asockslib 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- asockslib/__init__.py +117 -0
- asockslib/_console.py +18 -0
- asockslib/_port_utils.py +132 -0
- asockslib/benchmark.py +365 -0
- asockslib/cli/__init__.py +72 -0
- asockslib/cli/_helpers.py +162 -0
- asockslib/cli/_output.py +52 -0
- asockslib/cli/api_commands.py +377 -0
- asockslib/cli/commands.py +485 -0
- asockslib/client.py +634 -0
- asockslib/exceptions.py +89 -0
- asockslib/geo.json +649269 -0
- asockslib/geo_picker/__init__.py +30 -0
- asockslib/geo_picker/_completer.py +90 -0
- asockslib/geo_picker/_messages.py +89 -0
- asockslib/geo_picker/_types.py +89 -0
- asockslib/geo_picker/picker.py +667 -0
- asockslib/models/__init__.py +72 -0
- asockslib/models/directory.py +65 -0
- asockslib/models/enums.py +65 -0
- asockslib/models/port.py +187 -0
- asockslib/models/requests.py +89 -0
- asockslib/models/responses.py +20 -0
- asockslib/proxy_pool.py +659 -0
- asockslib/quick.py +174 -0
- asockslib/smart_proxy.py +251 -0
- asockslib-0.1.0.dist-info/METADATA +228 -0
- asockslib-0.1.0.dist-info/RECORD +30 -0
- asockslib-0.1.0.dist-info/WHEEL +4 -0
- asockslib-0.1.0.dist-info/entry_points.txt +3 -0
asockslib/exceptions.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""Custom exceptions for the ASocks library.
|
|
2
|
+
|
|
3
|
+
Exception hierarchy::
|
|
4
|
+
|
|
5
|
+
ASocksError (base)
|
|
6
|
+
├── AuthenticationError # HTTP 401/403
|
|
7
|
+
├── RateLimitError # HTTP 429
|
|
8
|
+
├── PortNotFoundError # HTTP 404
|
|
9
|
+
├── InsufficientBalanceError # HTTP 402
|
|
10
|
+
├── APIConnectionError # network/transport failure (timeout, refused)
|
|
11
|
+
├── ProxyHealthError # proxy health-check failure
|
|
12
|
+
└── NoAvailableProxyError # proxy pool exhausted
|
|
13
|
+
|
|
14
|
+
All exceptions inherit from :class:`ASocksError`, allowing a single
|
|
15
|
+
``except`` block to catch every library error.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ASocksError(Exception):
|
|
22
|
+
"""Base exception for all ASocks errors.
|
|
23
|
+
|
|
24
|
+
Attributes:
|
|
25
|
+
message: Human-readable error description.
|
|
26
|
+
status_code: HTTP status code returned by the API, if applicable.
|
|
27
|
+
|
|
28
|
+
Example::
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
await client.get_balance()
|
|
32
|
+
except ASocksError as e:
|
|
33
|
+
print(f"Error [{e.status_code}]: {e.message}")
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self, message: str, status_code: int | None = None) -> None:
|
|
37
|
+
self.message = message
|
|
38
|
+
self.status_code = status_code
|
|
39
|
+
super().__init__(self.message)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class AuthenticationError(ASocksError):
|
|
43
|
+
"""Invalid or missing API key (HTTP 401/403)."""
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class RateLimitError(ASocksError):
|
|
47
|
+
"""API rate limit exceeded (HTTP 429).
|
|
48
|
+
|
|
49
|
+
The client retries automatically with exponential back-off
|
|
50
|
+
(up to 5 attempts). This exception is raised only after all
|
|
51
|
+
retries are exhausted.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class PortNotFoundError(ASocksError):
|
|
56
|
+
"""Requested port does not exist (HTTP 404)."""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class InsufficientBalanceError(ASocksError):
|
|
60
|
+
"""Insufficient account balance (HTTP 402).
|
|
61
|
+
|
|
62
|
+
Top up your balance at https://my.asocks.com.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class APIConnectionError(ASocksError):
|
|
67
|
+
"""Network/transport failure talking to the ASocks API.
|
|
68
|
+
|
|
69
|
+
Raised when the HTTP request cannot complete — connection refused,
|
|
70
|
+
connection reset, DNS failure, or timeout — after all retries are
|
|
71
|
+
exhausted. Wraps the underlying ``httpx.TransportError`` (available
|
|
72
|
+
via ``__cause__``) so callers get a single typed error to catch.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class ProxyHealthError(ASocksError):
|
|
77
|
+
"""Proxy failed a health check.
|
|
78
|
+
|
|
79
|
+
Raised by :class:`SmartProxy` when a proxy is unreachable,
|
|
80
|
+
times out, or returns an unexpected response.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class NoAvailableProxyError(ASocksError):
|
|
85
|
+
"""No proxies matching the requested criteria are available.
|
|
86
|
+
|
|
87
|
+
Raised by :class:`SmartProxy` / :class:`ProxyPool` when the
|
|
88
|
+
pool is empty or all proxies have failed health checks.
|
|
89
|
+
"""
|