mirror of
https://github.com/kenzok8/small.git
synced 2025-01-07 03:26:39 +08:00
update 2024-03-19 20:17:56
This commit is contained in:
parent
ca87dcb23b
commit
8990b3fa1f
@ -6,7 +6,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall
|
||||
PKG_VERSION:=4.75-10
|
||||
PKG_VERSION:=4.76-1
|
||||
PKG_RELEASE:=
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
|
1
luci-app-passwall/htdocs/luci-static/resources/qrcode.min.js
vendored
Normal file
1
luci-app-passwall/htdocs/luci-static/resources/qrcode.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -54,6 +54,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
|
||||
@ -179,6 +180,18 @@ function get_redir_log()
|
||||
end
|
||||
end
|
||||
|
||||
function get_socks_log()
|
||||
local name = luci.http.formvalue("name")
|
||||
local path = "/tmp/etc/passwall/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/passwall.log ] && sed '1!G;h;$!d' /tmp/log/passwall.log > /tmp/log/passwall_show.log")
|
||||
luci.http.write(luci.sys.exec("[ -f '/tmp/log/passwall.log' ] && cat /tmp/log/passwall.log"))
|
||||
|
@ -146,6 +146,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("Passwall/OpenWrt")
|
||||
|
||||
return m
|
||||
|
@ -1,6 +1,7 @@
|
||||
local api = require "luci.passwall.api"
|
||||
local appname = "passwall"
|
||||
local uci = api.uci
|
||||
local has_singbox = api.finded_com("singbox")
|
||||
local has_xray = api.finded_com("xray")
|
||||
|
||||
m = Map(appname)
|
||||
@ -54,12 +55,16 @@ o.default = n + 1080
|
||||
o.datatype = "port"
|
||||
o.rmempty = false
|
||||
|
||||
if has_xray then
|
||||
if has_singbox or has_xray then
|
||||
o = s:option(Value, "http_port", "HTTP " .. translate("Listen Port") .. " " .. translate("0 is not use"))
|
||||
o.default = 0
|
||||
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 = "passwall"
|
||||
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
|
||||
@ -820,7 +820,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
|
||||
|
@ -62,7 +62,7 @@ _M["chinadns-ng"] = {
|
||||
default_path = "/usr/bin/chinadns-ng",
|
||||
match_fmt_str = "%s",
|
||||
file_tree = {
|
||||
x86_64 = "x86_64",
|
||||
x86_64 = "x86_64@",
|
||||
x86 = "i686",
|
||||
mips = "mips%-.*mips32%+soft_float@",
|
||||
mipsel = "mipsel.*mips32%+soft_float@",
|
||||
|
@ -125,12 +125,21 @@ local api = require "luci.passwall.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 + "'");
|
||||
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-passwall-", "") + "', '_blank')");
|
||||
new_html += " " + log_a.outerHTML;
|
||||
|
||||
node_select.insertAdjacentHTML("afterend", "  " + new_a.outerHTML);
|
||||
node_select.insertAdjacentHTML("afterend", "  " + new_html);
|
||||
}
|
||||
} catch(err) {
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
<%
|
||||
local api = require "luci.passwall.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.passwall.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.passwall.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;
|
||||
@ -384,12 +393,27 @@ local api = require "luci.passwall.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) {
|
||||
@ -397,11 +421,7 @@ local api = require "luci.passwall.api"
|
||||
} finally {
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
//alert(url);
|
||||
} else {
|
||||
alert("<%:Not a supported scheme:%> " + v_type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function fromUrl(btn, urlname, sid) {
|
||||
@ -921,6 +941,10 @@ local api = require "luci.passwall.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%>
|
||||
|
@ -475,6 +475,9 @@ msgstr "导入分享URL"
|
||||
msgid "Build Share URL"
|
||||
msgstr "导出分享URL"
|
||||
|
||||
msgid "Generate QRCode"
|
||||
msgstr "生成二维码"
|
||||
|
||||
msgid "Import Finished"
|
||||
msgstr "导入完成:"
|
||||
|
||||
|
@ -1021,9 +1021,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 $id 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}
|
||||
|
||||
#自动切换逻辑
|
||||
@ -1049,10 +1051,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 $flag 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}
|
||||
}
|
||||
}
|
||||
|
@ -898,13 +898,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
Block a user