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.3.tar.gz (4.6 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.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_tarpit-1.0.3.tar.gz
  • Upload date:
  • Size: 4.6 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.3.tar.gz
Algorithm Hash digest
SHA256 cbc22c200751414e5950928d3a53b088d77356c55164f1c7beba6d58f273825c
MD5 782a7ea43131d95aeebff7db973d685b
BLAKE2b-256 9830b79cb28c4b261f6f7a3911d5ea05d0e58bcb017e22673f92e5bccd19ba1d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastapi_tarpit-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.4 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 26f069ee9d60e845f481ac77a13cd736a855652e40dd97f94a4f723029fd0cc8
MD5 39ea0c31b9815cb794f6a0f9988c972e
BLAKE2b-256 2914d6cb4f90e057c867d5422560eedb21dab4114ae91851db4e3d54fd6fcbe2

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