traffic-guard
High-throughput traffic and attack defense gate for incoming web traffic with zero required dependencies, wire-order analysis, and TypeSafe System One acceleration.
pip install traffic-guard
Quick start
from traffic_guard import trafficguard
decision = await trafficguard(request)
if decision.should_block:
return Response(status_code=403, content="Forbidden")
trafficguard(request) inspects headers, wire sequence order, payload entropy, and velocity signals in under 25 µs. Returns action, should_block, should_tarpit, risk_score, and calibrated reasons.
FastAPI / Starlette middleware
from fastapi import FastAPI
from traffic_guard import TrafficGuardMiddleware
app = FastAPI()
app.add_middleware(
TrafficGuardMiddleware,
policy="balanced",
allow_good_bots=True,
honeypot_paths=["/__tg_trap"],
whitelisted_paths=["/healthz"],
)
Advanced defense patterns implemented
- Header Order Sequence Analysis: Real Chromium browsers send
HostbeforeUser-Agentand Client Hints (sec-ch-ua) in a strict order. Bots forging user-agents in Python/cURL exhibit sequence disorder. - Stateless HMAC Tokens & Velocity Tracking: Signs a signed
__trafficguardcookie via HMAC-SHA256 tracking request velocity in 10-second sliding windows with zero database dependency. - Silent Proof-of-Work (PoW) Micro-Challenge: Serves an inline 1.2 KB HashCash puzzle. Legitimate browsers solve it in 15–30 ms; automated CLI scrapers cannot execute JS.
- Tarpitting (Slowdown Defense): Configurable artificial latency delay for scrapers to exhaust their concurrency pools.
- Canary Honeypot Traps: Immediate blocking of crawlers that scrape invisible honeypot URLs.
Empirical benchmark
Evaluated on 25 canonical golden test cases (bench/dataset.json):
| Metric | In-Tree Zero-Dep Engine (Python) | TypeSafe Cloud Tier (Jev-latest) |
|---|---|---|
| Category Classification | 100.0% | 100.0% |
| Action Accuracy | 100.0% | 100.0% |
| Attack Block Rate (Recall) | 100.0% | 100.0% |
| Human False Positive Rate | 0.0% | 0.0% |
| Good Bot Passthrough Rate | 100.0% | 100.0% |
| Mean Latency | 20 µs (0.02 ms) | ~250 ms |
| p95 Latency | 39 µs | ~320 ms |
| External Dependencies | 0 required | Optional typesafe-sdk |
License
MIT © Hemanth.HM
Metadata
Release files for traffic-guard 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| traffic_guard-0.1.0.tar.gz | 17.3 kB | Without provenance | Details for traffic_guard-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| traffic_guard-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for traffic_guard-0.1.0-py3-none-any.whl |
Total release size: 37.3 kB
Release files / traffic_guard-0.1.0.tar.gz
| Download URL | traffic_guard-0.1.0.tar.gz |
|---|---|
| Size | 17.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b866f1e3aaca341c314177e55e09f2e4fdeca899176a3745ddf9bbf9f5102609
|
|
BLAKE2b-256 checksum How to use checksums |
9067c0ac787291de97582b82b0a48d80d9b57884e6542b879e39e11ac5c1d345
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / traffic_guard-0.1.0-py3-none-any.whl
| Download URL | traffic_guard-0.1.0-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3ff903ef7657c0cb8ffa4430d3d741a7e4d45ebc1bef00935862ae33124ae09
|
|
BLAKE2b-256 checksum How to use checksums |
01fe5c8e5a16dea49532edcd3eaa10052013a25bcc95521a20f58fc8af6b5291
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for traffic-guard 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.