Scan all candidate Google IPs and display results. Args: front_domain: The SNI hostname to use (e.g. "www.google.com"). Returns: True if at least one IP is reachable, False otherwise.
(front_domain: str)
| 108 | |
| 109 | |
| 110 | async def run(front_domain: str) -> bool: |
| 111 | """ |
| 112 | Scan all candidate Google IPs and display results. |
| 113 | |
| 114 | Args: |
| 115 | front_domain: The SNI hostname to use (e.g. "www.google.com"). |
| 116 | |
| 117 | Returns: |
| 118 | True if at least one IP is reachable, False otherwise. |
| 119 | """ |
| 120 | timeout = GOOGLE_SCANNER_TIMEOUT |
| 121 | concurrency = GOOGLE_SCANNER_CONCURRENCY |
| 122 | |
| 123 | print() |
| 124 | print(f"Scanning {len(CANDIDATE_IPS)} Google frontend IPs") |
| 125 | print(f" SNI: {front_domain}") |
| 126 | print(f" Timeout: {timeout}s per IP") |
| 127 | print(f" Concurrency: {concurrency} parallel probes") |
| 128 | print() |
| 129 | |
| 130 | # Create semaphore to limit concurrency |
| 131 | semaphore = asyncio.Semaphore(concurrency) |
| 132 | |
| 133 | # Launch all probes concurrently |
| 134 | tasks = [ |
| 135 | _probe_ip(ip, front_domain, semaphore, timeout) |
| 136 | for ip in CANDIDATE_IPS |
| 137 | ] |
| 138 | results = await asyncio.gather(*tasks) |
| 139 | |
| 140 | # Sort by latency (successful first, then by speed) |
| 141 | results.sort(key=lambda r: (not r.ok, r.latency_ms or float("inf"))) |
| 142 | |
| 143 | # Display results table |
| 144 | print(f"{'IP':<20} {'LATENCY':<12} {'STATUS':<25}") |
| 145 | print(f"{'-' * 20} {'-' * 12} {'-' * 25}") |
| 146 | |
| 147 | ok_count = 0 |
| 148 | for result in results: |
| 149 | if result.ok: |
| 150 | print(f"{result.ip:<20} {result.latency_ms:>8}ms OK") |
| 151 | ok_count += 1 |
| 152 | else: |
| 153 | status = result.error or "unknown error" |
| 154 | print(f"{result.ip:<20} {'—':<12} {status:<25}") |
| 155 | |
| 156 | print() |
| 157 | print(f"Result: {ok_count} / {len(results)} reachable") |
| 158 | |
| 159 | if ok_count == 0: |
| 160 | print("No Google IPs reachable from this network.") |
| 161 | print() |
| 162 | return False |
| 163 | |
| 164 | # Show top 3 fastest |
| 165 | fastest = [r for r in results if r.ok][:3] |
| 166 | print() |
| 167 | print("Top 3 fastest IPs:") |