Skip to content

Commit 133e85f

Browse files
committed
fix:更新获取IP的方式
1 parent a432f8d commit 133e85f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

depends.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ async def remove_expired_ip(self):
4646
self.ips.pop(ip)
4747

4848
def __call__(self, request: Request):
49-
ip = request.client.host
49+
ip = request.headers.get('X-Real-IP', request.headers.get('X-Forwarded-For', request.client.host))
50+
print(ip)
5051
if not self.check_ip(ip):
5152
raise HTTPException(status_code=400, detail=f"请求次数过多,请稍后再试")
5253
return ip

templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<meta name="description" content="{{description}}"/>
1212
<meta name="keywords" content="{{keywords}}"/>
1313
<meta name="generator" content="FileCodeBox"/>
14-
<meta name="template" content="Lan-V1.5.4"/>
14+
<meta name="template" content="Lan-V1.5.5"/>
1515
<style>
1616
.qu .el-button {
1717
width: 100px;

0 commit comments

Comments
 (0)