update 2024-03-20 00:20:04
This commit is contained in:
parent
029bd2df22
commit
3583b5857a
|
@ -5,7 +5,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall2
|
||||
PKG_VERSION:=1.28-2
|
||||
PKG_VERSION:=1.28-3
|
||||
PKG_RELEASE:=
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -52,6 +52,7 @@ function index()
|
|||
entry({"admin", "services", appname, "socks_autoswitch_remove_node"}, call("socks_autoswitch_remove_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
|
||||
entry({"admin", "services", appname, "get_socks_log"}, call("get_socks_log")).leaf = true
|
||||
entry({"admin", "services", appname, "get_log"}, call("get_log")).leaf = true
|
||||
entry({"admin", "services", appname, "clear_log"}, call("clear_log")).leaf = true
|
||||
entry({"admin", "services", appname, "status"}, call("status")).leaf = true
|
||||
|
@ -167,6 +168,18 @@ function get_redir_log()
|
|||
end
|
||||
end
|
||||
|
||||
function get_socks_log()
|
||||
local name = luci.http.formvalue("name")
|
||||
local path = "/tmp/etc/passwall2/SOCKS_" .. name .. ".log"
|
||||
if nixio.fs.access(path) then
|
||||
local content = luci.sys.exec("cat ".. path)
|
||||
content = content:gsub("\n", "<br />")
|
||||
luci.http.write(content)
|
||||
else
|
||||
luci.http.write(string.format("<script>alert('%s');window.close();</script>", i18n.translate("Not enabled log")))
|
||||
end
|
||||
end
|
||||
|
||||
function get_log()
|
||||
-- luci.sys.exec("[ -f /tmp/log/passwall2.log ] && sed '1!G;h;$!d' /tmp/log/passwall2.log > /tmp/log/passwall2_show.log")
|
||||
luci.http.write(luci.sys.exec("[ -f '/tmp/log/passwall2.log' ] && cat /tmp/log/passwall2.log"))
|
||||
|
|
|
@ -141,6 +141,10 @@ o.default = 0
|
|||
o:depends("auto_update", true)
|
||||
|
||||
o = s:option(Value, "user_agent", translate("User-Agent"))
|
||||
o.default = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
|
||||
o.default = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0"
|
||||
o:value("curl")
|
||||
o:value("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0")
|
||||
o:value("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0")
|
||||
o:value("Passwall2/OpenWrt")
|
||||
|
||||
return m
|
||||
|
|
|
@ -61,6 +61,10 @@ if has_singbox or has_xray then
|
|||
o.datatype = "port"
|
||||
end
|
||||
|
||||
o = s:option(Flag, "log", translate("Enable") .. " " .. translate("Log"))
|
||||
o.default = 1
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Flag, "enable_autoswitch", translate("Auto Switch"))
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
|
|
|
@ -10,7 +10,7 @@ jsonc = require "luci.jsonc"
|
|||
i18n = require "luci.i18n"
|
||||
|
||||
appname = "passwall2"
|
||||
curl_args = {"-skfL", "--connect-timeout 3", "--retry 3", "-m 60"}
|
||||
curl_args = { "-skfL", "--connect-timeout 3", "--retry 3" }
|
||||
command_timeout = 300
|
||||
OPENWRT_ARCH = nil
|
||||
DISTRIB_ARCH = nil
|
||||
|
@ -805,7 +805,10 @@ function to_download(app_name, url, size)
|
|||
end
|
||||
end
|
||||
|
||||
local return_code, result = curl_logic(url, tmp_file, curl_args)
|
||||
local _curl_args = clone(curl_args)
|
||||
table.insert(_curl_args, "-m 60")
|
||||
|
||||
local return_code, result = curl_logic(url, tmp_file, _curl_args)
|
||||
result = return_code == 0
|
||||
|
||||
if not result then
|
||||
|
|
|
@ -114,12 +114,22 @@ local api = require "luci.passwall2.api"
|
|||
node_select.title = node_select.options[node_select.options.selectedIndex].text;
|
||||
}
|
||||
|
||||
|
||||
var new_html = ""
|
||||
|
||||
var new_a = document.createElement("a");
|
||||
new_a.innerHTML = "<%:Edit%>";
|
||||
new_a.href = "#";
|
||||
new_a.setAttribute("onclick","location.href='" + '<%=api.url("node_config")%>' + "/" + node_select_value + "'");
|
||||
|
||||
node_select.insertAdjacentHTML("afterend", "  " + new_a.outerHTML);
|
||||
new_html = new_a.outerHTML;
|
||||
|
||||
var log_a = document.createElement("a");
|
||||
log_a.innerHTML = "<%:Log%>";
|
||||
log_a.href = "#";
|
||||
log_a.setAttribute("onclick", "window.open('" + '<%=api.url("get_socks_log")%>' + "?name=" + id.replace("cbi-passwall2-", "") + "', '_blank')");
|
||||
new_html += " " + log_a.outerHTML;
|
||||
|
||||
node_select.insertAdjacentHTML("afterend", "  " + new_html);
|
||||
}
|
||||
} catch(err) {
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<%
|
||||
local api = require "luci.passwall2.api"
|
||||
-%>
|
||||
<script src="<%=resource%>/qrcode.min.js"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
let has_singbox = "<%=api.finded_com("singbox")%>"
|
||||
let has_xray = "<%=api.finded_com("xray")%>"
|
||||
|
@ -72,6 +73,20 @@ local api = require "luci.passwall2.api"
|
|||
};
|
||||
return r;
|
||||
}
|
||||
|
||||
function genQrcode(btn, urlname, sid) {
|
||||
var qrcode_div = document.getElementById("qrcode_div");
|
||||
qrcode_div.style.display = null;
|
||||
document.getElementById("qrcode").innerHTML = "";
|
||||
var url = buildUrl(btn, urlname, sid);
|
||||
if (url) {
|
||||
var qrcode = new QRCode(document.getElementById("qrcode"), {
|
||||
width: 150,
|
||||
height: 150
|
||||
});
|
||||
qrcode.makeCode(url);
|
||||
}
|
||||
}
|
||||
|
||||
function buildUrl(btn, urlname, sid) {
|
||||
var opt = {
|
||||
|
@ -115,12 +130,6 @@ local api = require "luci.passwall2.api"
|
|||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
var s = document.getElementById(urlname + "-status");
|
||||
if (!s) {
|
||||
alert("Never");
|
||||
return false;
|
||||
}
|
||||
opt.base = "cbid." + urlname + "." + sid;
|
||||
opt.client = urlname.indexOf("server") === -1;
|
||||
var v_type = opt.get("type").value;
|
||||
|
@ -369,12 +378,27 @@ local api = require "luci.passwall2.api"
|
|||
}
|
||||
if (url) {
|
||||
url = protocol.toLowerCase() + "://" + url;
|
||||
return url;
|
||||
} else {
|
||||
alert("<%:Not a supported scheme:%> " + v_type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function exportUrl(btn, urlname, sid) {
|
||||
var url = buildUrl(btn, urlname, sid);
|
||||
if (url) {
|
||||
var textarea = document.createElement("textarea");
|
||||
textarea.textContent = url;
|
||||
textarea.style.position = "fixed";
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
try {
|
||||
var s = document.getElementById(urlname + "-status");
|
||||
if (!s) {
|
||||
alert("Never");
|
||||
return false;
|
||||
}
|
||||
document.execCommand("copy"); // Security exception may be thrown by some browsers.
|
||||
s.innerHTML = "<font color='green'><%:Share URL to clipboard successfully.%></font>";
|
||||
} catch (ex) {
|
||||
|
@ -382,11 +406,7 @@ local api = require "luci.passwall2.api"
|
|||
} finally {
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
//alert(url);
|
||||
} else {
|
||||
alert("<%:Not a supported scheme:%> " + v_type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function fromUrl(btn, urlname, sid) {
|
||||
|
@ -906,6 +926,10 @@ local api = require "luci.passwall2.api"
|
|||
|
||||
//]]></script>
|
||||
<input type="button" class="btn cbi-button cbi-button-apply" value='<%:From Share URL%>' onclick="return fromUrl(this, '<%=self.option%>', '<%=self.value%>')" />
|
||||
<input type="button" class="btn cbi-button cbi-button-apply" value='<%:Build Share URL%>' onclick="return buildUrl(this, '<%=self.option%>', '<%=self.value%>')" />
|
||||
<input type="button" class="btn cbi-button cbi-button-apply" value='<%:Build Share URL%>' onclick="return exportUrl(this, '<%=self.option%>', '<%=self.value%>')" />
|
||||
<input type="button" class="btn cbi-button cbi-button-apply" value='<%:Generate QRCode%>' onclick="return genQrcode(this, '<%=self.option%>', '<%=self.value%>')" />
|
||||
<div id="qrcode_div" style="margin-top: 1rem;display:none">
|
||||
<div id="qrcode"></div>
|
||||
</div>
|
||||
<span id="<%=self.option%>-status"></span>
|
||||
<%+cbi/valuefooter%>
|
||||
|
|
|
@ -418,6 +418,9 @@ msgstr "导入分享URL"
|
|||
msgid "Build Share URL"
|
||||
msgstr "导出分享URL"
|
||||
|
||||
msgid "Generate QRCode"
|
||||
msgstr "生成二维码"
|
||||
|
||||
msgid "Import Finished"
|
||||
msgstr "导入完成:"
|
||||
|
||||
|
|
|
@ -543,8 +543,13 @@ run_socks() {
|
|||
local _extra_param="-local_http_port $http_port"
|
||||
}
|
||||
[ -n "$relay_port" ] && _extra_param="${_extra_param} -server_host $server_host -server_port $port"
|
||||
[ "${log_file}" != "/dev/null" ] && {
|
||||
local loglevel=$(config_t_get global loglevel "warn")
|
||||
[ "$loglevel" = "warning" ] && loglevel="warn"
|
||||
_extra_param="${_extra_param} -log 1 -loglevel $loglevel -logfile $log_file"
|
||||
}
|
||||
lua $UTIL_SINGBOX gen_config -flag SOCKS_$flag -node $node -local_socks_port $socks_port ${_extra_param} > $config_file
|
||||
ln_run "$(first_type $(config_t_get global_app singbox_file) sing-box)" "sing-box" $log_file run -c "$config_file"
|
||||
ln_run "$(first_type $(config_t_get global_app singbox_file) sing-box)" "sing-box" /dev/null run -c "$config_file"
|
||||
;;
|
||||
xray)
|
||||
[ "$http_port" != "0" ] && {
|
||||
|
@ -625,10 +630,12 @@ socks_node_switch() {
|
|||
local port=$(config_n_get $flag port)
|
||||
local config_file="SOCKS_${flag}.json"
|
||||
local log_file="SOCKS_${flag}.log"
|
||||
local log=$(config_n_get $id log 1)
|
||||
[ "$log" == "0" ] && log_file=""
|
||||
local http_port=$(config_n_get $flag http_port 0)
|
||||
local http_config_file="HTTP2SOCKS_${flag}.json"
|
||||
LOG_FILE="/dev/null"
|
||||
run_socks flag=$flag node=$new_node bind=0.0.0.0 socks_port=$port config_file=$config_file http_port=$http_port http_config_file=$http_config_file
|
||||
run_socks flag=$flag node=$new_node bind=0.0.0.0 socks_port=$port config_file=$config_file http_port=$http_port http_config_file=$http_config_file log_file=$log_file
|
||||
echo $new_node > $TMP_ID_PATH/socks_${flag}
|
||||
}
|
||||
}
|
||||
|
@ -718,9 +725,11 @@ start_socks() {
|
|||
local port=$(config_n_get $id port)
|
||||
local config_file="SOCKS_${id}.json"
|
||||
local log_file="SOCKS_${id}.log"
|
||||
local log=$(config_n_get $flag log 1)
|
||||
[ "$log" == "0" ] && log_file=""
|
||||
local http_port=$(config_n_get $id http_port 0)
|
||||
local http_config_file="HTTP2SOCKS_${id}.json"
|
||||
run_socks flag=$id node=$node bind=0.0.0.0 socks_port=$port config_file=$config_file http_port=$http_port http_config_file=$http_config_file
|
||||
run_socks flag=$id node=$node bind=0.0.0.0 socks_port=$port config_file=$config_file http_port=$http_port http_config_file=$http_config_file log_file=$log_file
|
||||
echo $node > $TMP_ID_PATH/socks_${id}
|
||||
|
||||
#自动切换逻辑
|
||||
|
|
|
@ -891,13 +891,11 @@ local function processData(szType, content, add_mode, add_from)
|
|||
end
|
||||
|
||||
local function curl(url, file, ua)
|
||||
if not ua or ua == "" then
|
||||
ua = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
|
||||
local curl_args = api.clone(api.curl_args)
|
||||
if ua and ua ~= "" and ua ~= "curl" then
|
||||
table.insert(curl_args, '--user-agent "' .. ua .. '"')
|
||||
end
|
||||
local args = {
|
||||
"-skL", "--retry 3", "--connect-timeout 3", '--user-agent "' .. ua .. '"'
|
||||
}
|
||||
local return_code, result = api.curl_logic(url, file, args)
|
||||
local return_code, result = api.curl_logic(url, file, curl_args)
|
||||
return return_code
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue