feat: add various infrastructure check and automation scripts
This commit is contained in:
27
scripts/check_dns_heimdall.py
Normal file
27
scripts/check_dns_heimdall.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
import ssl
|
||||
import json
|
||||
import http.client
|
||||
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
|
||||
def do_req(ip, host_header, path):
|
||||
conn = http.client.HTTPSConnection(ip, 443, context=ctx, timeout=8)
|
||||
conn.request("GET", path, headers={"Host": host_header})
|
||||
resp = conn.getresponse()
|
||||
data = resp.read().decode('utf-8')
|
||||
conn.close()
|
||||
return json.loads(data)
|
||||
|
||||
try:
|
||||
token = do_req("140.44.4.62", "dns2.snarfnet.net", "/api/user/login?user=admin&pass=snarfnetadmin&includeInfo=true")['token']
|
||||
rec_heimdall = do_req("140.44.4.62", "dns2.snarfnet.net", f"/api/zones/records/get?token={token}&zone=snarfnet.net&domain=heimdall.snarfnet.net")
|
||||
print("DNS2 heimdall:", rec_heimdall)
|
||||
rec_portal = do_req("140.44.4.62", "dns2.snarfnet.net", f"/api/zones/records/get?token={token}&zone=snarfnet.net&domain=portal.snarfnet.net")
|
||||
print("DNS2 portal:", rec_portal)
|
||||
except Exception as e:
|
||||
print("DNS check err:", e)
|
||||
|
||||
Reference in New Issue
Block a user