aboutsummaryrefslogtreecommitdiffstats
path: root/backend/routes/forms
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2021-12-25 17:47:10 +0000
committerGravatar GitHub <[email protected]>2021-12-25 17:47:10 +0000
commitcff5510d5667297abf6a67806cb416fd45335bd1 (patch)
treefd462eae1170fcf49855a867c96dd6d6cbdb0b73 /backend/routes/forms
parentMerge pull request #104 from python-discord/Pin-platform-in-Dockerfile (diff)
parentHash Cf-Connecting-IP if given, else remote host (diff)
Merge pull request #120 from python-discord/jb3/store-correct-ip
Diffstat (limited to 'backend/routes/forms')
-rw-r--r--backend/routes/forms/submit.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/backend/routes/forms/submit.py b/backend/routes/forms/submit.py
index d0ce22c..8d9f4e5 100644
--- a/backend/routes/forms/submit.py
+++ b/backend/routes/forms/submit.py
@@ -116,7 +116,11 @@ class SubmitForm(Route):
if constants.FormFeatures.DISABLE_ANTISPAM.value not in form.features:
ip_hash_ctx = hashlib.md5()
- ip_hash_ctx.update(request.client.host.encode())
+ ip_hash_ctx.update(
+ request.headers.get(
+ "Cf-Connecting-IP", request.client.host
+ ).encode()
+ )
ip_hash = binascii.hexlify(ip_hash_ctx.digest())
user_agent_hash_ctx = hashlib.md5()
user_agent_hash_ctx.update(request.headers["User-Agent"].encode())