Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/lysis/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ class Vote(BaseModel):


def client_ip(request: Request):
# The right-most entry is added by Render's proxy, so a client can't spoof it.
fwd = request.headers.get("x-forwarded-for", "")
print("DEBUG ip:", fwd, "| cf:", request.headers.get("cf-connecting-ip"), flush=True)
if fwd:
return fwd.split(",")[-1].strip()
return request.client.host if request.client else "unknown"


def limit_ip(request: Request):
if not PER_IP.allow(client_ip(request)):
raise HTTPException(
Expand Down
Loading