From 8ee3112ca09fd70a50c2159629b40700beb2d5c3 Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Fri, 27 Feb 2026 23:37:44 +0330 Subject: first client ver --- broadd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'broadd.c') diff --git a/broadd.c b/broadd.c index cef3531..44c162a 100644 --- a/broadd.c +++ b/broadd.c @@ -59,7 +59,7 @@ #if 1 // max buffer size #define UDP_BUFS 1024 - #define TCP_BUFS 8192 + #define TCP_BUFS 16384 // rate limit: BUFS bytes / RLM seconds #define RATE_LIMIT_S 1 @@ -72,6 +72,9 @@ // max age for timestamped message #define DROP_OLD 5 + + // set to 0 to enable ratelimit + #define DISABLE_RATELIMIT 1 #endif // ============================== @@ -865,12 +868,12 @@ int main(int argc, char** argv) { } else if (buf[ 0 ] == 'M' && rd >= 9) { // M: broadcast with password - if (likely(now - clients[ j ].last_rl >= env_rate_limit_s)) { + if (likely(now - clients[ j ].last_rl >= env_rate_limit_s) && !DISABLE_RATELIMIT) { clients[ j ].last_rl = now; clients[ j ].rl_bytes = 0; } int plen = rd - 1; - if (unlikely(clients[ j ].rl_bytes + plen > env_bufs)) { + if (unlikely(clients[ j ].rl_bytes + plen > env_bufs) && !DISABLE_RATELIMIT) { onlytcp(write(clients[ j ].fd, "Rate\n", 5)); onlyudp(sendto(sock, "Rate\n", 5, 0, (struct sockaddr*) &udp_src, udp_srclen)); } else { -- cgit v1.2.3