Proxy address. Attributes: scheme: ``"socks5h"``, ``"socks5"``, ``"socks4a"``, ``"socks4"``, ``"https"``, or ``"http"``. host: Normalized to lower case. port: Always set even if it's the default. username: Available when the proxy address contain
| 16 | |
| 17 | @dataclasses.dataclass |
| 18 | class Proxy: |
| 19 | """ |
| 20 | Proxy address. |
| 21 | |
| 22 | Attributes: |
| 23 | scheme: ``"socks5h"``, ``"socks5"``, ``"socks4a"``, ``"socks4"``, |
| 24 | ``"https"``, or ``"http"``. |
| 25 | host: Normalized to lower case. |
| 26 | port: Always set even if it's the default. |
| 27 | username: Available when the proxy address contains `User Information`_. |
| 28 | password: Available when the proxy address contains `User Information`_. |
| 29 | |
| 30 | .. _User Information: https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1 |
| 31 | |
| 32 | """ |
| 33 | |
| 34 | scheme: str |
| 35 | host: str |
| 36 | port: int |
| 37 | username: str | None = None |
| 38 | password: str | None = None |
| 39 | |
| 40 | @property |
| 41 | def user_info(self) -> tuple[str, str] | None: |
| 42 | if self.username is None: |
| 43 | return None |
| 44 | assert self.password is not None |
| 45 | return (self.username, self.password) |
| 46 | |
| 47 | |
| 48 | def parse_proxy(proxy: str) -> Proxy: |
no outgoing calls
no test coverage detected
searching dependent graphs…