Commit c4c68ca7 authored by Luna's avatar Luna 📟

properly fetch ip address on cloudflare mode

reported by @violetwtf
parent c07f640e
Pipeline #142165614 failed with stage
in 6 minutes and 41 seconds
......@@ -14,6 +14,7 @@ import asyncpg
from ..errors import FailedAuth, NotFound
ALPHABET = string.ascii_lowercase + string.digits
CF_HEADER = 'CF-Connecting-IP'
log = logging.getLogger(__name__)
......@@ -35,9 +36,11 @@ def get_ip_addr(request) -> str:
Handles the cloudflare headers responsible to set
the client's IP.
if 'X-Forwarded-For' not in request.headers:
assert CF_HEADER in request.headers
return request.headers[CF_HEADER]
return request.ip
return request.headers['X-Forwarded-For']
def _gen_fname(length) -> str:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment