luci-app-passwall: sync with upstream source

Co-authored-by: lededev <30518126+lededev@users.noreply.github.com>
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
xiaorouji 2021-03-20 20:03:26 +08:00 committed by Tianling Shen
parent 839d632b56
commit 6fedf2264f
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
14 changed files with 282 additions and 165 deletions

View File

@ -49,9 +49,6 @@ function index()
entry({"admin", "services", appname, "server_user_log"}, call("server_user_log")).leaf = true
entry({"admin", "services", appname, "server_get_log"}, call("server_get_log")).leaf = true
entry({"admin", "services", appname, "server_clear_log"}, call("server_clear_log")).leaf = true
entry({"admin", "services", appname, "link_append_temp"}, call("link_append_temp")).leaf = true
entry({"admin", "services", appname, "link_load_temp"}, call("link_load_temp")).leaf = true
entry({"admin", "services", appname, "link_clear_temp"}, call("link_clear_temp")).leaf = true
entry({"admin", "services", appname, "link_add_node"}, call("link_add_node")).leaf = true
entry({"admin", "services", appname, "get_now_use_node"}, call("get_now_use_node")).leaf = true
entry({"admin", "services", appname, "get_redir_log"}, call("get_redir_log")).leaf = true
@ -97,38 +94,10 @@ function hide_menu()
luci.http.redirect(luci.dispatcher.build_url("admin", "status", "overview"))
end
function link_append_temp()
local link = luci.http.formvalue("link")
local lfile = "/tmp/links.conf"
local ret, ldata="empty", {}
luci.sys.call('touch ' .. lfile .. ' && echo \'' .. link .. '\' >> ' .. lfile)
ret = luci.sys.exec([[awk -F'://' 'BEGIN{ all=0 } /.{2,9}:\/\/.{4,}$/ {gsub(/:\/\/.*$/,""); arr[$0]++; all++ } END { for(typ in arr) { printf("%s: %d, ", typ, arr[typ]) }; printf("\ntotal: %d", all) }' ]] .. lfile)
luci.http.prepare_content("application/json")
luci.http.write_json({counter = ret})
end
function link_load_temp()
local lfile = "/tmp/links.conf"
local ret, ldata="empty", {}
ldata[#ldata+1] = nixio.fs.readfile(lfile) or "_nofile_"
if ldata[1] == "" then
ldata[1] = "_nodata_"
else
ret = luci.sys.exec([[awk -F'://' 'BEGIN{ all=0 } /.{2,9}:\/\/.{4,}$/ {gsub(/:\/\/.*$/,""); arr[$0]++; all++ } END { for(typ in arr) { printf("%s: %d, ", typ, arr[typ]) }; printf("\ntotal: %d", all) }' ]] .. lfile)
end
luci.http.prepare_content("application/json")
luci.http.write_json({counter = ret, data = ldata})
end
function link_clear_temp()
local lfile = "/tmp/links.conf"
luci.sys.call('cat /dev/null > ' .. lfile)
end
function link_add_node()
local lfile = "/tmp/links.conf"
local link = luci.http.formvalue("link")
luci.sys.call('echo \'' .. link .. '\' >> ' .. lfile)
luci.sys.call('echo \'' .. link .. '\' > ' .. lfile)
luci.sys.call("lua /usr/share/passwall/subscribe.lua add log")
end

View File

@ -43,7 +43,7 @@ o.rmempty = true
sys.net.mac_hints(function(e, t) o:value(e, "%s (%s)" % {e, t}) end)
---- TCP Proxy Mode
tcp_proxy_mode = s:option(ListValue, "tcp_proxy_mode", "TCP" .. translate("Proxy Mode"))
tcp_proxy_mode = s:option(ListValue, "tcp_proxy_mode", translatef("%s Proxy Mode", "TCP"))
tcp_proxy_mode.default = "default"
tcp_proxy_mode.rmempty = false
tcp_proxy_mode:value("default", translate("Default"))
@ -57,7 +57,7 @@ else
end
---- UDP Proxy Mode
udp_proxy_mode = s:option(ListValue, "udp_proxy_mode", "UDP" .. translate("Proxy Mode"))
udp_proxy_mode = s:option(ListValue, "udp_proxy_mode", translatef("%s Proxy Mode", "UDP"))
udp_proxy_mode.default = "default"
udp_proxy_mode.rmempty = false
udp_proxy_mode:value("default", translate("Default"))

View File

@ -151,7 +151,7 @@ if has_xray and #nodes_table > 0 then
end
local id = "main_node"
o = s:taboption("Main", ListValue, v.id .. "." .. id, "* " .. translate("Default") .. translate("Preproxy"))
o = s:taboption("Main", ListValue, v.id .. "." .. id, "* " .. translate("Default") .. " " .. translate("Preproxy"))
o:depends("tcp_node", v.id)
o:value("nil", translate("Close"))
for k1, v1 in pairs(normal_list) do
@ -263,7 +263,7 @@ end
s:tab("Proxy", translate("Mode"))
---- TCP Default Proxy Mode
tcp_proxy_mode = s:taboption("Proxy", ListValue, "tcp_proxy_mode", "TCP" .. translate("Default") .. translate("Proxy Mode"))
tcp_proxy_mode = s:taboption("Proxy", ListValue, "tcp_proxy_mode", "TCP " .. translate("Default") .. translate("Proxy Mode"))
-- o.description = translate("If not available, try clearing the cache.")
tcp_proxy_mode:value("disable", translate("No Proxy"))
tcp_proxy_mode:value("global", translate("Global Proxy"))
@ -274,7 +274,7 @@ tcp_proxy_mode.default = "chnroute"
--tcp_proxy_mode.validate = redir_mode_validate
---- UDP Default Proxy Mode
udp_proxy_mode = s:taboption("Proxy", ListValue, "udp_proxy_mode", "UDP" .. translate("Default") .. translate("Proxy Mode"))
udp_proxy_mode = s:taboption("Proxy", ListValue, "udp_proxy_mode", "UDP " .. translate("Default") .. translate("Proxy Mode"))
udp_proxy_mode:value("disable", translate("No Proxy"))
udp_proxy_mode:value("global", translate("Global Proxy"))
udp_proxy_mode:value("gfwlist", translate("GFW List"))
@ -284,7 +284,7 @@ udp_proxy_mode.default = "chnroute"
--udp_proxy_mode.validate = redir_mode_validate
---- Localhost TCP Proxy Mode
localhost_tcp_proxy_mode = s:taboption("Proxy", ListValue, "localhost_tcp_proxy_mode", translate("Router Localhost") .. "TCP" .. translate("Proxy Mode"))
localhost_tcp_proxy_mode = s:taboption("Proxy", ListValue, "localhost_tcp_proxy_mode", translate("Router Localhost") .. " TCP " .. translate("Proxy Mode"))
-- o.description = translate("The server client can also use this rule to scientifically surf the Internet.")
localhost_tcp_proxy_mode:value("default", translate("Default"))
localhost_tcp_proxy_mode:value("global", translate("Global Proxy"))
@ -295,7 +295,7 @@ localhost_tcp_proxy_mode.default = "default"
--localhost_tcp_proxy_mode.validate = redir_mode_validate
---- Localhost UDP Proxy Mode
localhost_udp_proxy_mode = s:taboption("Proxy", ListValue, "localhost_udp_proxy_mode", translate("Router Localhost") .. "UDP" .. translate("Proxy Mode"))
localhost_udp_proxy_mode = s:taboption("Proxy", ListValue, "localhost_udp_proxy_mode", translate("Router Localhost") .. " UDP " .. translate("Proxy Mode"))
localhost_udp_proxy_mode:value("default", translate("Default"))
localhost_udp_proxy_mode:value("global", translate("Global Proxy"))
localhost_udp_proxy_mode:value("gfwlist", translate("GFW List"))
@ -306,13 +306,13 @@ localhost_udp_proxy_mode.default = "default"
localhost_udp_proxy_mode.validate = redir_mode_validate
s:tab("log", translate("Log"))
o = s:taboption("log", Flag, "close_log_tcp", translate("Close") .. translate("Log") .. " " .. translate("TCP Node"))
o = s:taboption("log", Flag, "close_log_tcp", translatef("%s Node Log Close", "TCP"))
o.rmempty = false
o = s:taboption("log", Flag, "close_log_udp", translate("Close") .. translate("Log") .. " " .. translate("UDP Node"))
o = s:taboption("log", Flag, "close_log_udp", translatef("%s Node Log Close", "UDP"))
o.rmempty = false
loglevel = s:taboption("log", ListValue, "loglevel", "X/V2ray" .. translate("Log Level"))
loglevel = s:taboption("log", ListValue, "loglevel", "Xray" .. translate("Log Level"))
loglevel.default = "warning"
loglevel:value("debug")
loglevel:value("info")
@ -333,7 +333,7 @@ o = s:taboption("tips", DummyValue, "")
o.template = appname .. "/global/tips"
-- [[ Socks Server ]]--
o = s:taboption("Main", Flag, "socks_enabled", "Socks" .. translate("Main switch"))
o = s:taboption("Main", Flag, "socks_enabled", "Socks " .. translate("Main switch"))
o.rmempty = false
s = m:section(TypedSection, "socks", translate("Socks Config"))
@ -358,13 +358,13 @@ o.rmempty = false
socks_node = s:option(ListValue, "node", translate("Socks Node"))
socks_node:value("tcp", translate("Same as the tcp node"))
o = s:option(Value, "port", "Socks" .. translate("Listen Port"))
o = s:option(Value, "port", "Socks " .. translate("Listen Port"))
o.default = 9050
o.datatype = "port"
o.rmempty = false
if has_xray then
o = s:option(Value, "http_port", "HTTP" .. translate("Listen Port") .. " " .. translate("0 is not use"))
o = s:option(Value, "http_port", "HTTP " .. translate("Listen Port") .. " " .. translate("0 is not use"))
o.default = 0
o.datatype = "port"
end

View File

@ -59,7 +59,7 @@ s = m:section(NamedSection, arg[1], "nodes", "")
s.addremove = false
s.dynamic = false
share = s:option(DummyValue, "passwall", translate("Share Current"))
share = s:option(DummyValue, "passwall", " ")
share.rawhtml = true
share.template = "passwall/node_list/link_share_man"
share.value = arg[1]

View File

@ -63,9 +63,9 @@ o.cfgvalue = function(t, n)
if type == "Xray" then
local protocol = m:get(n, "protocol")
if protocol == "_balancing" then
protocol = "负载均衡"
protocol = translate("Balancing")
elseif protocol == "_shunt" then
protocol = "分流"
protocol = translate("Shunt")
elseif protocol == "vmess" then
protocol = "VMess"
elseif protocol == "vless" then

View File

@ -56,7 +56,7 @@ o = s:option(Value, "xray_location_asset", translate("Location of Xray asset"),
o.default = "/usr/share/xray/"
o.rmempty = false
s = m:section(TypedSection, "shunt_rules", "Xray" .. translate("Shunt") .. translate("Rule"), "<a style='color: red'>" .. translate("Please note attention to the priority, the higher the order, the higher the priority.") .. "</a>")
s = m:section(TypedSection, "shunt_rules", "Xray " .. translate("Shunt Rule"), "<a style='color: red'>" .. translate("Please note attention to the priority, the higher the order, the higher the priority.") .. "</a>")
s.template = "cbi/tblsection"
s.anonymous = false
s.addremove = true

View File

@ -63,7 +63,7 @@ end
e = t:option(DummyValue, "port", translate("Port"))
e = t:option(Flag, "log", translate("Enable") .. translate("Log"))
e = t:option(Flag, "log", translate("Log"))
e.default = "1"
e.rmempty = false

View File

@ -54,11 +54,6 @@ s = m:section(NamedSection, arg[1], "user", "")
s.addremove = false
s.dynamic = false
share = s:option(DummyValue, "passwall_server", translate("Share Current"))
share.rawhtml = true
share.template = "passwall/node_list/link_share_man"
share.value = arg[1]
enable = s:option(Flag, "enable", translate("Enable"))
enable.default = "1"
enable.rmempty = false
@ -582,7 +577,7 @@ transit_node_password.password = true
transit_node_password:depends("transit_node", "_socks")
transit_node_password:depends("transit_node", "_http")
log = s:option(Flag, "log", translate("Enable") .. translate("Log"))
log = s:option(Flag, "log", translate("Log"))
log.default = "1"
log.rmempty = false

View File

@ -20,41 +20,6 @@ local api = require "luci.model.cbi.passwall.api.api"
<script type="text/javascript">
//<![CDATA[
function link_clear_temp() {
if (confirm('<%:Are you sure to clear all cached links?%>') == true){
XHR.get('<%=api.url("link_clear_temp")%>', null,
function(x, data) {
if(x && x.status == 200) {
window.location.href = '<%=api.url("node_list")%>';
}
else {
alert("<%:Error%>");
}
});
}
}
function link_load_temp() {
var inputer = document.getElementById("nodes_link");
XHR.get('<%=api.url("link_load_temp")%>', null,
function(x, data) {
if(x.readyState === 4 && x.status === 200) {
try {
res = JSON.parse(x.responseText);
}
catch(e) {
res = null;
}
if(res !== null && typeof(res) === "object") {
alert(res.counter);
if(res.data) inputer.value = res.data;
}
} else {
alert("<%:Error%>");
}
});
}
function ajax_add_node(link) {
if (link) {
XHR.get('<%=api.url("link_add_node")%>', {
@ -122,8 +87,6 @@ local api = require "luci.model.cbi.passwall.api.api"
<div class="cbi-value">
<div class="cbi-value-field" style="display: unset">
<input class="cbi-button cbi-button-add" type="button" onclick="add_node()" value="<%:Add%>" />
<!-- <input class="cbi-button cbi-button-apply" type="button" onclick="link_load_temp()" value="<%:Load Cached%>" /> -->
<!-- <input class="cbi-button cbi-button-refresh" type="button" onclick="link_clear_temp()" value="<%:Clear Cached%>" /> -->
<input class="cbi-button cbi-button-remove" type="button" onclick="close_add_link_div()" value="<%:Close%>" />
</div>
</div>

View File

@ -76,27 +76,6 @@ local api = require "luci.model.cbi.passwall.api.api"
return m && r;
}
function link_append_temp(link) {
XHR.get('<%=api.url("link_append_temp")%>', {
'link': link
},
function(x, data) {
if(x.readyState === 4 && x.status === 200) {
try {
res = JSON.parse(x.responseText);
}
catch(e) {
res = null;
}
if(res !== null && typeof(res) === "object") {
alert(res.counter);
}
} else {
alert("<%:Error%>");
}
});
}
function buildUrl(btn, urlname, sid) {
var opt = {
base: "cbid.passwall",
@ -108,11 +87,14 @@ local api = require "luci.model.cbi.passwall.api.api"
if (obj) {
return obj;
} else {
return null;
/*
obj = document.getElementById(this.fallback);
if (opt === "address") obj.value = "0.0.0.0";
else if (opt === "mux") obj.value = "0";
if (this.client || (opt !== "address" && opt !== "mux")) alert("<%:Faltal on get option, please help in debug: %>" + opt);
return obj;
*/
}
},
getlist: function(opt) {
@ -153,7 +135,35 @@ local api = require "luci.model.cbi.passwall.api.api"
var v_type = opt.get("type").value;
var v_alias = opt.get("remarks");
var url = null;
if (v_type === "SSR") {
if (v_type === "SS") {
var v_server = opt.get("address");
var v_port = opt.get("port");
var v_method = opt.get("ss_encrypt_method");
var v_password = opt.get("password");
url = b64encsafe(v_method.value + ":" + v_password.value) + "@" +
v_server.value + ":" +
v_port.value + "/?";
var params = "";
var v_plugin = opt.get("ss_plugin").value;
if (v_plugin && v_plugin != "none") {
if (v_plugin == "simple-obfs" || v_plugin == "obfs-local") {
v_plugin = "obfs-local";
}
var v_plugin_opts = opt.get("ss_plugin_opts").value;
if (v_plugin_opts && v_plugin_opts != "") {
v_plugin += encodeURI(";" + v_plugin_opts);
}
params += "&plugin=" + encodeURI(v_plugin);
}
params += "&group="
params += "#" + encodeURI(v_alias.value);
if (params[0] == "&") {
params = params.substring(1);
}
url += params;
} else if (v_type === "SSR") {
var v_server = opt.get("address");
var v_port = opt.get("port");
var v_protocol = opt.get("ssr_protocol");
@ -172,7 +182,98 @@ local api = require "luci.model.cbi.passwall.api.api"
"&protoparam=" + b64encsafe(v_protocol_param.value) +
"&remarks=" + b64encutf8safe(v_alias.value);
url = b64encsafe(ssr_str);
} else if (v_type === "Trojan" || v_type === "Trojan-Plus" || v_type === "Trojan-Go") {
} else if (v_type === "Xray" && opt.get("protocol").value === "vmess") {
v_type = "vmess";
var info = {};
info.v = "2";
info.ps = v_alias.value;
info.add = opt.get("address").value;
info.port = opt.get("port").value;
info.id = opt.get("uuid").value;
info.aid = opt.get("alter_id").value;
var v_transport = opt.get("transport").value;
if (v_transport === "ws") {
info.host = opt.get("ws_host").value;
info.path = opt.get("ws_path").value;
} else if (v_transport === "h2") {
info.host = opt.get("h2_host").value;
info.path = opt.get("h2_path").value;
} else if (v_transport === "tcp") {
info.type = opt.get("tcp_guise").value;
info.host = opt.get("tcp_guise_http_host").value;
info.path = opt.get("tcp_guise_http_path").value;
} else if (v_transport === "mkcp") {
v_transport = "kcp";
info.type = opt.get("mkcp_guise").value;
} else if (v_transport === "quic") {
info.type = opt.get("quic_guise").value;
info.key = opt.get("quic_key").value;
info.securty = opt.get("quic_security").value;
}
if (info.path && info.path != "") {
info.path = encodeURI(info.path);
}
info.net = v_transport;
info.security = opt.get("security").value || "auto";
if (opt.get("tls").checked) {
var v_security = "tls";
info.tls = "tls";
info.sni = opt.get("tls_serverName").value;
}
url = b64EncodeUnicode(JSON.stringify(info));
} else if (v_type === "Xray" && opt.get("protocol").value === "vless") {
v_type = "vless";
var v_password = opt.get("uuid");
var v_server = opt.get("address");
var v_port = opt.get("port");
url = encodeURIComponent(v_password.value) +
"@" + v_server.value +
":" + v_port.value + "?";
var params = "";
var v_transport = opt.get("transport").value;
if (v_transport === "ws") {
params += opt.query("host", "ws_host");
params += opt.query("path", "ws_path");
} else if (v_transport === "h2") {
params += opt.query("host", "h2_host");
params += opt.query("path", "h2_path");
} else if (v_transport === "tcp") {
params += opt.query("headerType", "tcp_guise");
params += opt.query("host", "tcp_guise_http_host");
params += opt.query("path", "tcp_guise_http_path");
} else if (v_transport === "mkcp") {
v_transport = "kcp";
params += opt.query("headerType", "mkcp_guise");
} else if (v_transport === "quic") {
params += opt.query("headerType", "quic_guise");
params += opt.query("key", "quic_key");
params += opt.query("quicSecurity", "quic_security");
}
params += "&type=" + v_transport;
params += opt.query("encryption", "encryption");
if (opt.get("tls").checked) {
var v_security = "tls";
if (opt.get("xtls").checked) {
v_security = "xtls";
var v_flow = "xtls-rprx-direct";
if (opt.get("flow").value) {
v_flow = opt.get("flow").value;
}
params += "&flow=" + v_flow;
}
params += "&security=" + v_security;
params += opt.query("sni", "tls_serverName");
}
params += "#" + encodeURI(v_alias.value);
if (params[0] == "&") {
params = params.substring(1);
}
url += params;
} else if ((v_type === "Xray" && opt.get("protocol").value === "trojan") || v_type === "Trojan" || v_type === "Trojan-Plus" || v_type === "Trojan-Go") {
var v_password = opt.get(!opt.client && v_type === "Trojan-Go" ? "passwords" : "password");
var v_server = opt.get("address");
var v_port = opt.get("port");
@ -182,7 +283,7 @@ local api = require "luci.model.cbi.passwall.api.api"
if (opt.get("tls").checked) {
url += opt.query("sni", "tls_serverName");
if (v_type !== "Trojan-Go") {
url += "tls=1"
url += "&tls=1"
url += opt.query("allowinsecure", "tls_allowInsecure");
}
}
@ -219,7 +320,6 @@ local api = require "luci.model.cbi.passwall.api.api"
}
if (url) {
url = v_type.toLowerCase() + "://" + url;
link_append_temp(url);
var textarea = document.createElement("textarea");
textarea.textContent = url;
textarea.style.position = "fixed";
@ -227,12 +327,13 @@ local api = require "luci.model.cbi.passwall.api.api"
textarea.select();
try {
document.execCommand("copy"); // Security exception may be thrown by some browsers.
s.innerHTML = "<font color='green'><%:Share to clipboard successfully, copy to batch mode still: %></font>";
s.innerHTML = "<font color='green'><%:Share url to clipboard successfully.%></font>";
} catch (ex) {
s.innerHTML = "<font color='red'><%:Unable share to clipboard, copy to batch mode still: %></font>";
s.innerHTML = "<font color='red'><%:Share url to clipboard unable.%></font>";
} finally {
document.body.removeChild(textarea);
}
//alert(url);
} else {
alert("<%:Not a supported scheme:%> " + v_type);
}
@ -268,7 +369,7 @@ local api = require "luci.model.cbi.passwall.api.api"
obj.value = val;
}
} else {
alert('<%:Faltal on set option, please help in debug: %>' + opt + ' = ' + val);
//alert('<%:Faltal on set option, please help in debug: %>' + opt + ' = ' + val);
}
},
setlist: function(opt, vlist) {
@ -281,7 +382,7 @@ local api = require "luci.model.cbi.passwall.api.api"
}
alert("Manually input the option:\n" + opt + "s:\n[" + values + "]");
} else {
alert("<%:Faltal on set option, please help in debug: %>" + opt);
//alert("<%:Faltal on set option, please help in debug: %>" + opt);
}
}
}
@ -296,7 +397,6 @@ local api = require "luci.model.cbi.passwall.api.api"
opt.fallback = urlname + '-dummy';
var ssrurl = prompt('<%:Paste Share URL Here%>', '');
if (ssrurl === null || ssrurl === "") {
s.innerHTML = "<font color='red'><%:User cancelled%></font>";
return false;
}
s.innerHTML = "";
@ -351,7 +451,6 @@ local api = require "luci.model.cbi.passwall.api.api"
} else {
url0 = ssu[1];
}
console.log(param);
if (sipIndex !== -1) {
// SIP002
var userInfo = b64decsafe(url0.substr(0, sipIndex));
@ -378,8 +477,12 @@ local api = require "luci.model.cbi.passwall.api.api"
opt.set('port', port);
opt.set('password', password || "");
opt.set('ss_encrypt_method', method || "");
opt.set('ss_plugin', plugin || "");
opt.set('ss_plugin_opts', pluginOpts || "");
opt.set('ss_plugin', plugin || "none");
if (plugin && plugin != "none") {
opt.get('ss_plugin').dispatchEvent(event);
opt.set('ss_plugin_opts', pluginOpts || "");
opt.get('ss_plugin_opts').dispatchEvent(event);
}
if (param !== undefined) {
opt.set('remarks', decodeURI(param));
}
@ -394,8 +497,9 @@ local api = require "luci.model.cbi.passwall.api.api"
opt.set('port', part2[1]);
opt.set('password', part1[1]);
opt.set('ss_encrypt_method', part1[0]);
opt.set('ss_plugin', "");
opt.set('ss_plugin_opts', "");
opt.set('ss_plugin', "none");
opt.get('ss_plugin').dispatchEvent(event);
//opt.set('ss_plugin_opts', "");
if (param !== undefined) {
opt.set('remarks', decodeURI(param));
}
@ -552,6 +656,8 @@ local api = require "luci.model.cbi.passwall.api.api"
var ploc = sstr.indexOf("/?");
opt.set('type', "Xray");
opt.get('type').dispatchEvent(event);
opt.set('protocol', "vmess");
opt.get('protocol').dispatchEvent(event);
var url0, param = "";
if (ploc > 0) {
url0 = sstr.substr(0, ploc);
@ -567,8 +673,14 @@ local api = require "luci.model.cbi.passwall.api.api"
opt.set('tls', ssm.tls === "tls");
opt.get('tls').dispatchEvent(event);
if (ssm.tls === "tls") {
opt.set('tls_serverName', ssm.host);
var tls_serverName = ssm.host;
if (ssm.sni) {
tls_serverName = ssm.sni
}
opt.set('tls_serverName', tls_serverName);
}
if (ssm.net === "kcp" || ssm.net === "mkcp")
ssm.net = "mkcp"
opt.set('transport', ssm.net);
opt.get('transport').dispatchEvent(event);
if (ssm.net === "tcp") {
@ -587,10 +699,83 @@ local api = require "luci.model.cbi.passwall.api.api"
} else if (ssm.net === "quic") {
opt.set('quic_security', ssm.securty);
opt.set('quic_key', ssm.key);
} else if (ssm.net === "kcp") {
} else if (ssm.net === "kcp" || ssm.net === "mkcp") {
opt.set('mkcp_guise', ssm.type);
opt.get('mkcp_guise').dispatchEvent(event);
}
} else if (ssu[0] === "vless") {
opt.set('type', "Xray");
opt.get('type').dispatchEvent(event);
opt.set('protocol', "vless");
opt.get('protocol').dispatchEvent(event);
var m = parseNodeUrl(ssrurl);
console.log(m.search);
var password = m.passwd;
if (password === "") {
s.innerHTML = "<font color='red'><%:Invalid Share URL Format%></font>";
return false;
}
opt.set('uuid', password);
opt.set('address', m.hostname);
opt.set('port', m.port || "443");
var queryParam = {};
if (m.search.length > 1) {
var query = m.search.split('?');
var queryParams = query[1];
var queryArray = queryParams.split('&');
var params;
for (i = 0; i < queryArray.length; i++) {
params = queryArray[i].split('=');
queryParam[decodeURIComponent(params[0])] = decodeURIComponent(params[1] || '');
}
}
opt.set('encryption', queryParam.encryption);
if (queryParam.security) {
if (queryParam.security == "tls" || queryParam.security == "xtls") {
opt.set('tls', true);
opt.get('tls').dispatchEvent(event);
if (queryParam.security == "xtls") {
opt.set('xtls', true);
opt.get('xtls').dispatchEvent(event);
opt.set('flow', queryParam.flow || "xtls-rprx-direct");
}
opt.set('tls_serverName', queryParam.sni || '');
opt.set('tls_allowInsecure', true);
if (queryParam.allowinsecure === '0') {
opt.set('tls_allowInsecure', false);
}
opt.get('tls_allowInsecure').dispatchEvent(event);
}
}
if (queryParam.type === "kcp" || queryParam.type === "mkcp")
queryParam.type = "mkcp"
opt.set('transport', queryParam.type);
opt.get('transport').dispatchEvent(event);
if (queryParam.type === "tcp") {
opt.set('tcp_guise', queryParam.headerType || "none");
opt.get('tcp_guise').dispatchEvent(event);
if (queryParam.headerType && queryParam.headerType != "none") {
opt.set('tcp_guise_http_host', queryParam.host || "");
opt.set('tcp_guise_http_path', queryParam.path || "");
}
} else if (queryParam.type === "ws") {
opt.set('ws_host', queryParam.host || "");
opt.set('ws_path', queryParam.path || "");
} else if (queryParam.type === "h2") {
opt.set('h2_host', queryParam.host || "");
opt.set('h2_path', queryParam.path || "");
} else if (queryParam.type === "quic") {
opt.set('quic_guise', queryParam.headerType || "none");
opt.get('quic_guise').dispatchEvent(event);
opt.set('quic_security', queryParam.quicSecurity);
opt.set('quic_key', queryParam.key);
} else if (queryParam.type === "kcp" || queryParam.type === "mkcp") {
opt.set('mkcp_guise', queryParam.headerType || "none");
opt.get('mkcp_guise').dispatchEvent(event);
}
} else {
s.innerHTML = "<font color='red'><%:Invalid Share URL Format%></font>: " + ssu[0];
return false;
@ -600,7 +785,7 @@ local api = require "luci.model.cbi.passwall.api.api"
}
//]]></script>
<input type="text" class="hidden" id='<%=self.option%>-dummy' value="0.0.0.0" />
<input type="text" class="hidden" id='<%=self.option%>-dummy' value="" />
<input type="button" class="cbi-button cbi-button-apply" value='<%:From Share URL%>' onclick="return fromUrl(this, '<%=self.option%>', '<%=self.value%>')" />
<input type="button" class="cbi-button cbi-button-apply" value='<%:Build Share URL%>' onclick="return buildUrl(this, '<%=self.option%>', '<%=self.value%>')" />
<span id="<%=self.option%>-status"></span>

View File

@ -292,6 +292,9 @@ msgstr "单进程"
msgid "Proxy Mode"
msgstr "代理模式"
msgid "%s Proxy Mode"
msgstr "%s 代理模式"
msgid "If not available, try clearing the cache."
msgstr "如果无法使用,请尝试清除缓存。"
@ -337,12 +340,6 @@ msgstr "SS/SSR/Vmess/VLESS/Trojan链接"
msgid "Please enter the correct link, ss:// ssr:// vmess:// vless:// trojan://"
msgstr "请输入正确的链接ss:// ssr:// vmess:// vless:// trojan://"
msgid "Load Cached"
msgstr "加载缓存"
msgid "Clear Cached"
msgstr "清除缓存"
msgid "Clear all nodes"
msgstr "清空所有节点"
@ -451,14 +448,11 @@ msgstr "负载均衡节点列表"
msgid "Load balancing node list, <a target='_blank' href='https://toutyrater.github.io/routing/balance2.html'>document</a>"
msgstr "负载均衡节点列表,<a target='_blank' href='https://toutyrater.github.io/routing/balance2.html'>文档原理</a>"
msgid "Share Current"
msgstr "所见即所得"
msgid "From Share URL"
msgstr "导入配置信息"
msgstr "导入分享URL"
msgid "Build Share URL"
msgstr "导出配置信息"
msgstr "导出分享URL"
msgid "Import Finished"
msgstr "导入完成:"
@ -467,19 +461,16 @@ msgid "Not a supported scheme:"
msgstr "不支持这种样式的:"
msgid "Invalid Share URL Format"
msgstr "无效的分享信息"
msgid "User cancelled"
msgstr "用户已取消"
msgstr "无效的分享URL信息"
msgid "Paste Share URL Here"
msgstr "在此处粘贴分享信息"
msgid "Unable share to clipboard, copy to batch mode still:"
msgstr "无法分享网址到剪贴板,复制到批量导入临时输入:"
msgid "Share url to clipboard unable."
msgstr "无法分享URL到剪贴板。"
msgid "Share to clipboard successfully, copy to batch mode still:"
msgstr "成功复制分享网址到剪贴板和批量导入临时输入:"
msgid "Share url to clipboard successfully."
msgstr "成功复制分享URL到剪贴板。"
msgid "Faltal on get option, please help in debug:"
msgstr "代码错误,请协助捉虫:"
@ -766,6 +757,9 @@ msgstr "Xray 资源文件目录"
msgid "This variable specifies a directory where geoip.dat and geosite.dat files are."
msgstr "此变量指定geoip.dat和geosite.dat文件所在的目录。"
msgid "Shunt Rule"
msgstr "分流规则"
msgid "Please note attention to the priority, the higher the order, the higher the priority."
msgstr "请注意优先级问题,排序越上面优先级越高。"
@ -1183,6 +1177,9 @@ msgstr "日志"
msgid "Log"
msgstr "日志"
msgid "%s Node Log Close"
msgstr "%s 节点日志关闭"
msgid "Log Level"
msgstr "日志等级"

View File

@ -801,7 +801,8 @@ start_dns() {
nonuse)
echolog " - 不过滤DNS..."
TUN_DNS=""
return
use_chinadns_ng=$(config_t_get global always_use_chinadns_ng 0)
[ "$use_chinadns_ng" == "0" ] && return
;;
dns2socks)
local dns2socks_socks_server=$(echo $(config_t_get global socks_server 127.0.0.1:9050) | sed "s/#/:/g")

View File

@ -62,7 +62,7 @@ RULE_LAST_INDEX() {
local chain=${1}; shift
local list=${1}; shift
local default=${1:-0}; shift
local _index=$($ipt_tmp -n -L $chain --line-numbers 2>/dev/null | grep "$list" | sed -n '$p' | awk '{print $1}')
local _index=$($ipt_tmp -n -L $chain --line-numbers 2>/dev/null | grep "$list" | head -n 1 | awk '{print $1}')
echo "${_index:-${default}}"
}
@ -550,27 +550,29 @@ add_firewall_rule() {
# 过滤所有节点IP
filter_vpsip > /dev/null 2>&1 &
filter_haproxy > /dev/null 2>&1 &
# 据说能提升性能?
$ipt_m -N PSW_DIVERT
$ipt_m -A PSW_DIVERT -j MARK --set-mark 1
$ipt_m -A PSW_DIVERT -j ACCEPT
$ipt_m -A PREROUTING -p tcp -m socket -j PSW_DIVERT
$ipt_n -N PSW
$ipt_n -A PSW $(dst $IPSET_LANIPLIST) -j RETURN
$ipt_n -A PSW $(dst $IPSET_VPSIPLIST) -j RETURN
$ipt_n -A PSW $(dst $IPSET_WHITELIST) -j RETURN
$ipt_n -A PSW -m mark --mark 0xff -j RETURN
local PR_INDEX=$(RULE_LAST_INDEX "$ipt_n" PREROUTING prerouting_rule)
PR_INDEX=$(RULE_LAST_INDEX "$ipt_n" PREROUTING prerouting_rule)
PR_INDEX=$((PR_INDEX + 1))
$ipt_n -I PREROUTING $PR_INDEX -p tcp -j PSW
unset PR_INDEX
$ipt_n -N PSW_OUTPUT
$ipt_n -A PSW_OUTPUT $(dst $IPSET_LANIPLIST) -j RETURN
$ipt_n -A PSW_OUTPUT $(dst $IPSET_VPSIPLIST) -j RETURN
$ipt_n -A PSW_OUTPUT $(dst $IPSET_WHITELIST) -j RETURN
$ipt_n -A PSW_OUTPUT -m mark --mark 0xff -j RETURN
# 据说能提升性能?
PR_INDEX=$(RULE_LAST_INDEX "$ipt_m" PREROUTING mwan3 1)
$ipt_m -N PSW_DIVERT
$ipt_m -A PSW_DIVERT -j MARK --set-mark 1
$ipt_m -A PSW_DIVERT -j ACCEPT
$ipt_m -I PREROUTING $PR_INDEX -p tcp -m socket -j PSW_DIVERT
$ipt_m -N PSW
$ipt_m -A PSW $(dst $IPSET_LANIPLIST) -j RETURN
@ -578,7 +580,9 @@ add_firewall_rule() {
$ipt_m -A PSW $(dst $IPSET_WHITELIST) -j RETURN
$ipt_m -A PSW -m mark --mark 0xff -j RETURN
$ipt_m -A PSW $(dst $IPSET_BLOCKLIST) -j DROP
$ipt_m -A PREROUTING -j PSW
PR_INDEX=$((PR_INDEX + 1))
$ipt_m -I PREROUTING $PR_INDEX -j PSW
unset PR_INDEX
$ipt_m -N PSW_OUTPUT
$ipt_m -A PSW_OUTPUT $(dst $IPSET_LANIPLIST) -j RETURN

View File

@ -328,7 +328,6 @@ local function processData(szType, content, add_mode)
result.address = info.add
result.port = info.port
result.protocol = 'vmess'
result.transport = info.net
result.alter_id = info.aid
result.uuid = info.id
result.remarks = info.ps
@ -350,7 +349,8 @@ local function processData(szType, content, add_mode)
result.tcp_guise_http_host = info.host
result.tcp_guise_http_path = info.path
end
if info.net == 'kcp' then
if info.net == 'kcp' or info.net == 'mkcp' then
info.net = "mkcp"
result.mkcp_guise = info.type
result.mkcp_mtu = 1350
result.mkcp_tti = 50
@ -364,10 +364,11 @@ local function processData(szType, content, add_mode)
result.quic_key = info.key
result.quic_security = info.securty
end
result.transport = info.net
if not info.security then result.security = "auto" end
if info.tls == "tls" or info.tls == "1" then
result.tls = "1"
result.tls_serverName = info.host
result.tls_serverName = info.sni
result.tls_allowInsecure = allowInsecure_default and "1" or "0"
else
result.tls = "0"
@ -598,7 +599,7 @@ local function processData(szType, content, add_mode)
local params = {}
for _, v in pairs(split(query[2], '&')) do
local t = split(v, '=')
params[string.lower(t[1])] = UrlDecode(t[2])
params[t[1]] = UrlDecode(t[2])
end
if params.type == 'ws' then
@ -614,7 +615,8 @@ local function processData(szType, content, add_mode)
result.tcp_guise_http_host = params.host
result.tcp_guise_http_path = params.path
end
if params.type == 'kcp' then
if params.type == 'kcp' or params.type == 'mkcp' then
params.type = "mkcp"
result.mkcp_guise = params.headerType or "none"
result.mkcp_mtu = 1350
result.mkcp_tti = 50
@ -628,6 +630,7 @@ local function processData(szType, content, add_mode)
result.quic_key = params.key
result.quic_security = params.quicSecurity or "none"
end
result.transport = params.type
result.encryption = params.encryption or "none"