Skip to content

Commit

Permalink
🔥 Update IP check url
Browse files Browse the repository at this point in the history
  • Loading branch information
shamhi committed Sep 24, 2024
1 parent a5b627f commit 39e08a8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions bot/utils/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ def get_proxy_string(name: str):


async def check_proxy(
http_client: aiohttp.ClientSession, proxy: str, session_name: str
http_client: aiohttp.ClientSession, proxy: str, session_name: str
) -> None:
try:
response = await http_client.get(
url='https://httpbin.org/ip', timeout=aiohttp.ClientTimeout(5)
)
ip = (await response.json()).get('origin')
logger.info(f'{session_name} | Proxy IP: {ip}')
response = await http_client.get(url='https://ipinfo.io/json', timeout=aiohttp.ClientTimeout(5))
response.raise_for_status()

response_json = await response.json()
ip = response_json.get('ip', 'NO')

logger.info(f'{session_name} | Proxy IP: <lw>{ip}</lw>')
except Exception as error:
logger.error(f'{session_name} | Proxy: <le>{proxy}</le> | Error: <lr>{error}</lr>')

0 comments on commit 39e08a8

Please sign in to comment.