Skip to content

FastAPI middleware that purposely delays incoming connections on unused routes

License

Notifications You must be signed in to change notification settings

thus/fastapi-tarpit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

FastAPI middleware that purposely delays incoming connections on unused routes

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages