1
0
Fork 0
mirror of https://github.com/Findus23/HNReader.git synced 2024-09-19 15:23:44 +02:00

correct IP detection

This commit is contained in:
Lukas Winkler 2021-07-23 21:23:23 +02:00
parent de98a843f9
commit ae4fe2fd42
Signed by: lukas
GPG key ID: 54DE4D798D244853

View file

@ -33,7 +33,10 @@ async def read(request: Request):
item = await api.get_item(item_id)
if "url" not in item:
return "Url not found", 404
if not debug and request.client not in trusted_ips:
if not debug and (
"x-forwarded-for" not in request.headers
or request.headers["x-forwarded-for"] not in trusted_ips
):
return JSONResponse({
"title": "Reader View not public",
"html": "For security reasons, this instance doesn't allow fetching a reader-friendly version of the website."