Skip to main content

Fail-closed Tor session enforcement for Python HTTP(S) traffic

Reason this release was yanked:

Superseded

Project description

ProtoX GateKeeper

ProtoX GateKeeper is a small, opinionated Python library that enforces fail‑closed Tor routing for HTTP(S) traffic.

The goal is simple:

If Tor is not active and verified, nothing runs.

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.


What GateKeeper Is

  • A Tor‑verified HTTP client
  • A thin wrapper around requests.Session
  • Fail‑closed by default (no silent clearnet fallback)
  • Observable (exit IP, optional geo info)
  • Suitable for scripts, tooling, and automation

What GateKeeper Is NOT

  • ❌ A Tor controller
  • ❌ A crawler or scanner
  • ❌ An anonymization silver bullet
  • ❌ A replacement for Tor Browser

GateKeeper enforces transport routing only. You are still responsible for what you do with it.


Requirements

  • A locally running Tor client
  • SOCKS proxy enabled (default: 127.0.0.1:9150)

On Windows this usually means Tor Browser running in the background.


Installation

From source (development)

pip install -e .

(Recommended while developing or testing.)


Basic Usage

import logging
from protox_gatekeeper import GateKeeper

logging.basicConfig(
    level=logging.INFO,
    format='[%(levelname)s] %(name)s - %(message)s'
)

gk = GateKeeper(geo=True)

gk.download(
    "https://httpbin.org/bytes/1024",
    "downloads/test.bin"
)

Example output

[INFO] gatekeeper.core - Tor verified: 89.xxx.xxx.xxx -> 185.xxx.xxx.xxx
[INFO] gatekeeper.core - Tor exit location: Brandenburg, DE
[INFO] gatekeeper.core - [Tor 185.xxx.xxx.xxx] downloading https://httpbin.org/bytes/1024 -> downloads/test.bin

This confirms:

  • clearnet IP was measured
  • Tor routing was verified
  • all traffic used the Tor exit shown

API Overview

GateKeeper(...)

gk = GateKeeper(
    socks_port=9150,
    geo=False
)

Parameters:

  • socks_port (int) – Tor SOCKS port (default: 9150)
  • geo (bool) – Enable best‑effort Tor exit geolocation (optional)

Raises RuntimeError if Tor routing cannot be verified.


download(url, target_path)

Downloads a resource through the verified Tor session.

gk.download(url, target_path)
  • url – HTTP(S) URL
  • target_path – Full local file path (directories created automatically)

Design Principles

  • Fail closed: no Tor → no execution
  • Single verification point (during construction)
  • No global state
  • No logging configuration inside the library
  • Session reuse without re‑verification

Logging is emitted by the library, but configured by the application.


Logging

GateKeeper uses standard Python logging:

import logging
logging.basicConfig(level=logging.INFO)

The library does not call logging.basicConfig() internally.


Security Notes

  • Tor exit IPs may rotate over time
  • Geo information is best‑effort and may be unavailable (rate‑limits, CAPTCHAs)
  • GateKeeper guarantees routing, not anonymity

License

MIT License


Status

  • Version: v0.1.1
  • Phase 1 complete
  • API intentionally minimal

Future versions may add optional features such as:

  • circuit rotation
  • ControlPort support
  • higher‑level request helpers

Without breaking the core contract.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

protox_gatekeeper-0.1.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

protox_gatekeeper-0.1.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file protox_gatekeeper-0.1.1.tar.gz.

File metadata

  • Download URL: protox_gatekeeper-0.1.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for protox_gatekeeper-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b106b53907df39ed0a8dbf0f9681ee2f3a39d75594f35d76c79c12f857899ad8
MD5 c8f288125f92f81037a5f4093bcf579c
BLAKE2b-256 78d03f0208bab222fa0a9e8453994a3dc7ebd88cc47de1aaa162a96d1ec859a9

See more details on using hashes here.

File details

Details for the file protox_gatekeeper-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for protox_gatekeeper-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0e9591e21f52bc8083b3dc6dd38208ff9413394327b9ec2a2558517730f6eb71
MD5 07b0cd5168b6f8c7ffd061c391333a7f
BLAKE2b-256 4336e5b8f244841b7d406fa2c6013b5854667b12e26be0a25a9464759bb2882c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page