Last active
June 25, 2021 16:15
-
-
Save evindunn/efb785ae41dfec0bae899dd399d6f461 to your computer and use it in GitHub Desktop.
rate-limit-test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests | |
import time | |
from sys import argv | |
from threading import Thread | |
URL = argv[-1] | |
def worker(i, url): | |
start_time = time.time() | |
res = requests.get(url) | |
req_time = round((time.time() - start_time) * 1000) | |
print("Request {:02d}: {} | {}ms".format(i, res.status_code, req_time)) | |
threads = list() | |
for i in range(0, 20): | |
t = Thread(target=worker, args=[i, URL]) | |
t.start() | |
threads.append(t) | |
[t.join() for t in threads] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
firewall-cmd \ | |
--permanent \ | |
--direct \ | |
--add-rule ipv4 filter INPUT_direct 0 -p tcp --match --dports 80,443 --state NEW -m recent --set | |
firewall-cmd \ | |
--permanent \ | |
--direct \ | |
--add-rule ipv4 filter INPUT_direct 1 -p tcp --match --dports 80,443 --state NEW -m recent --update --seconds 1 --hitcount 10 -j REJECT --reject-with tcp-reset | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment