From 133e85fa499c2a68aaffd584647f9a33cfe8c2df Mon Sep 17 00:00:00 2001 From: lan Date: Wed, 14 Dec 2022 12:28:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=9B=B4=E6=96=B0=E8=8E=B7=E5=8F=96IP?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- depends.py | 3 ++- templates/index.html | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/depends.py b/depends.py index e92bb40..6b1dc66 100644 --- a/depends.py +++ b/depends.py @@ -46,7 +46,8 @@ class IPRateLimit: self.ips.pop(ip) def __call__(self, request: Request): - ip = request.client.host + ip = request.headers.get('X-Real-IP', request.headers.get('X-Forwarded-For', request.client.host)) + print(ip) if not self.check_ip(ip): raise HTTPException(status_code=400, detail=f"请求次数过多,请稍后再试") return ip diff --git a/templates/index.html b/templates/index.html index fcd100f..c078cda 100644 --- a/templates/index.html +++ b/templates/index.html @@ -11,7 +11,7 @@ - +