configurable tarpit delay

This commit is contained in:
serxoz 2022-12-21 12:53:27 +01:00
parent b86f811bf9
commit 89816437e8

View File

@ -17,6 +17,9 @@ use std::{env, io};
use tokio::net::UdpSocket;
use tokio::time::{sleep, Duration};
// delay seconds for tarpit feature
static TARPIT_DELAY: u64 = 4;
struct Server {
socket: UdpSocket,
buf: Vec<u8>,
@ -44,7 +47,7 @@ impl Server {
match msg {
msg if msg.contains("OPTIONS") => {
// esperar - tarpit!
sleep(Duration::from_secs(1)).await;
sleep(Duration::from_secs(TARPIT_DELAY)).await;
let options = Options::parse(&msg);
// respondemos con un 404 not found
@ -74,7 +77,7 @@ impl Server {
},
msg if msg.contains("REGISTER") => {
// esperar - tarpit!
sleep(Duration::from_secs(1)).await;
sleep(Duration::from_secs(TARPIT_DELAY)).await;
let register = Register::parse(&msg);