stack-orchestrator/scripts/relay-test-tcp-sport.py
A. F. Dudley 496c7982cb feat: end-to-end relay test scripts
Three Python scripts send real packets from the kind node through the
full relay path (biscayne → tunnel → mia-sw01 → was-sw01 → internet)
and verify responses come back via the inbound path. No indirect
counter-checking — a response proves both directions work.

- relay-test-udp.py: DNS query with sport 8001
- relay-test-tcp-sport.py: HTTP request with sport 8001
- relay-test-tcp-dport.py: TCP connect to entrypoint dport 8001 (ip_echo)
- test-ashburn-relay.sh: orchestrates from ansible controller via nsenter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 00:43:06 +00:00

29 lines
707 B
Python
Executable File

#!/usr/bin/env python3
"""TCP sport 8001 round trip via HTTP HEAD to 1.1.1.1."""
import socket
import sys
PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 8001
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(5)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(("0.0.0.0", PORT))
try:
s.connect(("1.1.1.1", 80))
s.sendall(b"HEAD / HTTP/1.0\r\nHost: 1.1.1.1\r\n\r\n")
resp = s.recv(256)
if b"HTTP" in resp:
print("OK HTTP response received")
else:
print(f"OK {len(resp)} bytes (non-HTTP)")
except socket.timeout:
print("TIMEOUT")
sys.exit(1)
except Exception as e:
print(f"ERROR {e}")
sys.exit(1)
finally:
s.close()