(host: str | None)
| 301 | |
| 302 | |
| 303 | def _is_loopback(host: str | None) -> bool: |
| 304 | if not host: |
| 305 | return False |
| 306 | if host.startswith("::ffff:"): # IPv4-mapped IPv6 |
| 307 | host = host[7:] |
| 308 | return host in {"127.0.0.1", "::1", "localhost"} or host.startswith("127.") |
| 309 | |
| 310 | |
| 311 | @functools.lru_cache(maxsize=1) |
no outgoing calls