Cleaned up errors and added logging

master
Keith Irwin 2022-11-06 17:27:27 -07:00
parent ae41a169b8
commit b289bd5d30
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
3 changed files with 10 additions and 7 deletions

View File

@ -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}"

View File

@ -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

View File

@ -7,7 +7,7 @@
<h2>Your peers</h2>
<p data-bind="hidden:isLoaded"><code>Loading...</code></p>
<table data-bind="visible:isLoaded">
<table data-bind="visible:isLoaded" style="display:hidden">
<thead><tr>
<th>Host</th><th>SSL</th><th></th>
</tr></thead>
@ -21,7 +21,7 @@
<h2>Add a peer</h2>
<p>To add a new peer, type in a hostname and click add. The hostname must be 3-10 lowercase letters and numbers <code>/[a-z0-9]{3,10}/</code>. Keep it short for your own sake!</p>
<p data-bind="hidden:isLoaded"><code>Loading...</code></p>
<div data-bind="visible:isLoaded">
<div data-bind="visible:isLoaded" style="display:hidden">
<input type="text" data-bind="textInput:newPeerName,event:{keypress:addKeyPress}" placeholder="mypc1"></input>
<button data-bind="click:addPeer,disable:isAdding,text:addText">Add</button>
</div>