torwire 0.1.0__tar.gz → 0.1.2__tar.gz
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.
- {torwire-0.1.0 → torwire-0.1.2}/PKG-INFO +1 -2
- {torwire-0.1.0 → torwire-0.1.2}/pyproject.toml +2 -2
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/__init__.py +1 -1
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/binary.py +25 -5
- {torwire-0.1.0 → torwire-0.1.2}/tests/unit/test_core.py +9 -0
- {torwire-0.1.0 → torwire-0.1.2}/.github/workflows/ci.yml +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/.github/workflows/publish.yml +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/.gitignore +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/LICENSE +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/README.md +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/implementation_plan.md +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/_platform.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/bridge.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/checks.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/cli.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/clients/__init__.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/clients/aiohttp_.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/clients/httpx_.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/clients/requests_.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/config.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/controller.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/env.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/errors.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/manager.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/pool.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/process.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/py.typed +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/src/torwire/rotation.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/tests/__init__.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/tests/integration/__init__.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/tests/unit/__init__.py +0 -0
- {torwire-0.1.0 → torwire-0.1.2}/torwire_os_support.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: torwire
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Route your Python app's traffic through Tor. No proxychains, no Privoxy, no manual setup.
|
|
5
5
|
Project-URL: Homepage, https://github.com/TechXploreGenSec/torwire
|
|
6
6
|
Project-URL: Documentation, https://github.com/TechXploreGenSec/torwire#readme
|
|
@@ -33,7 +33,6 @@ Requires-Dist: aiohttp-socks>=0.9; extra == 'all'
|
|
|
33
33
|
Requires-Dist: aiohttp>=3.9; extra == 'all'
|
|
34
34
|
Requires-Dist: httpx[socks]>=0.27; extra == 'all'
|
|
35
35
|
Requires-Dist: requests[socks]>=2.31; extra == 'all'
|
|
36
|
-
Requires-Dist: torwire-bin; extra == 'all'
|
|
37
36
|
Provides-Extra: bundled
|
|
38
37
|
Requires-Dist: torwire-bin; extra == 'bundled'
|
|
39
38
|
Provides-Extra: httpx
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "torwire"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.2"
|
|
8
8
|
description = "Route your Python app's traffic through Tor. No proxychains, no Privoxy, no manual setup."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -37,7 +37,7 @@ requests = ["requests[socks]>=2.31"]
|
|
|
37
37
|
httpx = ["httpx[socks]>=0.27"]
|
|
38
38
|
aiohttp = ["aiohttp>=3.9", "aiohttp-socks>=0.9"]
|
|
39
39
|
bundled = ["torwire-bin"]
|
|
40
|
-
all = ["torwire[requests,httpx,aiohttp
|
|
40
|
+
all = ["torwire[requests,httpx,aiohttp]"]
|
|
41
41
|
|
|
42
42
|
[project.scripts]
|
|
43
43
|
torwire = "torwire.cli:main"
|
|
@@ -32,8 +32,9 @@ from torwire.errors import (
|
|
|
32
32
|
|
|
33
33
|
logger = logging.getLogger("torwire")
|
|
34
34
|
|
|
35
|
-
TOR_VERSION = "
|
|
35
|
+
TOR_VERSION = "16.0.3"
|
|
36
36
|
EXPERT_BUNDLE_BASE_URL = "https://dist.torproject.org/torbrowser"
|
|
37
|
+
_VERSION_LINK_RE = re.compile(r'href="(\d+\.\d+(?:\.\d+)?)/"')
|
|
37
38
|
|
|
38
39
|
_ARCHIVE_MAP: dict[tuple[str, str], str] = {
|
|
39
40
|
("windows", "x86_64"): "tor-expert-bundle-windows-x86_64-{ver}.tar.gz",
|
|
@@ -203,11 +204,30 @@ class BinaryManager:
|
|
|
203
204
|
archive_name = self._get_archive_name(version)
|
|
204
205
|
return f"{EXPERT_BUNDLE_BASE_URL}/{version}/{archive_name}"
|
|
205
206
|
|
|
207
|
+
def _resolve_latest_version(self) -> str:
|
|
208
|
+
"""Query Tor Project's download listing for the latest stable version."""
|
|
209
|
+
try:
|
|
210
|
+
req = urllib.request.Request(
|
|
211
|
+
f"{EXPERT_BUNDLE_BASE_URL}/",
|
|
212
|
+
headers={"User-Agent": "torwire"},
|
|
213
|
+
)
|
|
214
|
+
with urllib.request.urlopen(req, timeout=15) as resp:
|
|
215
|
+
html = resp.read().decode("utf-8", errors="replace")
|
|
216
|
+
versions = _VERSION_LINK_RE.findall(html)
|
|
217
|
+
if versions:
|
|
218
|
+
latest = max(versions, key=lambda v: tuple(int(p) for p in v.split(".")))
|
|
219
|
+
logger.debug("Resolved latest Tor Expert Bundle version: %s", latest)
|
|
220
|
+
return latest
|
|
221
|
+
except Exception as exc:
|
|
222
|
+
logger.debug("Could not resolve latest Tor version (%s); using fallback %s", exc, TOR_VERSION)
|
|
223
|
+
return TOR_VERSION
|
|
224
|
+
|
|
206
225
|
def _download(self, verify: bool = True) -> Path:
|
|
207
226
|
"""Download, verify, and extract the Tor Expert Bundle to the cache dir."""
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
227
|
+
version = self._resolve_latest_version()
|
|
228
|
+
archive_name = self._get_archive_name(version)
|
|
229
|
+
archive_url = self._get_archive_url(version)
|
|
230
|
+
sums_url = f"{EXPERT_BUNDLE_BASE_URL}/{version}/sha256sums-signed-build.txt"
|
|
211
231
|
|
|
212
232
|
cache_dir = self._platform_cache_dir()
|
|
213
233
|
if cache_dir is None:
|
|
@@ -252,7 +272,7 @@ class BinaryManager:
|
|
|
252
272
|
binary.chmod(current_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
|
253
273
|
|
|
254
274
|
meta = {
|
|
255
|
-
"version":
|
|
275
|
+
"version": version,
|
|
256
276
|
"archive": archive_name,
|
|
257
277
|
"downloaded_at": datetime.now(timezone.utc).isoformat(),
|
|
258
278
|
}
|
|
@@ -216,6 +216,15 @@ class TestBinaryManager:
|
|
|
216
216
|
with pytest.raises(BinaryNotFoundError):
|
|
217
217
|
mgr.ensure()
|
|
218
218
|
|
|
219
|
+
def test_resolve_latest_version_parses_listing(self) -> None:
|
|
220
|
+
html = b'<a href="15.0.1/">15.0.1/</a><a href="16.0.3/">16.0.3/</a><a href="16.5a1/">16.5a1/</a>'
|
|
221
|
+
mock_resp = MagicMock()
|
|
222
|
+
mock_resp.read.return_value = html
|
|
223
|
+
mock_resp.__enter__ = lambda s: s
|
|
224
|
+
mock_resp.__exit__ = lambda s, *a: None
|
|
225
|
+
with patch("urllib.request.urlopen", return_value=mock_resp):
|
|
226
|
+
assert BinaryManager()._resolve_latest_version() == "16.0.3"
|
|
227
|
+
|
|
219
228
|
|
|
220
229
|
class TestBridgeEncoding:
|
|
221
230
|
def test_encode_socks5_connect(self) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|