Skip to content

Commit 57c6e64

Browse files
committed
passwall : fix bug
Fixed a bug where the subscription alias was too long. Fixed an error after inherited configuration.
1 parent 1710369 commit 57c6e64

File tree

10 files changed

+53
-40
lines changed

10 files changed

+53
-40
lines changed

lienol/luci-app-passwall/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
77

88
PKG_NAME:=luci-app-passwall
99
PKG_VERSION:=3.0
10-
PKG_RELEASE:=113-20191129
10+
PKG_RELEASE:=115-20191201
1111

1212
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
1313
PO2LMO:=./po2lmo

lienol/luci-app-passwall/luasrc/model/cbi/passwall/acl.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ o.rmempty = true
5959
sys.net.mac_hints(function(e, t) o:value(e, "%s " % {e}) end)
6060

6161
---- TCP Node
62-
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
62+
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
6363
o = s:option(ListValue, "tcp_node", translate("TCP Node"))
6464
for i = 1, tcp_node_num, 1 do o:value(i, "TCP_" .. i) end
6565

6666
---- UDP Node
67-
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
67+
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
6868
o = s:option(ListValue, "udp_node", translate("UDP Node"))
6969
for i = 1, udp_node_num, 1 do o:value(i, "UDP_" .. i) end
7070

lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/api.lua

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,25 @@ local command_timeout = 300
1717
local LEDE_BOARD = nil
1818
local DISTRIB_TARGET = nil
1919

20-
function uci_get_type(type, config)
21-
return uci:get(appname, "@" .. type .. "[0]", config) or
22-
sys.exec(
23-
"echo -n `uci -q get " .. appname .. ".@" .. type .. "[0]." ..
24-
config .. "`")
20+
function uci_get_type(type, config, default)
21+
value = uci:get(appname, "@" .. type .. "[0]", config) or sys.exec(
22+
"echo -n `uci -q get " .. appname .. ".@" .. type .. "[0]." ..
23+
config .. "`")
24+
if (value == nil or value == "") and (default and default ~= "") then
25+
value = default
26+
end
27+
return value
2528
end
2629

27-
function uci_get_type_id(id, config)
28-
return uci:get(appname, id, config) or
29-
sys.exec("echo -n `uci -q get " .. appname .. "." .. id .. "." ..
30-
config .. "`")
30+
function uci_get_type_id(id, config, default)
31+
value = uci:get(appname, id, config) or
32+
sys.exec(
33+
"echo -n `uci -q get " .. appname .. "." .. id .. "." ..
34+
config .. "`")
35+
if (value == nil or value == "") and (default and default ~= "") then
36+
value = default
37+
end
38+
return value
3139
end
3240

3341
function _unpack(t, i)

lienol/luci-app-passwall/luasrc/model/cbi/passwall/global.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ table.sort(key_table)
3232

3333
m = Map(appname)
3434
local status_use_big_icon = api.uci_get_type("global_other",
35-
"status_use_big_icon")
35+
"status_use_big_icon", 1)
3636
if status_use_big_icon and status_use_big_icon == "1" then
3737
m:append(Template("passwall/global/status"))
3838
else
@@ -45,7 +45,7 @@ s.anonymous = true
4545
s.addremove = false
4646

4747
---- TCP Node
48-
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
48+
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
4949
for i = 1, tcp_node_num, 1 do
5050
if i == 1 then
5151
o = s:option(ListValue, "tcp_node" .. i, translate("TCP Node"),
@@ -59,7 +59,7 @@ for i = 1, tcp_node_num, 1 do
5959
end
6060

6161
---- UDP Node
62-
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
62+
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
6363
for i = 1, udp_node_num, 1 do
6464
if i == 1 then
6565
o = s:option(ListValue, "udp_node" .. i, translate("UDP Node"),
@@ -76,7 +76,7 @@ for i = 1, udp_node_num, 1 do
7676
end
7777

7878
---- Socks5 Node
79-
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num")
79+
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1)
8080
for i = 1, socks5_node_num, 1 do
8181
if i == 1 then
8282
o = s:option(ListValue, "socks5_node" .. i, translate("Socks5 Node"),

lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_list.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ end--]]
8080

8181
---- Ping
8282
o = s:option(DummyValue, "address", translate("Ping"))
83-
if api.uci_get_type("global_other", "auto_ping") == "0" then
83+
if api.uci_get_type("global_other", "auto_ping", "0") == "0" then
8484
o.template = "passwall/node_list/ping"
8585
else
8686
o.template = "passwall/node_list/auto_ping"

lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
return false
1212
end
1313

14-
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
15-
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
16-
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num")
14+
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
15+
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
16+
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1)
1717
-%>
1818

1919
<style>

lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
return false
1212
end
1313

14-
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
15-
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
16-
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num")
14+
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
15+
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
16+
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1)
1717
-%>
1818

1919
<style>

lienol/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
local api = require "luci.model.cbi.passwall.api.api"
33
local dsp = require "luci.dispatcher"
44

5-
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
6-
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
7-
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num")
5+
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
6+
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
7+
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1)
88
-%>
99

1010
<style>

lienol/luci-app-passwall/luasrc/view/passwall/rule/rule_version.htm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
local gfwlist_version = api.uci_get_type("global_rules", "gfwlist_version")
66
local chnroute_version = api.uci_get_type("global_rules", "chnroute_version")
77

8-
local gfwlist_update = api.uci_get_type("global_rules", "gfwlist_update") == "1" and "checked='checked'" or ""
9-
local chnroute_update = api.uci_get_type("global_rules", "chnroute_update") == "1" and "checked='checked'" or ""
8+
local gfwlist_update = api.uci_get_type("global_rules", "gfwlist_update", "1") == "1" and "checked='checked'" or ""
9+
local chnroute_update = api.uci_get_type("global_rules", "chnroute_update", "1") == "1" and "checked='checked'" or ""
1010
-%>
1111

1212
<script type="text/javascript">

lienol/luci-app-passwall/root/usr/share/passwall/subscription.sh

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ get_local_nodes(){
5252
}
5353

5454
get_remote_config(){
55+
isAdd=1
5556
add_mode="订阅"
5657
[ -n "$3" ] && add_mode="导入"
5758
group="sub_node"
@@ -64,6 +65,8 @@ get_remote_config(){
6465
elif [ "$1" == "ssr" ]; then
6566
decode_link="$2"
6667
node_address=$(echo "$decode_link" | awk -F ':' '{print $1}')
68+
node_address=$(echo $node_address |awk '{print gensub(/[^!-~]/,"","g",$0)}')
69+
[ -z "$node_address" -o "$node_address" == "" ] && isAdd=0
6770
node_port=$(echo "$decode_link" | awk -F ':' '{print $2}')
6871
protocol=$(echo "$decode_link" | awk -F ':' '{print $3}')
6972
ssr_encrypt_method=$(echo "$decode_link" | awk -F ':' '{print $4}')
@@ -75,7 +78,7 @@ get_remote_config(){
7578
protoparam_temp=$(echo "$decode_link" |grep -Eo "protoparam.+" |sed 's/protoparam=//g'|awk -F'&' '{print $1}')
7679
[ -n "$protoparam_temp" ] && protoparam=$(decode_url_link $protoparam_temp 0) || protoparam=''
7780
remarks_temp=$(echo "$decode_link" |grep -Eo "remarks.+" |sed 's/remarks=//g'|awk -F'&' '{print $1}')
78-
[ -n "$remarks_temp" ] && remarks="${remarks}$(decode_url_link $remarks_temp 0)"
81+
[ -n "$remarks_temp" ] && remarks="$(decode_url_link $remarks_temp 0)"
7982
group_temp=$(echo "$decode_link" |grep -Eo "group.+" |sed 's/group=//g'|awk -F'&' '{print $1}')
8083
elif [ "$1" == "v2ray" ]; then
8184
json_load "$2"
@@ -188,17 +191,19 @@ add_nodes(){
188191
}
189192

190193
update_config(){
191-
isadded_address=$(uci show $CONFIG | grep -c "remarks='$remarks'")
192-
if [ "$isadded_address" -eq 0 ]; then
193-
add_nodes add "$link_type"
194-
else
195-
index=$(uci show $CONFIG | grep -w "remarks='$remarks'" | cut -d '[' -f2|cut -d ']' -f1)
196-
local_port=$(config_t_get nodes port $index)
197-
local_vmess_id=$(config_t_get nodes v2ray_VMess_id $index)
198-
199-
uci delete $CONFIG.@nodes[$index]
200-
add_nodes update "$link_type"
201-
fi
194+
[ "$isAdd" == 1 ] && {
195+
isadded_address=$(uci show $CONFIG | grep -c "remarks='$remarks'")
196+
if [ "$isadded_address" -eq 0 ]; then
197+
add_nodes add "$link_type"
198+
else
199+
index=$(uci show $CONFIG | grep -w "remarks='$remarks'" | cut -d '[' -f2|cut -d ']' -f1)
200+
local_port=$(config_t_get nodes port $index)
201+
local_vmess_id=$(config_t_get nodes v2ray_VMess_id $index)
202+
203+
uci delete $CONFIG.@nodes[$index]
204+
add_nodes update "$link_type"
205+
fi
206+
}
202207
}
203208

204209
del_config(){

0 commit comments

Comments
 (0)