From b289bd5d30ef2848691b2111f9b599af1a672e0e Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Sun, 6 Nov 2022 17:27:27 -0700 Subject: [PATCH] Cleaned up errors and added logging --- back/dashboard_ssl.cgi | 2 +- back/lib/dashboard/ssl | 11 +++++++---- front/dashboard.html | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/back/dashboard_ssl.cgi b/back/dashboard_ssl.cgi index 069b909..4e09b72 100644 --- a/back/dashboard_ssl.cgi +++ b/back/dashboard_ssl.cgi @@ -4,7 +4,7 @@ # ERRORS: # 3: Bad usage # 4: Missing config file - +printf 'Request for dashboard_ssl.cgi received\n' >>"${LOGFILE}" CONFIG_FILE='/etc/wgapi/config' if ! [ -f "${CONFIG_FILE}" ]; then printf 'ERROR! %s could not find %s!\n' "${0}" "${CONFIG_FILE}" >>"${LOGFILE}" diff --git a/back/lib/dashboard/ssl b/back/lib/dashboard/ssl index 4b97a36..b3c87a4 100644 --- a/back/lib/dashboard/ssl +++ b/back/lib/dashboard/ssl @@ -8,8 +8,11 @@ # 4: Config file not found # 5: Missing part of the querystring # 6: Invalid extension -# 7: SSL file missing -# 8: Failed to return SSL file +# 7: Failed to perform nslookup of ip +# 8: Failed to parse username from domain +# 9: Missing username or SSL_CONFIG_DIR +# 10: SSL file missing +# 11: Failed to return SSL file CONFIG_FILE='/etc/wgapi/config' if ! [ ${#} -eq 2 ]; then @@ -53,8 +56,8 @@ if ! username="$(<<<"${domain}" cut -d'.' -f2)"; then fi if ! path="${SSL_CONFIG_DIR:?}/${username:?}/${file}"; then - printf 'ERROR! Username "${username}" or SSL_CONFIG_DIR "%s" missing!\n' >> "${LOGFILE}" - printf 'Hostname or username or extension missing!\n' | "${LIB_DIR}/http_res" 400 + printf 'ERROR! Username "${username}" or SSL_CONFIG_DIR "%s" missing!\n' "${username}" "${SSL_CONFIG_DIR}" >> "${LOGFILE}" + "${LIB_DIR}/http_res" 500 exit 9 fi diff --git a/front/dashboard.html b/front/dashboard.html index 56f088e..1c48a98 100644 --- a/front/dashboard.html +++ b/front/dashboard.html @@ -7,7 +7,7 @@

Your peers

Loading...

- +
@@ -21,7 +21,7 @@

Add a peer

To add a new peer, type in a hostname and click add. The hostname must be 3-10 lowercase letters and numbers /[a-z0-9]{3,10}/. Keep it short for your own sake!

Loading...

-
+
HostSSL