From ec397d44a154f93e603d4ec7093fd3640ffff4c1 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Tue, 11 May 2021 08:13:19 -0600 Subject: [PATCH] ncp-web: fix port checking Signed-off-by: nachoparker --- bin/ncp-diag | 14 +++++++++----- changelog.md | 6 ++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/ncp-diag b/bin/ncp-diag index ef0d879c3..b7d65e263 100644 --- a/bin/ncp-diag +++ b/bin/ncp-diag @@ -64,15 +64,19 @@ echo "internet check|$( ping -W 2 -w 1 -q github.com &>/dev/null && echo ok || e function is_port_open() { - local PORT=$1 + local port=$1 + local public_ip + public_ip="$(curl icanhazip.com 2>/dev/null)" || { echo "closed"; return 1; } + local tmp_file=$(mktemp) - local v=$(wget -T2 -t1 -q --keep-session-cookies --save-cookies $tmp_file https://portchecker.co -O - | grep -oP "_csrf\" value=\"\K.*\"") - if [[ "$v" != "" ]]; then - wget -T2 -t1 -q --load-cookies $tmp_file https://portchecker.co --post-data "port=$PORT&_csrf=${v::-1}" -O - \ + local token=$(wget -T2 -t1 -qO- --keep-session-cookies --save-cookies $tmp_file https://portchecker.co | grep -oP "_csrf\" value=\"\K.*\"") + rm $tmp_file + + if [[ "${token}" != "" ]]; then + wget -T2 -t1 -qO- --load-cookies $tmp_file https://portchecker.co --post-data "target_ip=${public_ip}&port=${port}&_csrf=${token::-1}" \ | grep -q 'open' && { echo "open"; return 1; } fi echo "closed" - rm $tmp_file } echo "port check 80|$( is_port_open 80 )" diff --git a/changelog.md b/changelog.md index 7763b2d23..ea0d65b33 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,9 @@ -[v1.36.1](https://github.com/nextcloud/nextcloudpi/commit/8e7579d) (2021-05-09) lamp: allow only TLSv12 and TLSv13 +[v1.36.2](https://github.com/nextcloud/nextcloudpi/commit/fccc04c) (2021-05-11) ncp-web: fix port checking -[v1.36.0](https://github.com/nextcloud/nextcloudpi/commit/24b6018) (2020-09-16) Namecheap dynamic DNS client +[v1.36.1](https://github.com/nextcloud/nextcloudpi/commit/c7f2939) (2021-05-09) lamp: allow only TLSv12 and TLSv13 + +[v1.36.0 ](https://github.com/nextcloud/nextcloudpi/commit/24b6018) (2020-09-16) Namecheap dynamic DNS client [v1.35.2 ](https://github.com/nextcloud/nextcloudpi/commit/bfab195) (2021-04-29) ncp-web: fix display of big files for 32 bit