update ip
This commit is contained in:
+6
-2
@@ -155,10 +155,14 @@ router = APIRouter(prefix='/api/v1', tags=['ip'])
|
||||
|
||||
@router.get('/ip')
|
||||
async def get_ip(request: Request):
|
||||
ip = request.headers.get('X-Forwarded-For')
|
||||
forwarded = request.headers.get('X-Forwarded-For')
|
||||
|
||||
if forwarded:
|
||||
# Берем ПЕРВЫЙ IP из списка (это реальный клиент)
|
||||
client_ip = forwarded.split(',')[0].strip()
|
||||
|
||||
async with AsyncClient() as client:
|
||||
response = await client.get(f'https://ipinfo.io/{ip}')
|
||||
response = await client.get(f'https://ipinfo.io/{client_ip}')
|
||||
|
||||
html = response.text
|
||||
ipinfo = IPInfo(html)
|
||||
|
||||
Reference in New Issue
Block a user