protox-gatekeeper 0.1.2__py3-none-any.whl → 0.2.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.
protox_gatekeeper/core.py CHANGED
@@ -69,6 +69,31 @@ class GateKeeper:
69
69
  """ Returns the Tor exit IP address. """
70
70
  return self.exit_ip
71
71
 
72
+ def get(self, url: str, **kwargs) -> requests.Response:
73
+ """
74
+ Passes a GET request to the Tor Gatekeeper.
75
+
76
+ Args:
77
+ url (str): The url to request.
78
+ **kwargs: Additional parameters to pass to the GET request.
79
+ """
80
+ logger.info(f'[Tor {self.tor_exit}] GET {url}')
81
+ return self._session.get(url=url, **kwargs)
82
+
83
+ def post(self, url: str, data=None, json=None,
84
+ **kwargs) -> requests.Response:
85
+ """
86
+ Passes a POST request to the Tor Gatekeeper.
87
+
88
+ Args:
89
+ url (str): The url to post to.
90
+ data (dict, optional): The data to post.
91
+ json (dict, optional): The json data to post.
92
+ **kwargs: Additional parameters to pass to the POST request.
93
+ """
94
+ logger.info(f'[Tor {self.tor_exit}] POST {url}')
95
+ return self._session.post(url=url, data=data, json=json, **kwargs)
96
+
72
97
  def download(self, url: str, target_path: str, timeout: int = 30,
73
98
  chunk_size: int = 8192):
74
99
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: protox-gatekeeper
3
- Version: 0.1.2
3
+ Version: 0.2.0
4
4
  Summary: Fail-closed Tor session enforcement for Python HTTP(S) traffic
5
5
  Author: Tom Erik Harnes
6
6
  License: MIT License
@@ -46,25 +46,24 @@ Dynamic: license-file
46
46
  [![Python versions](https://img.shields.io/pypi/pyversions/protox-gatekeeper.svg)](https://pypi.org/project/protox-gatekeeper/)
47
47
  [![License](https://img.shields.io/pypi/l/protox-gatekeeper.svg)](https://pypi.org/project/protox-gatekeeper/)
48
48
 
49
-
50
49
  # ProtoX GateKeeper
51
50
 
52
51
  **ProtoX GateKeeper** is a small, opinionated Python library that enforces
53
- **failclosed Tor routing** for HTTP(S) traffic.
52
+ **fail-closed Tor routing** for HTTP(S) traffic.
54
53
 
55
54
  The goal is simple:
56
55
 
57
56
  > If Tor is not active and verified, **nothing runs**.
58
57
 
59
- GateKeeper is designed to be *fireandforget*: create a client once, then perform network operations with a hard guarantee that traffic exits through the Tor network.
58
+ GateKeeper is designed to be *fire-and-forget*: create a client once, then perform network operations with a hard guarantee that traffic exits through the Tor network.
60
59
 
61
60
  ---
62
61
 
63
62
  ## What GateKeeper Is
64
63
 
65
- - A **Torverified HTTP client**
66
- - A thin wrapper around `requests.Session`
67
- - Failclosed by default (no silent clearnet fallback)
64
+ - A **Tor-verified HTTP client**
65
+ - A thin wrapper around `requests.Session` with safe helpers
66
+ - Fail-closed by default (no silent clearnet fallback)
68
67
  - Observable (exit IP, optional geo info)
69
68
  - Suitable for scripts, tooling, and automation
70
69
 
@@ -92,6 +91,12 @@ On Windows this usually means **Tor Browser** running in the background.
92
91
 
93
92
  ## Installation
94
93
 
94
+ ### From PyPI
95
+
96
+ ```bash
97
+ pip install protox-gatekeeper
98
+ ```
99
+
95
100
  ### From source (development)
96
101
 
97
102
  ```bash
@@ -136,6 +141,20 @@ This confirms:
136
141
 
137
142
  ---
138
143
 
144
+ ### HTTP requests
145
+
146
+ GateKeeper can also be used as a Tor-verified HTTP client:
147
+
148
+ ```python
149
+ with GateKeeper() as gk:
150
+ response = gk.get("https://httpbin.org/ip")
151
+ print(response.json())
152
+ ```
153
+
154
+ All requests are guaranteed to use the verified Tor session.
155
+
156
+ ---
157
+
139
158
  ## API Overview
140
159
 
141
160
  ### `GateKeeper(...)`
@@ -149,7 +168,7 @@ gk = GateKeeper(
149
168
 
150
169
  **Parameters**:
151
170
  - `socks_port` *(int)* – Tor SOCKS port (default: `9150`)
152
- - `geo` *(bool)* – Enable besteffort Tor exit geolocation (optional)
171
+ - `geo` *(bool)* – Enable best-effort Tor exit geolocation (optional)
153
172
 
154
173
  Raises `RuntimeError` if Tor routing cannot be verified.
155
174
 
@@ -168,13 +187,37 @@ gk.download(url, target_path)
168
187
 
169
188
  ---
170
189
 
190
+ ### `get(url, **kwargs)`
191
+
192
+ Performs a Tor-verified HTTP GET request.
193
+
194
+ ```python
195
+ response = gk.get(url, timeout=10)
196
+ ```
197
+
198
+ Returns a standard `requests.Response`.
199
+
200
+ ---
201
+
202
+ ### `post(url, data=None, json=None, **kwargs)`
203
+
204
+ Performs a Tor-verified HTTP POST request.
205
+
206
+ ```python
207
+ response = gk.post(url, json={"key": "value"})
208
+ ```
209
+
210
+ Returns a standard `requests.Response`.
211
+
212
+ ---
213
+
171
214
  ## Design Principles
172
215
 
173
216
  - **Fail closed**: no Tor → no execution
174
217
  - **Single verification point** (during construction)
175
218
  - **No global state**
176
219
  - **No logging configuration inside the library**
177
- - **Session reuse without reverification**
220
+ - **Session reuse without re-verification**
178
221
 
179
222
  Logging is emitted by the library, but **configured by the application**.
180
223
 
@@ -196,8 +239,8 @@ The library does **not** call `logging.basicConfig()` internally.
196
239
  ## Security Notes
197
240
 
198
241
  - Tor exit IPs may rotate over time
199
- - Geo information is besteffort and may be unavailable (ratelimits, CAPTCHAs)
200
- - GateKeeper guarantees routing, not anonymity
242
+ - Geo information is best-effort and may be unavailable (rate-limits, CAPTCHAs)
243
+ - GateKeeper guarantees transport routing, not anonymity
201
244
 
202
245
  ---
203
246
 
@@ -209,14 +252,13 @@ MIT License
209
252
 
210
253
  ## Status
211
254
 
212
- - Version: **v0.1.2**
213
- - Phase 1 complete
255
+ - Version: **v0.2.0**
256
+ - Phase 2 in progress
214
257
  - API intentionally minimal
215
258
 
216
259
  Future versions may add optional features such as:
217
260
  - circuit rotation
218
261
  - ControlPort support
219
- - higherlevel request helpers
262
+ - higher-level request helpers
220
263
 
221
264
  Without breaking the core contract.
222
-
@@ -1,11 +1,11 @@
1
1
  protox_gatekeeper/__init__.py,sha256=HisDC-NCbMlkrNkrLRdANILoBqw03ssqFp6BTsXm6Us,75
2
- protox_gatekeeper/core.py,sha256=Z4LEY1WcSbjMDU3OS1rf7kPOTry9NJq5-quzACxPvKg,3062
2
+ protox_gatekeeper/core.py,sha256=SALDt7IhalzkOBQ2amjsmcMTf3IMiZYaWqQDU9B8FLo,4010
3
3
  protox_gatekeeper/geo.py,sha256=AdjHfZqjP0w5ujHFI_WV7c5XWnDTzqkVL32KeJQojYo,641
4
4
  protox_gatekeeper/ops.py,sha256=Kmr8lU8Ohe81URHHNUlUJ0S71aZ1uGgyiztLBPsOUO4,690
5
5
  protox_gatekeeper/session.py,sha256=0qGZF44EHr7CP-bSM0awtq4F-5LWiIb4w87mV7Yocfk,235
6
6
  protox_gatekeeper/verify.py,sha256=bsHK3f16sRV8cHo30AY82SB1vb_Svu-US7IhghTSQ6E,452
7
- protox_gatekeeper-0.1.2.dist-info/licenses/LICENSE,sha256=EE75Vy9_csDDBRXBF4uVQWxYu1YpzXTcmaeuVcPOjl4,1093
8
- protox_gatekeeper-0.1.2.dist-info/METADATA,sha256=MmHERPyR-Jx8UnAM8BhmpIe6IKrgk7-k_44fN7l8Jh8,6154
9
- protox_gatekeeper-0.1.2.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
10
- protox_gatekeeper-0.1.2.dist-info/top_level.txt,sha256=KOVL4YUpiWQLGjCvx2SmP8VSsA6hPcEvKCd4k6kPl8s,18
11
- protox_gatekeeper-0.1.2.dist-info/RECORD,,
7
+ protox_gatekeeper-0.2.0.dist-info/licenses/LICENSE,sha256=EE75Vy9_csDDBRXBF4uVQWxYu1YpzXTcmaeuVcPOjl4,1093
8
+ protox_gatekeeper-0.2.0.dist-info/METADATA,sha256=0V4NABFLpC2NOWg_2v6gLWJTqfqRhrBP6_2h8GcJ4Uc,6890
9
+ protox_gatekeeper-0.2.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
10
+ protox_gatekeeper-0.2.0.dist-info/top_level.txt,sha256=KOVL4YUpiWQLGjCvx2SmP8VSsA6hPcEvKCd4k6kPl8s,18
11
+ protox_gatekeeper-0.2.0.dist-info/RECORD,,