From 31afb91f8d12abb99ec176a69f6ca029618233cd Mon Sep 17 00:00:00 2001 From: Ralf Ramsauer Date: Wed, 5 Sep 2018 18:23:39 +0000 Subject: [PATCH] Add proper debugging mode For production, only listen on localhost, in Debug mode, allow anything from 0.0.0.0 Signed-off-by: Ralf Ramsauer --- doorlockd.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doorlockd.py b/doorlockd.py index 61781fa..26f5c79 100755 --- a/doorlockd.py +++ b/doorlockd.py @@ -80,6 +80,10 @@ wave_unlock_button = webapp.config.get('WAVE_UNLOCK_BUTTON') wave_zonk = webapp.config.get('WAVE_ZONK') sounds = webapp.config.get('SOUNDS') +host = 'localhost' +if webapp.config.get('DEBUG'): + host = '0.0.0.0' + # copied from sudo eperm_insults = { 'Wrong! You cheating scum!', @@ -407,8 +411,6 @@ def on_connect(): @webapp.route('/display') def display(): - if request.remote_addr != '127.0.0.1': - abort(403) return render_template('display.html') @@ -492,6 +494,6 @@ if __name__ == '__main__': logic = Logic() - socketio.run(webapp, host='0.0.0.0', port=8080) + socketio.run(webapp, host=host, port=8080) sys.exit(0)