Browse Source

Add FORCE_DISABLE_SSL

Joachim M. Giæver 2 years ago
parent
commit
5dd9a66942
2 changed files with 18 additions and 9 deletions
  1. 13 6
      src/helper/env-wrapper
  2. 5 3
      src/helper/functions

+ 13 - 6
src/helper/env-wrapper

@@ -102,18 +102,24 @@ fi
 # Not needed anymore as of ZWAVEJS_EXTERNAL_CONFIG?
 # ensure_zwavejs_config
 
-export SERVER_SSL=$(snapctl get server.ssl)
 export SERVER_HOST=$(snapctl get server.host)
 export SERVER_PORT=$(snapctl get server.port)
 
-export GIT_DIR="${SNAP}/lib/node_modules/zwavejs2mqtt/.git"
+export HOST="${SERVER_HOST}"
+export PORT="${SERVER_PORT}"
 
+export SERVER_SSL=$(snapctl get server.ssl)
 export HTTPS="${SERVER_SSL}"
 
-export SESSION_SECRET=$(snapctl get session.secret)
+export FORCE_DISABLE_SSL=$(snapctl get server.force-disable-ssl)
+
+if [ "${FORCE_DISABLE_SSL}" != true ]; then
+    unset FORCE_DISABLE_SSL
+fi
+
 export USE_SECURE_COOKIE=$(snapctl get session.cookie-secure)
 
-if [ "${HTTPS}" != true ]; then
+if [ "${HTTPS}" != true ] || [ "${FORCE_DISABLE_SSL}" == true ]; then
     unset HTTPS
     unset SERVER_SSL
     unset USE_SECURE_COOKIE
@@ -121,13 +127,14 @@ elif [ "${USE_SECURE_COOKIE}" != true ]; then
     unset USE_SECURE_COOKIE
 fi
 
+export SESSION_SECRET=$(snapctl get session.secret)
+
 export MQTT_NAME=$(snapctl get mqtt.name)
 
 if [ -z "${MQTT_NAME}" ]; then
     unset MQTT_NAME
 fi
 
-export HOST="${SERVER_HOST}"
-export PORT="${SERVER_PORT}"
+export GIT_DIR="${SNAP}/lib/node_modules/zwavejs2mqtt/.git"
 
 [ "$(basename "${1}")" == "yarn" ] && cd "${SNAP}/lib/node_modules/zwavejs2mqtt" && exec "${@}" || exec "${@}"

+ 5 - 3
src/helper/functions

@@ -137,12 +137,14 @@ function test_priority_dir {
 }
 
 function test_default_config {
+    testnset_config "server.host" "localhost"
+    testnset_config "server.port" 8091
+
     testnset_config "server.ssl" false
+    testnset_config "server.force-disable-ssl" false
+
     testnset_config "session.cookie-secure" $(snap get server.ssl)
     testnset_config "session.secret" $(uuid)
 
-    testnset_config "server.host" "localhost"
-    testnset_config "server.port" 8091
-
     testnset_config "mqtt.name" ""
 }