luci-app-passwall: fix bugs
This commit is contained in:
parent
ab57354a94
commit
6fb73d7b6e
@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall
|
||||
PKG_VERSION:=3.0
|
||||
PKG_RELEASE:=113-20191129
|
||||
PKG_RELEASE:=115-20191201
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PO2LMO:=./po2lmo
|
||||
|
||||
@ -59,12 +59,12 @@ o.rmempty = true
|
||||
sys.net.mac_hints(function(e, t) o:value(e, "%s " % {e}) end)
|
||||
|
||||
---- TCP Node
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
|
||||
o = s:option(ListValue, "tcp_node", translate("TCP Node"))
|
||||
for i = 1, tcp_node_num, 1 do o:value(i, "TCP_" .. i) end
|
||||
|
||||
---- UDP Node
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
|
||||
o = s:option(ListValue, "udp_node", translate("UDP Node"))
|
||||
for i = 1, udp_node_num, 1 do o:value(i, "UDP_" .. i) end
|
||||
|
||||
|
||||
@ -17,17 +17,25 @@ local command_timeout = 300
|
||||
local LEDE_BOARD = nil
|
||||
local DISTRIB_TARGET = nil
|
||||
|
||||
function uci_get_type(type, config)
|
||||
return uci:get(appname, "@" .. type .. "[0]", config) or
|
||||
sys.exec(
|
||||
"echo -n `uci -q get " .. appname .. ".@" .. type .. "[0]." ..
|
||||
config .. "`")
|
||||
function uci_get_type(type, config, default)
|
||||
value = uci:get(appname, "@" .. type .. "[0]", config) or sys.exec(
|
||||
"echo -n `uci -q get " .. appname .. ".@" .. type .. "[0]." ..
|
||||
config .. "`")
|
||||
if (value == nil or value == "") and (default and default ~= "") then
|
||||
value = default
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
function uci_get_type_id(id, config)
|
||||
return uci:get(appname, id, config) or
|
||||
sys.exec("echo -n `uci -q get " .. appname .. "." .. id .. "." ..
|
||||
config .. "`")
|
||||
function uci_get_type_id(id, config, default)
|
||||
value = uci:get(appname, id, config) or
|
||||
sys.exec(
|
||||
"echo -n `uci -q get " .. appname .. "." .. id .. "." ..
|
||||
config .. "`")
|
||||
if (value == nil or value == "") and (default and default ~= "") then
|
||||
value = default
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
function _unpack(t, i)
|
||||
|
||||
@ -32,7 +32,7 @@ table.sort(key_table)
|
||||
|
||||
m = Map(appname)
|
||||
local status_use_big_icon = api.uci_get_type("global_other",
|
||||
"status_use_big_icon")
|
||||
"status_use_big_icon", 1)
|
||||
if status_use_big_icon and status_use_big_icon == "1" then
|
||||
m:append(Template("passwall/global/status"))
|
||||
else
|
||||
@ -45,7 +45,7 @@ s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
---- TCP Node
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
|
||||
for i = 1, tcp_node_num, 1 do
|
||||
if i == 1 then
|
||||
o = s:option(ListValue, "tcp_node" .. i, translate("TCP Node"),
|
||||
@ -59,7 +59,7 @@ for i = 1, tcp_node_num, 1 do
|
||||
end
|
||||
|
||||
---- UDP Node
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
|
||||
for i = 1, udp_node_num, 1 do
|
||||
if i == 1 then
|
||||
o = s:option(ListValue, "udp_node" .. i, translate("UDP Node"),
|
||||
@ -76,7 +76,7 @@ for i = 1, udp_node_num, 1 do
|
||||
end
|
||||
|
||||
---- Socks5 Node
|
||||
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num")
|
||||
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1)
|
||||
for i = 1, socks5_node_num, 1 do
|
||||
if i == 1 then
|
||||
o = s:option(ListValue, "socks5_node" .. i, translate("Socks5 Node"),
|
||||
|
||||
@ -80,7 +80,7 @@ end--]]
|
||||
|
||||
---- Ping
|
||||
o = s:option(DummyValue, "address", translate("Ping"))
|
||||
if api.uci_get_type("global_other", "auto_ping") == "0" then
|
||||
if api.uci_get_type("global_other", "auto_ping", "0") == "0" then
|
||||
o.template = "passwall/node_list/ping"
|
||||
else
|
||||
o.template = "passwall/node_list/auto_ping"
|
||||
|
||||
@ -11,9 +11,9 @@ local function is_finded(e)
|
||||
return false
|
||||
end
|
||||
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
|
||||
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num")
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
|
||||
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1)
|
||||
-%>
|
||||
|
||||
<style>
|
||||
|
||||
@ -11,9 +11,9 @@ local function is_finded(e)
|
||||
return false
|
||||
end
|
||||
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
|
||||
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num")
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
|
||||
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1)
|
||||
-%>
|
||||
|
||||
<style>
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local dsp = require "luci.dispatcher"
|
||||
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
|
||||
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num")
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
|
||||
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1)
|
||||
-%>
|
||||
|
||||
<style>
|
||||
|
||||
@ -5,8 +5,8 @@ local dsp = require "luci.dispatcher"
|
||||
local gfwlist_version = api.uci_get_type("global_rules", "gfwlist_version")
|
||||
local chnroute_version = api.uci_get_type("global_rules", "chnroute_version")
|
||||
|
||||
local gfwlist_update = api.uci_get_type("global_rules", "gfwlist_update") == "1" and "checked='checked'" or ""
|
||||
local chnroute_update = api.uci_get_type("global_rules", "chnroute_update") == "1" and "checked='checked'" or ""
|
||||
local gfwlist_update = api.uci_get_type("global_rules", "gfwlist_update", "1") == "1" and "checked='checked'" or ""
|
||||
local chnroute_update = api.uci_get_type("global_rules", "chnroute_update", "1") == "1" and "checked='checked'" or ""
|
||||
-%>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@ -52,6 +52,7 @@ get_local_nodes(){
|
||||
}
|
||||
|
||||
get_remote_config(){
|
||||
isAdd=1
|
||||
add_mode="订阅"
|
||||
[ -n "$3" ] && add_mode="导入"
|
||||
group="sub_node"
|
||||
@ -64,6 +65,8 @@ get_remote_config(){
|
||||
elif [ "$1" == "ssr" ]; then
|
||||
decode_link="$2"
|
||||
node_address=$(echo "$decode_link" | awk -F ':' '{print $1}')
|
||||
node_address=$(echo $node_address |awk '{print gensub(/[^!-~]/,"","g",$0)}')
|
||||
[ -z "$node_address" -o "$node_address" == "" ] && isAdd=0
|
||||
node_port=$(echo "$decode_link" | awk -F ':' '{print $2}')
|
||||
protocol=$(echo "$decode_link" | awk -F ':' '{print $3}')
|
||||
ssr_encrypt_method=$(echo "$decode_link" | awk -F ':' '{print $4}')
|
||||
@ -75,7 +78,7 @@ get_remote_config(){
|
||||
protoparam_temp=$(echo "$decode_link" |grep -Eo "protoparam.+" |sed 's/protoparam=//g'|awk -F'&' '{print $1}')
|
||||
[ -n "$protoparam_temp" ] && protoparam=$(decode_url_link $protoparam_temp 0) || protoparam=''
|
||||
remarks_temp=$(echo "$decode_link" |grep -Eo "remarks.+" |sed 's/remarks=//g'|awk -F'&' '{print $1}')
|
||||
[ -n "$remarks_temp" ] && remarks="${remarks}$(decode_url_link $remarks_temp 0)"
|
||||
[ -n "$remarks_temp" ] && remarks="$(decode_url_link $remarks_temp 0)"
|
||||
group_temp=$(echo "$decode_link" |grep -Eo "group.+" |sed 's/group=//g'|awk -F'&' '{print $1}')
|
||||
elif [ "$1" == "v2ray" ]; then
|
||||
json_load "$2"
|
||||
@ -188,17 +191,19 @@ add_nodes(){
|
||||
}
|
||||
|
||||
update_config(){
|
||||
isadded_address=$(uci show $CONFIG | grep -c "remarks='$remarks'")
|
||||
if [ "$isadded_address" -eq 0 ]; then
|
||||
add_nodes add "$link_type"
|
||||
else
|
||||
index=$(uci show $CONFIG | grep -w "remarks='$remarks'" | cut -d '[' -f2|cut -d ']' -f1)
|
||||
local_port=$(config_t_get nodes port $index)
|
||||
local_vmess_id=$(config_t_get nodes v2ray_VMess_id $index)
|
||||
|
||||
uci delete $CONFIG.@nodes[$index]
|
||||
add_nodes update "$link_type"
|
||||
fi
|
||||
[ "$isAdd" == 1 ] && {
|
||||
isadded_address=$(uci show $CONFIG | grep -c "remarks='$remarks'")
|
||||
if [ "$isadded_address" -eq 0 ]; then
|
||||
add_nodes add "$link_type"
|
||||
else
|
||||
index=$(uci show $CONFIG | grep -w "remarks='$remarks'" | cut -d '[' -f2|cut -d ']' -f1)
|
||||
local_port=$(config_t_get nodes port $index)
|
||||
local_vmess_id=$(config_t_get nodes v2ray_VMess_id $index)
|
||||
|
||||
uci delete $CONFIG.@nodes[$index]
|
||||
add_nodes update "$link_type"
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
del_config(){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user