protox-gatekeeper 0.1.2__tar.gz → 0.2.0__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.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
-
@@ -2,25 +2,24 @@
2
2
  [![Python versions](https://img.shields.io/pypi/pyversions/protox-gatekeeper.svg)](https://pypi.org/project/protox-gatekeeper/)
3
3
  [![License](https://img.shields.io/pypi/l/protox-gatekeeper.svg)](https://pypi.org/project/protox-gatekeeper/)
4
4
 
5
-
6
5
  # ProtoX GateKeeper
7
6
 
8
7
  **ProtoX GateKeeper** is a small, opinionated Python library that enforces
9
- **failclosed Tor routing** for HTTP(S) traffic.
8
+ **fail-closed Tor routing** for HTTP(S) traffic.
10
9
 
11
10
  The goal is simple:
12
11
 
13
12
  > If Tor is not active and verified, **nothing runs**.
14
13
 
15
- 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.
14
+ 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.
16
15
 
17
16
  ---
18
17
 
19
18
  ## What GateKeeper Is
20
19
 
21
- - A **Torverified HTTP client**
22
- - A thin wrapper around `requests.Session`
23
- - Failclosed by default (no silent clearnet fallback)
20
+ - A **Tor-verified HTTP client**
21
+ - A thin wrapper around `requests.Session` with safe helpers
22
+ - Fail-closed by default (no silent clearnet fallback)
24
23
  - Observable (exit IP, optional geo info)
25
24
  - Suitable for scripts, tooling, and automation
26
25
 
@@ -48,6 +47,12 @@ On Windows this usually means **Tor Browser** running in the background.
48
47
 
49
48
  ## Installation
50
49
 
50
+ ### From PyPI
51
+
52
+ ```bash
53
+ pip install protox-gatekeeper
54
+ ```
55
+
51
56
  ### From source (development)
52
57
 
53
58
  ```bash
@@ -92,6 +97,20 @@ This confirms:
92
97
 
93
98
  ---
94
99
 
100
+ ### HTTP requests
101
+
102
+ GateKeeper can also be used as a Tor-verified HTTP client:
103
+
104
+ ```python
105
+ with GateKeeper() as gk:
106
+ response = gk.get("https://httpbin.org/ip")
107
+ print(response.json())
108
+ ```
109
+
110
+ All requests are guaranteed to use the verified Tor session.
111
+
112
+ ---
113
+
95
114
  ## API Overview
96
115
 
97
116
  ### `GateKeeper(...)`
@@ -105,7 +124,7 @@ gk = GateKeeper(
105
124
 
106
125
  **Parameters**:
107
126
  - `socks_port` *(int)* – Tor SOCKS port (default: `9150`)
108
- - `geo` *(bool)* – Enable besteffort Tor exit geolocation (optional)
127
+ - `geo` *(bool)* – Enable best-effort Tor exit geolocation (optional)
109
128
 
110
129
  Raises `RuntimeError` if Tor routing cannot be verified.
111
130
 
@@ -124,13 +143,37 @@ gk.download(url, target_path)
124
143
 
125
144
  ---
126
145
 
146
+ ### `get(url, **kwargs)`
147
+
148
+ Performs a Tor-verified HTTP GET request.
149
+
150
+ ```python
151
+ response = gk.get(url, timeout=10)
152
+ ```
153
+
154
+ Returns a standard `requests.Response`.
155
+
156
+ ---
157
+
158
+ ### `post(url, data=None, json=None, **kwargs)`
159
+
160
+ Performs a Tor-verified HTTP POST request.
161
+
162
+ ```python
163
+ response = gk.post(url, json={"key": "value"})
164
+ ```
165
+
166
+ Returns a standard `requests.Response`.
167
+
168
+ ---
169
+
127
170
  ## Design Principles
128
171
 
129
172
  - **Fail closed**: no Tor → no execution
130
173
  - **Single verification point** (during construction)
131
174
  - **No global state**
132
175
  - **No logging configuration inside the library**
133
- - **Session reuse without reverification**
176
+ - **Session reuse without re-verification**
134
177
 
135
178
  Logging is emitted by the library, but **configured by the application**.
136
179
 
@@ -152,8 +195,8 @@ The library does **not** call `logging.basicConfig()` internally.
152
195
  ## Security Notes
153
196
 
154
197
  - Tor exit IPs may rotate over time
155
- - Geo information is besteffort and may be unavailable (ratelimits, CAPTCHAs)
156
- - GateKeeper guarantees routing, not anonymity
198
+ - Geo information is best-effort and may be unavailable (rate-limits, CAPTCHAs)
199
+ - GateKeeper guarantees transport routing, not anonymity
157
200
 
158
201
  ---
159
202
 
@@ -165,14 +208,13 @@ MIT License
165
208
 
166
209
  ## Status
167
210
 
168
- - Version: **v0.1.2**
169
- - Phase 1 complete
211
+ - Version: **v0.2.0**
212
+ - Phase 2 in progress
170
213
  - API intentionally minimal
171
214
 
172
215
  Future versions may add optional features such as:
173
216
  - circuit rotation
174
217
  - ControlPort support
175
- - higherlevel request helpers
218
+ - higher-level request helpers
176
219
 
177
220
  Without breaking the core contract.
178
-
@@ -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
-
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "protox-gatekeeper"
7
- version = "0.1.2"
7
+ version = "0.2.0"
8
8
  description = "Fail-closed Tor session enforcement for Python HTTP(S) traffic"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -34,3 +34,8 @@ authors = [
34
34
  Homepage = "https://github.com/ProtoXCode/protox-gatekeeper"
35
35
  Repository = "https://github.com/ProtoXCode/protox-gatekeeper"
36
36
  Issues = "https://github.com/ProtoXCode/protox-gatekeeper/issues"
37
+
38
+ [tool.pytest.ini_options]
39
+ markers = [
40
+ "integration: requires Tor running locally"
41
+ ]