luci-app-passwall: sync with upstream source

This commit is contained in:
CN_SZTL 2020-12-19 17:39:51 +08:00
parent b8ca02f347
commit 91b3428a14
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
3 changed files with 46 additions and 70 deletions

View File

@ -4,6 +4,7 @@ local appname = "passwall"
local ucic = luci.model.uci.cursor()
local http = require "luci.http"
local util = require "luci.util"
local i18n = require "luci.i18n"
local api = require "luci.model.cbi.passwall.api.api"
local kcptun = require "luci.model.cbi.passwall.api.kcptun"
local brook = require "luci.model.cbi.passwall.api.brook"
@ -155,17 +156,17 @@ function get_now_use_node()
end
function get_redir_log()
local e = {}
local proto = luci.http.formvalue("proto")
proto = proto:upper()
local index = luci.http.formvalue("index")
local filename = proto .. "_" .. index
if nixio.fs.access("/var/etc/passwall/" .. filename .. ".log") then
e.code = 200
local content = luci.sys.exec("cat /var/etc/passwall/" .. filename .. ".log")
content = content:gsub("\n", "<br />")
luci.http.write(content)
else
e.code = 400
luci.http.write(string.format("<script>alert('%s');window.close();</script>", i18n.translate("Not enabled log")))
end
e.data = luci.sys.exec("cat /var/etc/passwall/" .. filename .. ".log")
http_write_json(e)
end
function get_log()
@ -224,7 +225,11 @@ function connect_status()
local code = tonumber(luci.sys.exec("echo -n '" .. result .. "' | awk -F ':' '{print $1}'") or "0")
if code ~= 0 then
local use_time = luci.sys.exec("echo -n '" .. result .. "' | awk -F ':' '{print $2}'")
e.use_time = string.format("%.2f", use_time * 1000)
if use_time:find("%.") then
e.use_time = string.format("%.2f", use_time * 1000)
else
e.use_time = string.format("%.2f", use_time / 1000)
end
e.ping_type = "curl"
end
luci.http.prepare_content("application/json")
@ -311,18 +316,14 @@ function check_port()
local node_name = ""
local retstring = "<br />"
-- retstring = retstring .. "<font color='red'>暂时不支持UDP检测</font><br />"
retstring = retstring .. "<font color='green'>检测端口可用性</font><br />"
retstring = retstring .. "<font color='green'>检测端口连通性不支持UDP检测</font><br />"
ucic:foreach(appname, "nodes", function(s)
local ret = ""
local tcp_socket
if (s.use_kcp and s.use_kcp == "1" and s.kcp_port) or (s.transport and s.transport == "mkcp" and s.port) then
else
local type = s.type
local protocol = s.protocol
if type and (protocol and protocol ~= "_balancing" and protocol ~= "_shunt") and
s.address and s.port and s.remarks then
if 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}
tcp_socket = nixio.socket("inet", "stream")
tcp_socket:setopt("socket", "rcvtimeo", 3)

View File

@ -6,29 +6,6 @@ local auto_switch = api.uci_get_type("auto_switch", "enable", 0)
-%>
<script type="text/javascript">
//<![CDATA[
function get_redir_log(proto, index) {
if (proto && index) {
proto = proto.toUpperCase();
XHR.get('<%=url([[admin]], [[services]], [[passwall]], [[get_redir_log]])%>', {
proto: proto,
index: index
},
function(x, result) {
if (x && x.status == 200) {
if (result.code == 200) {
var content = result.data;
content = content.replace(/\n/g, "<br />");
var new_window = window.open();
new_window.document.write(content);
} else {
alert('<%:Not enabled log%>');
}
}
}
);
}
}
var _status = document.getElementsByClassName('_status');
for (var i = 0; i < _status.length; i++) {
var id = _status[i].getAttribute("socks_id");
@ -84,19 +61,17 @@ local auto_switch = api.uci_get_type("auto_switch", "enable", 0)
var v = document.getElementById(dom_id + "-" + node_select_value);
node_select.title = v.text;
var edit_btn = document.createElement("input");
edit_btn.setAttribute("class", "cbi-button cbi-button-edit");
edit_btn.setAttribute("type", "button");
edit_btn.setAttribute("value", "<%:Edit%>");
edit_btn.setAttribute("onclick", "location.href='" + '<%=url([[admin]], [[services]], [[passwall]], [[node_config]])%>' + "/" + node_select_value + "'");
var new_a = document.createElement("a");
new_a.innerHTML = "<%:Edit%>";
new_a.href = "#";
new_a.setAttribute("onclick", "location.href='" + '<%=url([[admin]], [[services]], [[passwall]], [[node_config]])%>' + "/" + node_select_value + "'");
var log_btn = document.createElement("input");
log_btn.setAttribute("class", "cbi-button cbi-button-add");
log_btn.setAttribute("type", "button");
log_btn.setAttribute("value", "<%:Log%>");
log_btn.setAttribute("onclick", 'get_redir_log("' + proto + '","' + index + '")');
var log_a = document.createElement("a");
log_a.innerHTML = "<%:Log%>";
log_a.href = "#";
log_a.setAttribute("onclick", "window.open('" + '<%=url([[admin]], [[services]], [[passwall]], [[get_redir_log]])%>' + "?proto=" + proto + "&index=" + index + "', '_blank')");
node_select.outerHTML = node_select.outerHTML + "&nbsp&nbsp" + edit_btn.outerHTML + log_btn.outerHTML;
node_select.outerHTML = node_select.outerHTML + "&nbsp&nbsp" + new_a.outerHTML + "&nbsp&nbsp" + log_a.outerHTML;
//node_select.parentNode.insertBefore(new_a, node_select.nextSibling);
}
}
@ -129,16 +104,13 @@ local auto_switch = api.uci_get_type("auto_switch", "enable", 0)
var v = document.getElementById(dom_id + "-" + node_select_value);
node_select.title = v.text;
var new_input = document.createElement("input");
new_input.setAttribute("class", "cbi-button cbi-button-edit");
new_input.setAttribute("type", "button");
new_input.setAttribute("value", "<%:Edit%>");
new_input.setAttribute("alt", "<%:Edit%>");
new_input.setAttribute("title", "<%:Edit%>");
new_input.setAttribute("onclick","location.href='" + '<%=url([[admin]], [[services]], [[passwall]], [[node_config]])%>' + "/" + node_select_value + "'");
var new_a = document.createElement("a");
new_a.innerHTML = "<%:Edit%>";
new_a.href = "#";
new_a.setAttribute("onclick","location.href='" + '<%=url([[admin]], [[services]], [[passwall]], [[node_config]])%>' + "/" + node_select_value + "'");
node_select.outerHTML = node_select.outerHTML + "&nbsp&nbsp" + new_input.outerHTML;
//node_select.parentNode.insertBefore(new_input, node_select.nextSibling);
node_select.outerHTML = node_select.outerHTML + "&nbsp&nbsp" + new_a.outerHTML;
//node_select.parentNode.insertBefore(new_a, node_select.nextSibling);
}
}
}

View File

@ -16,7 +16,7 @@ Licensed under the BSD License.
https://github.com/pure-css/pure/blob/master/LICENSE.md
*/
.pure-g{letter-spacing:-.31em;text-rendering:optimizespeed;font-family:FreeSans,Arimo,"Droid Sans",Helvetica,Arial,sans-serif;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-flex-flow:row wrap;-ms-flex-flow:row wrap;flex-flow:row wrap;-webkit-align-content:flex-start;-ms-flex-line-pack:start;align-content:flex-start}@media all and (-ms-high-contrast:none),(-ms-high-contrast:active){table .pure-g{display:block}}.opera-only :-o-prefocus,.pure-g{word-spacing:-.43em}.pure-u{display:inline-block;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-g [class*=pure-u]{font-family:sans-serif}.pure-u-1,.pure-u-1-1,.pure-u-1-12,.pure-u-1-2,.pure-u-1-24,.pure-u-1-3,.pure-u-1-4,.pure-u-1-5,.pure-u-1-6,.pure-u-1-8,.pure-u-10-24,.pure-u-11-12,.pure-u-11-24,.pure-u-12-24,.pure-u-13-24,.pure-u-14-24,.pure-u-15-24,.pure-u-16-24,.pure-u-17-24,.pure-u-18-24,.pure-u-19-24,.pure-u-2-24,.pure-u-2-3,.pure-u-2-5,.pure-u-20-24,.pure-u-21-24,.pure-u-22-24,.pure-u-23-24,.pure-u-24-24,.pure-u-3-24,.pure-u-3-4,.pure-u-3-5,.pure-u-3-8,.pure-u-4-24,.pure-u-4-5,.pure-u-5-12,.pure-u-5-24,.pure-u-5-5,.pure-u-5-6,.pure-u-5-8,.pure-u-6-24,.pure-u-7-12,.pure-u-7-24,.pure-u-7-8,.pure-u-8-24,.pure-u-9-24{display:inline-block;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-1-24{width:4.1667%}.pure-u-1-12,.pure-u-2-24{width:8.3333%}.pure-u-1-8,.pure-u-3-24{width:12.5%}.pure-u-1-6,.pure-u-4-24{width:16.6667%}.pure-u-1-5{width:20%}.pure-u-5-24{width:20.8333%}.pure-u-1-4,.pure-u-6-24{width:25%}.pure-u-7-24{width:29.1667%}.pure-u-1-3,.pure-u-8-24{width:33.3333%}.pure-u-3-8,.pure-u-9-24{width:37.5%}.pure-u-2-5{width:40%}.pure-u-10-24,.pure-u-5-12{width:41.6667%}.pure-u-11-24{width:45.8333%}.pure-u-1-2,.pure-u-12-24{width:50%}.pure-u-13-24{width:54.1667%}.pure-u-14-24,.pure-u-7-12{width:58.3333%}.pure-u-3-5{width:60%}.pure-u-15-24,.pure-u-5-8{width:62.5%}.pure-u-16-24,.pure-u-2-3{width:66.6667%}.pure-u-17-24{width:70.8333%}.pure-u-18-24,.pure-u-3-4{width:75%}.pure-u-19-24{width:79.1667%}.pure-u-4-5{width:80%}.pure-u-20-24,.pure-u-5-6{width:83.3333%}.pure-u-21-24,.pure-u-7-8{width:87.5%}.pure-u-11-12,.pure-u-22-24{width:91.6667%}.pure-u-23-24{width:95.8333%}.pure-u-1,.pure-u-1-1,.pure-u-24-24,.pure-u-5-5{width:100%}
.block{
.block {
margin: 0.5rem;
padding: 0;
font-weight: normal;
@ -31,36 +31,36 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
background-color: #fff;
box-shadow: 0 0 2rem 0 rgba(136,152,170,.15);
}
.img-con{
.img-con {
margin: 1rem;
}
.green{
.green {
font-size:.9rem;
color: #2dce89;
}
.red{
.red {
font-size:.9rem;
color: #fb6340;
}
.yellow{
.yellow {
font-size:.9rem;
color: #fb9a05;
}
.block img{
.block img {
width: 48px;
height: auto;
float:right;
/* float:right; */
}
.pure-u-5-8{
.pure-u-5-8 {
display:flex;
align-items:center;
}
.block h4{
.block h4 {
font-size: .8125rem;
font-weight: 600;
margin: 1rem;
margin: 1rem 0rem 1rem 1rem;
color:#8898aa!important;
line-height: 1.8em;
min-height: 48px;
@ -71,22 +71,25 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
}
@media screen and (max-width: 720px) {
.block{
.block {
margin: 0.2rem;
}
.pure-u-1-4{
.pure-u-1-4 {
width: 50%;
}
.pure-u-1-2{
.pure-u-1-2 {
width: 100%;
}
.block h4 {
margin: 1rem 0rem 1rem 0.5rem;
}
}
@media screen and (max-width: 480px) {
.img-con{
.img-con {
margin: 1.5rem 0.5rem;
}
.block img{
.block img {
width: 36px;
}
}