Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pydivert
- import time
- DELAY_MS = 200
- DELAY_SECONDS = DELAY_MS / 1000
- LIMIT = 20
- FILTER = "outbound and udp and udp.DstPort == 27015"
- queue = []
- with pydivert.WinDivert(FILTER) as w:
- print(f"[*] Fake lag active ({DELAY_SECONDS:.3f} sec) with packet limit {LIMIT}...")
- while True:
- try:
- packet = w.recv()
- send_time = time.time() + DELAY_SECONDS
- queue.append((send_time, packet))
- except Exception as e:
- print(f"Recv error: {e}")
- now = time.time()
- ready_packets = [p for p in queue if p[0] <= now]
- queue = [p for p in queue if p[0] > now]
- for _, pkt in ready_packets:
- try:
- w.send(pkt)
- except Exception as e:
- print(f"Send error: {e}")
- if len(queue) >= LIMIT:
- _, pkt = queue.pop()
- try:
- w.send(pkt)
- except Exception as e:
- print(f"Send error: {e}")
- time.sleep(0.001)
Advertisement
Add Comment
Please, Sign In to add comment