37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import urllib.request
|
|
import ssl
|
|
import http.client
|
|
|
|
ctx = ssl.create_default_context()
|
|
ctx.check_hostname = False
|
|
ctx.verify_mode = ssl.CERT_NONE
|
|
|
|
def test_external(domain):
|
|
print(f"\n=== Testing External Request to {domain} ===")
|
|
url = f"https://{domain}/"
|
|
req = urllib.request.Request(
|
|
url,
|
|
headers={
|
|
'Host': domain,
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8'
|
|
}
|
|
)
|
|
|
|
# We test connecting directly to WAN IP with SNI
|
|
conn = http.client.HTTPSConnection("174.106.252.96", 443, context=ctx, timeout=8)
|
|
conn.request("GET", "/", headers={
|
|
'Host': domain,
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
|
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
|
|
})
|
|
resp = conn.getresponse()
|
|
print("Status code:", resp.status)
|
|
print("Location header:", resp.getheader('Location'))
|
|
print("Set-Cookie header:", resp.getheader('Set-Cookie'))
|
|
conn.close()
|
|
|
|
test_external('pihole1.snarfnet.net')
|
|
test_external('pihole2.snarfnet.net')
|
|
|