mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-20 02:26:32 +01:00
httpx man
This commit is contained in:
parent
db634f2a73
commit
a6f2055b8c
1 changed files with 19 additions and 22 deletions
|
@ -855,30 +855,27 @@ class OtherCog(commands.Cog):
|
||||||
await ctx.respond("Removed domain from blacklist.")
|
await ctx.respond("Removed domain from blacklist.")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def check_proxy(self, url: str = "socks5://localhost:1090"):
|
async def check_proxy(url: str = "socks5://localhost:1090"):
|
||||||
async with httpx.AsyncClient(
|
client = httpx.AsyncClient(http2=True)
|
||||||
http2=True
|
my_ip64 = (await client.get("https://api64.ipify.org")).text
|
||||||
) as client:
|
my_ip4 = (await client.get("https://api.ipify.org")).text
|
||||||
my_ip64 = (await client.get("https://api64.ipify.org")).text
|
real_ips = [my_ip64, my_ip4]
|
||||||
my_ip4 = (await client.get("https://api.ipify.org")).text
|
await client.aclose()
|
||||||
real_ips = [my_ip64, my_ip4]
|
|
||||||
|
|
||||||
# Check the proxy
|
# Check the proxy
|
||||||
with httpx.AsyncClient(
|
client = httpx.AsyncClient(http2=True, proxies=url)
|
||||||
proxies=url
|
try:
|
||||||
) as client:
|
response = await client.get(
|
||||||
try:
|
"https://1.1.1.1/cdn-cgi/trace",
|
||||||
response = await client.get(
|
)
|
||||||
"https://1.1.1.1/cdn-cgi/trace",
|
response.raise_for_status()
|
||||||
)
|
for line in response.text.splitlines():
|
||||||
response.raise_for_status()
|
if line.startswith("ip"):
|
||||||
for line in response.text.splitlines():
|
if any(x in line for x in real_ips):
|
||||||
if line.startswith("ip"):
|
return 1
|
||||||
if any(x in line for x in real_ips):
|
except (httpx.TransportError, httpx.HTTPStatusError):
|
||||||
return 1
|
return 2
|
||||||
except (httpx.TransportError, httpx.HTTPStatusError):
|
await client.aclose()
|
||||||
return 2
|
|
||||||
|
|
||||||
|
|
||||||
@commands.slash_command(name="yt-dl")
|
@commands.slash_command(name="yt-dl")
|
||||||
@commands.max_concurrency(1, commands.BucketType.user)
|
@commands.max_concurrency(1, commands.BucketType.user)
|
||||||
|
|
Loading…
Reference in a new issue