understanding commited on
Commit
27d20e1
·
verified ·
1 Parent(s): 4fb1a6d

Create diag_extra.py

Browse files
Files changed (1) hide show
  1. bot/integrations/diag_extra.py +14 -0
bot/integrations/diag_extra.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PATH: bot/integrations/diag_extra.py
2
+ import socket
3
+ from urllib.parse import urlparse
4
+
5
+ def dns_check(url: str) -> str:
6
+ try:
7
+ host = urlparse(url).hostname
8
+ if not host:
9
+ return "bad_url"
10
+ infos = socket.getaddrinfo(host, 443, type=socket.SOCK_STREAM)
11
+ ips = sorted({i[4][0] for i in infos})
12
+ return "OK " + ", ".join(ips[:6])
13
+ except Exception as e:
14
+ return f"ERR:{type(e).__name__}:{e}"