#!/usr/bin/env python3
"""DAS: pastikan server asal 103.175.217.138 memang menyajikan situs DAS (bukan halaman parkir)."""
import html, re, ssl, urllib.request

UA = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/124 Safari/537.36"}
ctx = ssl.create_default_context(); ctx.check_hostname = False; ctx.verify_mode = ssl.CERT_NONE

for host in ("dasindonesia.com", "www.dasindonesia.com"):
    try:
        req = urllib.request.Request("https://103.175.217.138/", headers={**UA, "Host": host})
        with urllib.request.urlopen(req, timeout=25, context=ctx) as r:
            b = r.read().decode("utf-8", "replace")
        t = re.search(r"<title>(.*?)</title>", b, re.S)
        d = re.search(r'<meta name="description" content="([^"]*)"', b)
        print(f"   Host: {host}")
        print(f"      HTTP {r.status} | {len(b)//1024} KB | judul: {html.unescape(t.group(1)).strip()[:70] if t else '-'}")
        print(f"      meta : {html.unescape(d.group(1))[:80] if d else '-'}")
        print(f"      'DAS Bengkel Indonesia' muncul {len(re.findall('DAS Bengkel Indonesia', b))}x | 'Surabaya' {len(re.findall('Surabaya', b))}x")
    except Exception as e:
        print(f"   Host: {host} → gagal {str(e)[:60]}")

print("\n=== beranda lewat Cloudflare (jalur pengunjung) ===")
try:
    with urllib.request.urlopen(urllib.request.Request("https://dasindonesia.com/", headers=UA), timeout=60) as r:
        print(f"   HTTP {r.status} | cf={r.headers.get('cf-cache-status')}")
except Exception as e:
    print(f"   gagal: {str(e)[:80]}")
