protox-gatekeeper 0.2.0__tar.gz → 0.2.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: protox-gatekeeper
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Fail-closed Tor session enforcement for Python HTTP(S) traffic
5
5
  Author: Tom Erik Harnes
6
6
  License: MIT License
@@ -33,6 +33,7 @@ Classifier: Programming Language :: Python :: 3
33
33
  Classifier: Programming Language :: Python :: 3.10
34
34
  Classifier: Programming Language :: Python :: 3.11
35
35
  Classifier: Programming Language :: Python :: 3.12
36
+ Classifier: Programming Language :: Python :: 3.13
36
37
  Classifier: License :: OSI Approved :: MIT License
37
38
  Classifier: Operating System :: OS Independent
38
39
  Requires-Python: >=3.10
@@ -252,7 +253,7 @@ MIT License
252
253
 
253
254
  ## Status
254
255
 
255
- - Version: **v0.2.0**
256
+ - Version: **v0.2.1**
256
257
  - Phase 2 in progress
257
258
  - API intentionally minimal
258
259
 
@@ -208,7 +208,7 @@ MIT License
208
208
 
209
209
  ## Status
210
210
 
211
- - Version: **v0.2.0**
211
+ - Version: **v0.2.1**
212
212
  - Phase 2 in progress
213
213
  - API intentionally minimal
214
214
 
@@ -1,6 +1,7 @@
1
1
  import logging
2
2
 
3
3
  import requests
4
+ from requests.exceptions import RequestException
4
5
 
5
6
  from protox_gatekeeper.session import make_tor_session
6
7
  from protox_gatekeeper.verify import is_tor_exit, get_public_ip
@@ -33,8 +34,16 @@ class GateKeeper:
33
34
  self._session = make_tor_session(port=socks_port)
34
35
 
35
36
  # 3) Verify Tor routing
36
- if not is_tor_exit(session=self._session, timeout=timeout):
37
- raise RuntimeError('Tor verification failed. Execution aborted.')
37
+ try:
38
+ if not is_tor_exit(session=self._session, timeout=timeout):
39
+ raise RuntimeError(
40
+ 'Tor verification failed. Execution aborted.')
41
+ except RequestException as e:
42
+ logger.debug('Underlying Tor connection error', exc_info=e)
43
+ raise RuntimeError(
44
+ f'Tor SOCKS proxy is not reachable on 127.0.0.1:{socks_port}. '
45
+ 'Start Tor or Tor Browser and try again.'
46
+ ) from None
38
47
 
39
48
  # 4) Measure Tor exit IP
40
49
  self.exit_ip = get_public_ip(session=self._session, timeout=timeout)
@@ -10,7 +10,7 @@ def geo_lookup(ip: str) -> str | None:
10
10
  r = requests.get(
11
11
  url=f'https://ipapi.co/{ip}/json',
12
12
  timeout=10,
13
- headers={'User-Agent': 'GateKeeper/0.1.0'}
13
+ headers={'User-Agent': 'GateKeeper/0.2.1'}
14
14
  )
15
15
  if r.status_code != 200:
16
16
  return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: protox-gatekeeper
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Fail-closed Tor session enforcement for Python HTTP(S) traffic
5
5
  Author: Tom Erik Harnes
6
6
  License: MIT License
@@ -33,6 +33,7 @@ Classifier: Programming Language :: Python :: 3
33
33
  Classifier: Programming Language :: Python :: 3.10
34
34
  Classifier: Programming Language :: Python :: 3.11
35
35
  Classifier: Programming Language :: Python :: 3.12
36
+ Classifier: Programming Language :: Python :: 3.13
36
37
  Classifier: License :: OSI Approved :: MIT License
37
38
  Classifier: Operating System :: OS Independent
38
39
  Requires-Python: >=3.10
@@ -252,7 +253,7 @@ MIT License
252
253
 
253
254
  ## Status
254
255
 
255
- - Version: **v0.2.0**
256
+ - Version: **v0.2.1**
256
257
  - Phase 2 in progress
257
258
  - API intentionally minimal
258
259
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "protox-gatekeeper"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "Fail-closed Tor session enforcement for Python HTTP(S) traffic"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -20,6 +20,7 @@ classifiers = [
20
20
  "Programming Language :: Python :: 3.10",
21
21
  "Programming Language :: Python :: 3.11",
22
22
  "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
23
24
  "License :: OSI Approved :: MIT License",
24
25
  "Operating System :: OS Independent",
25
26
  ]