luci-app-passwall: sync with upstream source
This commit is contained in:
parent
e59a145234
commit
6fdc785d67
@ -6,8 +6,8 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall
|
||||
PKG_VERSION:=3.5.8
|
||||
PKG_RELEASE:=20200215
|
||||
PKG_VERSION:=3.5.9
|
||||
PKG_RELEASE:=20200216
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ function link_add_node()
|
||||
local link = luci.http.formvalue("link")
|
||||
luci.sys.call('rm -f /tmp/links.conf && echo "' .. link ..
|
||||
'" >> /tmp/links.conf')
|
||||
luci.sys.call("lua /usr/share/passwall/subscribe.lua add >> /var/log/passwall.log")
|
||||
luci.sys.call("lua /usr/share/passwall/subscribe.lua add log")
|
||||
end
|
||||
|
||||
function get_log()
|
||||
|
||||
@ -93,7 +93,7 @@ local v2ray = {
|
||||
-- 传出连接
|
||||
outbounds = {
|
||||
{
|
||||
protocol = node.v2ray_protocol,
|
||||
protocol = node.v2ray_protocol or "vmess",
|
||||
mux = {
|
||||
enabled = (node.v2ray_mux == "1") and true or false,
|
||||
concurrency = (node.v2ray_mux_concurrency) and
|
||||
|
||||
@ -63,7 +63,7 @@ o = s:option(Button, "_update", translate("Manual subscription"))
|
||||
o.inputstyle = "apply"
|
||||
function o.write(e, e)
|
||||
luci.sys.call(
|
||||
"lua /usr/share/passwall/subscribe.lua start >> /var/log/passwall.log 2>&1 &")
|
||||
"lua /usr/share/passwall/subscribe.lua start log > /dev/null 2>&1 &")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "vpn", "passwall",
|
||||
"log"))
|
||||
end
|
||||
@ -73,7 +73,7 @@ o = s:option(Button, "_stop", translate("Delete All Subscribe Node"))
|
||||
o.inputstyle = "remove"
|
||||
function o.write(e, e)
|
||||
luci.sys.call(
|
||||
"lua /usr/share/passwall/subscribe.lua truncate >> /var/log/passwall.log 2>&1 &")
|
||||
"lua /usr/share/passwall/subscribe.lua truncate log > /dev/null 2>&1 &")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "vpn", "passwall",
|
||||
"log"))
|
||||
end
|
||||
|
||||
@ -9,8 +9,6 @@ require 'luci.util'
|
||||
require 'luci.jsonc'
|
||||
require 'luci.sys'
|
||||
|
||||
local params = arg[1]
|
||||
|
||||
-- these global functions are accessed all the time by the event handler
|
||||
-- so caching them is worth the effort
|
||||
local luci = luci
|
||||
@ -24,9 +22,21 @@ local name = 'passwall'
|
||||
local uciType = 'nodes'
|
||||
local ucic = luci.model.uci.cursor()
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local arg2 = arg[2]
|
||||
|
||||
local log = function(...)
|
||||
print(os.date("%Y-%m-%d %H:%M:%S: ") .. table.concat({ ... }, " "))
|
||||
if arg2 then
|
||||
local result = os.date("%Y-%m-%d %H:%M:%S: ") .. table.concat({ ... }, " ")
|
||||
if arg2 == "log" then
|
||||
local f,err = io.open("/var/log/passwall.log","a")
|
||||
if f and err == nil then
|
||||
f:write(result.."\n")
|
||||
f:close()
|
||||
end
|
||||
elseif arg2 == "print" then
|
||||
print(result)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 分割字符串
|
||||
@ -129,12 +139,13 @@ local function processData(szType, content, add_mode)
|
||||
result.type = 'V2ray'
|
||||
result.address = info.add
|
||||
result.port = info.port
|
||||
result.v2ray_protocol = 'vmess'
|
||||
result.v2ray_transport = info.net
|
||||
result.v2ray_VMess_alterId = info.aid
|
||||
result.v2ray_VMess_id = info.id
|
||||
result.remarks = info.ps
|
||||
result.v2ray_mux = 1
|
||||
result.v2ray_mux_concurrency = 8
|
||||
-- result.v2ray_mux = 1
|
||||
-- result.v2ray_mux_concurrency = 8
|
||||
if info.net == 'ws' then
|
||||
result.v2ray_ws_host = info.host
|
||||
result.v2ray_ws_path = info.path
|
||||
@ -168,6 +179,7 @@ local function processData(szType, content, add_mode)
|
||||
if info.tls == "tls" or info.tls == "1" then
|
||||
result.v2ray_stream_security = "tls"
|
||||
result.tls_serverName = info.host
|
||||
result.tls_allowInsecure = 1
|
||||
else
|
||||
result.v2ray_stream_security = "none"
|
||||
end
|
||||
@ -304,14 +316,8 @@ local function update_node(manual)
|
||||
setmetatable(nodeResult[old.grouphashkey][old.hashkey], { __index = { _ignore = true } })
|
||||
end
|
||||
elseif manual == 1 and (old.add_mode and old.add_mode == "导入") then
|
||||
if not nodeResult[old.grouphashkey] or not nodeResult[old.grouphashkey][old.hashkey] then
|
||||
if nodeResult[old.grouphashkey] and nodeResult[old.grouphashkey][old.hashkey] then
|
||||
ucic:delete(name, old['.name'])
|
||||
del = del + 1
|
||||
else
|
||||
local dat = nodeResult[old.grouphashkey][old.hashkey]
|
||||
ucic:tset(name, old['.name'], dat)
|
||||
-- 标记一下
|
||||
setmetatable(nodeResult[old.grouphashkey][old.hashkey], { __index = { _ignore = true } })
|
||||
end
|
||||
end
|
||||
else
|
||||
@ -328,6 +334,7 @@ local function update_node(manual)
|
||||
|
||||
end
|
||||
end
|
||||
log('新增节点数量: ' ..add, '删除节点数量: ' .. del)
|
||||
ucic:commit(name)
|
||||
-- 如果节点已经不见了把帮换一个
|
||||
local globalServer = ucic:get_first(name, 'global', 'tcp_node1', '')
|
||||
@ -340,10 +347,9 @@ local function update_node(manual)
|
||||
end
|
||||
luci.sys.call("/etc/init.d/" .. name .. " restart > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早
|
||||
end
|
||||
log('新增节点数量: ' ..add, '删除节点数量: ' .. del)
|
||||
end
|
||||
|
||||
local function parse_link(raw, md5_str, manual)
|
||||
local function parse_link(raw, remark, md5_str, manual)
|
||||
if raw and #raw > 0 then
|
||||
local add_mode
|
||||
local nodes, szType
|
||||
@ -376,6 +382,7 @@ local function parse_link(raw, md5_str, manual)
|
||||
add_mode = '导入'
|
||||
else
|
||||
nodes = split(base64Decode(raw):gsub(" ", "\n"), "\n")
|
||||
add_mode = remark
|
||||
end
|
||||
end
|
||||
|
||||
@ -429,7 +436,7 @@ local execute = function()
|
||||
local url = obj.url
|
||||
local md5_str = md5(url)
|
||||
local raw = wget(url)
|
||||
parse_link(raw, md5_str)
|
||||
parse_link(raw, remark, md5_str)
|
||||
end
|
||||
end)
|
||||
end
|
||||
@ -458,7 +465,7 @@ if arg[1] then
|
||||
local nodes = split(content:gsub(" ", "\n"), "\n")
|
||||
for _, raw in ipairs(nodes) do
|
||||
local md5_str = md5(raw)
|
||||
parse_link(raw, md5_str, 1)
|
||||
parse_link(raw, nil, md5_str, 1)
|
||||
end
|
||||
update_node(1)
|
||||
elseif arg[1] == "truncate" then
|
||||
|
||||
Loading…
Reference in New Issue
Block a user