feat: add cluster management and audit utility scripts

This commit is contained in:
2026-11-05 21:40:22 -05:00
parent fa969fc1d3
commit fffb446206
63 changed files with 1686 additions and 6 deletions

28
scripts/test_adblock.py Normal file
View File

@@ -0,0 +1,28 @@
import socket
import struct
def test_ad_block(server_ip, domain="pagead2.googlesyndication.com"):
header = struct.pack(">HHHHHH", 0x1234, 0x0100, 1, 0, 0, 0)
qname = b"".join(bytes([len(p)]) + p.encode("ascii") for p in domain.split(".")) + b"\x00"
qtype_qclass = struct.pack(">HH", 1, 1)
packet = header + qname + qtype_qclass
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.settimeout(3.0)
try:
sock.sendto(packet, (server_ip, 53))
resp, _ = sock.recvfrom(1024)
# Parse answer IP (last 4 bytes of standard A record answer)
if len(resp) >= 32:
ip = ".".join(str(b) for b in resp[-4:])
print(f"Server {server_ip} returned for {domain} -> {ip}")
if ip in ["0.0.0.0", "127.0.0.1"]:
print(f" [VERIFIED] Ad domain {domain} was BLOCKED (0.0.0.0)!")
except Exception as e:
print(f"Error querying {server_ip}: {e}")
finally:
sock.close()
test_ad_block("140.44.4.36")
test_ad_block("140.44.4.65")