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 @@ - +