diff options
author | B Stack <bgstack15@gmail.com> | 2020-12-10 19:01:27 -0500 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-12-10 19:01:27 -0500 |
commit | b24910be0f15e0268436111fc2c579c7d1685fa0 (patch) | |
tree | fac06b8f4e33fbf1e796789e2521a054c9ce2690 /hex_zero.py | |
parent | improve front page html (diff) | |
download | hex-zero-b24910be0f15e0268436111fc2c579c7d1685fa0.tar.gz hex-zero-b24910be0f15e0268436111fc2c579c7d1685fa0.tar.bz2 hex-zero-b24910be0f15e0268436111fc2c579c7d1685fa0.zip |
gracefully handle when x_forwarded_for is null
Diffstat (limited to 'hex_zero.py')
-rwxr-xr-x | hex_zero.py | 9 |
1 files changed, 6 insertions, 3 deletions
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: |