Skip to content

Commit ec397d4

Browse files
committed
ncp-web: fix port checking
Signed-off-by: nachoparker <[email protected]>
1 parent a950c8a commit ec397d4

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

bin/ncp-diag

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,19 @@ echo "internet check|$( ping -W 2 -w 1 -q github.com &>/dev/null && echo ok || e
6464

6565
function is_port_open()
6666
{
67-
local PORT=$1
67+
local port=$1
68+
local public_ip
69+
public_ip="$(curl icanhazip.com 2>/dev/null)" || { echo "closed"; return 1; }
70+
6871
local tmp_file=$(mktemp)
69-
local v=$(wget -T2 -t1 -q --keep-session-cookies --save-cookies $tmp_file https://portchecker.co -O - | grep -oP "_csrf\" value=\"\K.*\"")
70-
if [[ "$v" != "" ]]; then
71-
wget -T2 -t1 -q --load-cookies $tmp_file https://portchecker.co --post-data "port=$PORT&_csrf=${v::-1}" -O - \
72+
local token=$(wget -T2 -t1 -qO- --keep-session-cookies --save-cookies $tmp_file https://portchecker.co | grep -oP "_csrf\" value=\"\K.*\"")
73+
rm $tmp_file
74+
75+
if [[ "${token}" != "" ]]; then
76+
wget -T2 -t1 -qO- --load-cookies $tmp_file https://portchecker.co --post-data "target_ip=${public_ip}&port=${port}&_csrf=${token::-1}" \
7277
| grep -q '<span class="green">open</span>' && { echo "open"; return 1; }
7378
fi
7479
echo "closed"
75-
rm $tmp_file
7680
}
7781

7882
echo "port check 80|$( is_port_open 80 )"

changelog.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

2-
[v1.36.1](https://github.com/nextcloud/nextcloudpi/commit/8e7579d) (2021-05-09) lamp: allow only TLSv12 and TLSv13
2+
[v1.36.2](https://github.com/nextcloud/nextcloudpi/commit/fccc04c) (2021-05-11) ncp-web: fix port checking
33

4-
[v1.36.0](https://github.com/nextcloud/nextcloudpi/commit/24b6018) (2020-09-16) Namecheap dynamic DNS client
4+
[v1.36.1](https://github.com/nextcloud/nextcloudpi/commit/c7f2939) (2021-05-09) lamp: allow only TLSv12 and TLSv13
5+
6+
[v1.36.0 ](https://github.com/nextcloud/nextcloudpi/commit/24b6018) (2020-09-16) Namecheap dynamic DNS client
57

68
[v1.35.2 ](https://github.com/nextcloud/nextcloudpi/commit/bfab195) (2021-04-29) ncp-web: fix display of big files for 32 bit
79

0 commit comments

Comments
 (0)