|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | | -from typing_extensions import TypedDict |
| 5 | +from typing import Iterable |
| 6 | +from typing_extensions import Required, TypedDict |
6 | 7 |
|
7 | 8 | from .._types import SequenceNotStr |
8 | 9 |
|
9 | | -__all__ = ["BrowserNetworkConfigParam"] |
| 10 | +__all__ = ["BrowserNetworkConfigParam", "ProxyRoute", "ProxyRouteProxy"] |
| 11 | + |
| 12 | + |
| 13 | +class ProxyRouteProxy(TypedDict, total=False): |
| 14 | + """Select an active non-direct proxy by ID or name. Responses always use ID.""" |
| 15 | + |
| 16 | + id: str |
| 17 | + |
| 18 | + name: str |
| 19 | + |
| 20 | + |
| 21 | +class ProxyRoute(TypedDict, total=False): |
| 22 | + hosts: Required[SequenceNotStr[str]] |
| 23 | + """Exact hostnames or leading \\**. |
| 24 | +
|
| 25 | + wildcard patterns (subdomains only); patterns cannot include ports, and matching |
| 26 | + ignores the destination port. Hosts not matched by any route use the session's |
| 27 | + top-level proxy (or the browser default when proxy is omitted). |
| 28 | + """ |
| 29 | + |
| 30 | + proxy: Required[ProxyRouteProxy] |
| 31 | + """Select an active non-direct proxy by ID or name. Responses always use ID.""" |
10 | 32 |
|
11 | 33 |
|
12 | 34 | class BrowserNetworkConfigParam(TypedDict, total=False): |
@@ -37,3 +59,22 @@ class BrowserNetworkConfigParam(TypedDict, total=False): |
37 | 59 | destinations. Not related to a proxy's bypass_hosts, which selects between |
38 | 60 | upstream-proxy and Kernel-managed direct egress and cannot reach into a VPN. |
39 | 61 | """ |
| 62 | + |
| 63 | + proxy_routes: Iterable[ProxyRoute] |
| 64 | + """Per-destination proxy routes for a browser session. |
| 65 | +
|
| 66 | + After setup, a destination hostname is matched against every route's hosts, |
| 67 | + regardless of port; route order does not matter. An exact hostname beats a |
| 68 | + wildcard, and a longer wildcard suffix beats a shorter one (for a.b.example.com: |
| 69 | + "a.b.example.com" > "_.b.example.com" > "_.example.com"). A host pattern may |
| 70 | + appear in only one route. "\\**.example.com" matches subdomains only, not |
| 71 | + example.com. A matched request selects the route's proxy instead of the |
| 72 | + session's top-level proxy (including mode: direct); the route proxy's own |
| 73 | + bypass_hosts still apply. If the route proxy becomes unavailable, matched |
| 74 | + requests fail closed without falling back. Requests that match no route use the |
| 75 | + session's default egress from the top-level proxy field (or the browser default |
| 76 | + when proxy is omitted: stealth proxy or direct egress). Routes take effect once |
| 77 | + the session is created; start_url and other traffic during browser setup use the |
| 78 | + top-level proxy. Setting routes requires proxy v3. Not supported on browser |
| 79 | + pools. |
| 80 | + """ |
0 commit comments