Set of possible types of proxy. Each proxy type has 2 properties: 'ff_value' is value of Firefox profile preference, 'string' is id of proxy type.
| 29 | |
| 30 | |
| 31 | class ProxyType: |
| 32 | """Set of possible types of proxy. |
| 33 | |
| 34 | Each proxy type has 2 properties: 'ff_value' is value of Firefox |
| 35 | profile preference, 'string' is id of proxy type. |
| 36 | """ |
| 37 | |
| 38 | DIRECT = ProxyTypeFactory.make(0, "DIRECT") # Direct connection, no proxy (default on Windows). |
| 39 | MANUAL = ProxyTypeFactory.make(1, "MANUAL") # Manual proxy settings (e.g., for httpProxy). |
| 40 | PAC = ProxyTypeFactory.make(2, "PAC") # Proxy autoconfiguration from URL. |
| 41 | RESERVED_1 = ProxyTypeFactory.make(3, "RESERVED1") # Never used. |
| 42 | AUTODETECT = ProxyTypeFactory.make(4, "AUTODETECT") # Proxy autodetection (presumably with WPAD). |
| 43 | SYSTEM = ProxyTypeFactory.make(5, "SYSTEM") # Use system settings (default on Linux). |
| 44 | UNSPECIFIED = ProxyTypeFactory.make(6, "UNSPECIFIED") # Not initialized (for internal use). |
| 45 | |
| 46 | @classmethod |
| 47 | def load(cls, value): |
| 48 | if isinstance(value, dict) and "string" in value: |
| 49 | value = value["string"] |
| 50 | value = str(value).upper() |
| 51 | for attr in dir(cls): |
| 52 | attr_value = getattr(cls, attr) |
| 53 | if isinstance(attr_value, dict) and "string" in attr_value and attr_value["string"] == value: |
| 54 | return attr_value |
| 55 | raise Exception(f"No proxy type is found for {value}") |
| 56 | |
| 57 | |
| 58 | class _ProxyTypeDescriptor: |