From b24910be0f15e0268436111fc2c579c7d1685fa0 Mon Sep 17 00:00:00 2001 From: B Stack Date: Thu, 10 Dec 2020 19:01:27 -0500 Subject: gracefully handle when x_forwarded_for is null --- hex_zero.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'hex_zero.py') diff --git a/hex_zero.py b/hex_zero.py index 81c8169..b534a51 100755 --- a/hex_zero.py +++ b/hex_zero.py @@ -382,9 +382,12 @@ def fhost(): out = None if "file" in request.files: - if app.config["USE_HTTP_X_FORWARDED_FOR"]: - stored_ip_address = request.environ["HTTP_X_FORWARDED_FOR"] - else: + try: + if app.config["USE_HTTP_X_FORWARDED_FOR"]: + stored_ip_address = request.environ["HTTP_X_FORWARDED_FOR"] + else: + stored_ip_address = request.remote_addr + except: stored_ip_address = request.remote_addr out = store_file(request.files["file"], stored_ip_address) elif "url" in request.form: -- cgit