fix:更新获取IP的方式

This commit is contained in:
lan
2022-12-14 12:28:09 +08:00
parent 78c7174e69
commit 1871706ad1
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -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
+1 -1
View File
@@ -11,7 +11,7 @@
<meta name="description" content="{{description}}"/>
<meta name="keywords" content="{{keywords}}"/>
<meta name="generator" content="FileCodeBox"/>
<meta name="template" content="Lan-V1.5.4"/>
<meta name="template" content="Lan-V1.5.5"/>
<style>
.qu .el-button {
width: 100px;