Normalize socket address to ASGI-compatible (host, port) tuple. ASGI spec requires server/client to be (host, port) tuples. IPv6 sockets return 4-tuples (host, port, flowinfo, scope_id), so we extract just the first two elements.
(sockaddr)
| 39 | |
| 40 | |
| 41 | def _normalize_sockaddr(sockaddr): |
| 42 | """Normalize socket address to ASGI-compatible (host, port) tuple. |
| 43 | |
| 44 | ASGI spec requires server/client to be (host, port) tuples. |
| 45 | IPv6 sockets return 4-tuples (host, port, flowinfo, scope_id), |
| 46 | so we extract just the first two elements. |
| 47 | """ |
| 48 | return tuple(sockaddr[:2]) if sockaddr else None |
| 49 | |
| 50 | |
| 51 | def _check_trusted_proxy(peer_addr, allow_list, networks): |
no outgoing calls