Skip to main content

FastAPI middleware that purposely delays incoming connections on unused routes

Project description

FastAPI Tarpit

FastAPI middleware that purposely delays incoming connections on unused routes.

Definition of a tarpit from Wikipedia:

A tarpit is a service on a computer system (usually a server) that purposely delays incoming connections. The technique was developed as a defense against a computer worm, and the idea is that network abuses such as spamming or broad scanning are less effective, and therefore less attractive, if they take too long. The concept is analogous with a tar pit, in which animals can get bogged down and slowly sink under the surface, like in a swamp.

Installation

Install the package using pip:

pip install fastapi-tarpit

Usage

from fastapi import FastAPI
from fastapi_tarpit import HTTPTarpitMiddleware

app = FastAPI()

app.add_middleware(HTTPTarpitMiddleware)

@app.get("/foo")
async def foobar():
    return {"foo": "bar"}

The code above triggers the tarpit on any other routes than /foo, and routes related to docs.

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

fastapi_tarpit-1.0.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

fastapi_tarpit-1.0.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_tarpit-1.0.2.tar.gz.

File metadata

  • Download URL: fastapi_tarpit-1.0.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for fastapi_tarpit-1.0.2.tar.gz
Algorithm Hash digest
SHA256 80038dc77f31d2ff0984365f0161226dd84428e7ebe8ad6e40b918d7dc81b9ec
MD5 6258a15d65dcac46f734cbf61599f59f
BLAKE2b-256 ca50eb4abfcbf43558a7226782030dae6869d841a1ee9659f99e234b6ccddf59

See more details on using hashes here.

File details

Details for the file fastapi_tarpit-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: fastapi_tarpit-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for fastapi_tarpit-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9d84a87ef72cd491965c83c3a11e282a3fa686f8de780a0fce8201dfb2e2b305
MD5 8f2bc6a60ba0a4739c27ff240eddaef5
BLAKE2b-256 bd9fa3d74222e134c2dd8ba9b101805fdabb14926238644e68a250354c06ccb6

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