torwire 0.1.1__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.
Files changed (32) hide show
  1. {torwire-0.1.1 → torwire-0.1.2}/PKG-INFO +1 -1
  2. {torwire-0.1.1 → torwire-0.1.2}/pyproject.toml +1 -1
  3. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/__init__.py +1 -1
  4. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/binary.py +25 -5
  5. {torwire-0.1.1 → torwire-0.1.2}/tests/unit/test_core.py +9 -0
  6. {torwire-0.1.1 → torwire-0.1.2}/.github/workflows/ci.yml +0 -0
  7. {torwire-0.1.1 → torwire-0.1.2}/.github/workflows/publish.yml +0 -0
  8. {torwire-0.1.1 → torwire-0.1.2}/.gitignore +0 -0
  9. {torwire-0.1.1 → torwire-0.1.2}/LICENSE +0 -0
  10. {torwire-0.1.1 → torwire-0.1.2}/README.md +0 -0
  11. {torwire-0.1.1 → torwire-0.1.2}/implementation_plan.md +0 -0
  12. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/_platform.py +0 -0
  13. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/bridge.py +0 -0
  14. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/checks.py +0 -0
  15. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/cli.py +0 -0
  16. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/clients/__init__.py +0 -0
  17. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/clients/aiohttp_.py +0 -0
  18. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/clients/httpx_.py +0 -0
  19. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/clients/requests_.py +0 -0
  20. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/config.py +0 -0
  21. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/controller.py +0 -0
  22. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/env.py +0 -0
  23. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/errors.py +0 -0
  24. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/manager.py +0 -0
  25. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/pool.py +0 -0
  26. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/process.py +0 -0
  27. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/py.typed +0 -0
  28. {torwire-0.1.1 → torwire-0.1.2}/src/torwire/rotation.py +0 -0
  29. {torwire-0.1.1 → torwire-0.1.2}/tests/__init__.py +0 -0
  30. {torwire-0.1.1 → torwire-0.1.2}/tests/integration/__init__.py +0 -0
  31. {torwire-0.1.1 → torwire-0.1.2}/tests/unit/__init__.py +0 -0
  32. {torwire-0.1.1 → 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.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
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "torwire"
7
- version = "0.1.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"
@@ -30,7 +30,7 @@ from torwire.errors import (
30
30
  from torwire.manager import TorManager
31
31
  from torwire.pool import TorPool
32
32
 
33
- __version__ = "0.1.1"
33
+ __version__ = "0.1.2"
34
34
 
35
35
  __all__ = [
36
36
  "TorManager",
@@ -32,8 +32,9 @@ from torwire.errors import (
32
32
 
33
33
  logger = logging.getLogger("torwire")
34
34
 
35
- TOR_VERSION = "14.0.4"
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
- archive_name = self._get_archive_name(TOR_VERSION)
209
- archive_url = self._get_archive_url(TOR_VERSION)
210
- sums_url = f"{EXPERT_BUNDLE_BASE_URL}/{TOR_VERSION}/sha256sums-signed-build.txt"
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": TOR_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