feat: add various infrastructure and service diagnostic scripts
This commit is contained in:
58
scripts/verify_npm_live.py
Normal file
58
scripts/verify_npm_live.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import ssl
|
||||
import socket
|
||||
import sys
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
active_hosts = [
|
||||
'pihole1.snarfnet.net',
|
||||
'pihole2.snarfnet.net',
|
||||
'dns1.snarfnet.net',
|
||||
'dns2.snarfnet.net',
|
||||
]
|
||||
|
||||
removed_hosts = [
|
||||
'pihole.snarfnet.net',
|
||||
'pihole3.snarfnet.net',
|
||||
'technitium.snarfnet.net',
|
||||
]
|
||||
|
||||
npm_vip = '140.44.4.70'
|
||||
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
|
||||
print(f"=== Active Endpoints via NPM VIP ({npm_vip}:443) ===")
|
||||
for host in active_hosts:
|
||||
path = '/admin/' if 'pihole' in host else '/'
|
||||
try:
|
||||
sock = socket.create_connection((npm_vip, 443), timeout=5)
|
||||
ssock = ctx.wrap_socket(sock, server_hostname=host)
|
||||
req = f"GET {path} HTTP/1.1\r\nHost: {host}\r\nUser-Agent: Mozilla/5.0\r\nConnection: close\r\n\r\n"
|
||||
ssock.sendall(req.encode('utf-8'))
|
||||
resp = ssock.recv(4096).decode('utf-8', errors='replace')
|
||||
ssock.close()
|
||||
|
||||
status_line = resp.splitlines()[0] if resp else "No response"
|
||||
loc = [l for l in resp.splitlines() if 'location:' in l.lower()]
|
||||
loc_str = loc[0][:75] + "..." if loc else ""
|
||||
print(f" ✓ {host:25} -> {status_line:15} {loc_str}")
|
||||
except Exception as e:
|
||||
print(f" ✗ {host:25} -> ERROR: {e}")
|
||||
|
||||
print(f"\n=== Removed Endpoints via NPM VIP ({npm_vip}:443) ===")
|
||||
for host in removed_hosts:
|
||||
path = '/admin/' if 'pihole' in host else '/'
|
||||
try:
|
||||
sock = socket.create_connection((npm_vip, 443), timeout=5)
|
||||
ssock = ctx.wrap_socket(sock, server_hostname=host)
|
||||
req = f"GET {path} HTTP/1.1\r\nHost: {host}\r\nUser-Agent: Mozilla/5.0\r\nConnection: close\r\n\r\n"
|
||||
ssock.sendall(req.encode('utf-8'))
|
||||
resp = ssock.recv(4096).decode('utf-8', errors='replace')
|
||||
ssock.close()
|
||||
|
||||
status_line = resp.splitlines()[0] if resp else "No response"
|
||||
print(f" - {host:25} -> {status_line:15} (Default host/unrouted)")
|
||||
except Exception as e:
|
||||
print(f" - {host:25} -> {e}")
|
||||
Reference in New Issue
Block a user