Skip to content

Commit

Permalink
Do not allow more than 10 NTP requests per second to be served
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Feb 22, 2025
1 parent 39a852e commit 0d077a5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ntp/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#include "enums.h"
// threads
#include "signals.h"
// sleepms()
#include "timers.h"

uint64_t ntp_last_sync = 0u;
uint32_t ntp_root_delay = 0u;
Expand Down Expand Up @@ -269,6 +271,10 @@ static void request_process_loop(const int fd, const char *ipstr, const int prot
// Handle the request
ntp_reply(fd, &src_addr, src_addrlen, buf, &recv_time);
log_debug(DEBUG_NTP, "NTP reply sent");

// Sleep for 100 msec, this allows no more than 10 requests per
// second
sleepms(100);
}
}

Expand Down

0 comments on commit 0d077a5

Please sign in to comment.