Skip to content

Commit c603773

Browse files
committed
add rate-limited messages about unknown clients
1 parent 5e9f7d1 commit c603773

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/lib/io/master.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ typedef struct {
4747
uint32_t num_connections; //!< number of dynamic connections
4848
uint32_t num_pending_packets; //!< number of pending packets
4949
uint64_t client_id; //!< Unique client identifier.
50+
fr_rate_limit_t unknown_client;
5051
} fr_io_thread_t;
5152

5253
/** A saved packet
@@ -1592,15 +1593,21 @@ static ssize_t mod_read(fr_listen_t *li, void **packet_ctx, fr_time_t *recv_time
15921593
state = PR_CLIENT_PENDING;
15931594

15941595
} else {
1596+
char const *msg;
1597+
15951598
ignore:
15961599
if (accept_fd < 0) {
1597-
DEBUG("proto_%s - ignoring packet from unknown client IP address %pV",
1598-
inst->app_io->common.name, fr_box_ipaddr(address.socket.inet.src_ipaddr));
1600+
msg = "packet";
15991601
} else {
1600-
DEBUG("proto_%s - ignoring connection attempt from unknown client IP address %pV",
1601-
inst->app_io->common.name, fr_box_ipaddr(address.socket.inet.src_ipaddr));
1602+
msg = "connection attempt";
16021603
close(accept_fd);
16031604
}
1605+
1606+
DEBUG("proto_%s - ignoring %s from unknown client IP address %pV",
1607+
inst->app_io->common.name, msg, fr_box_ipaddr(address.socket.inet.src_ipaddr));
1608+
1609+
RATE_LIMIT_LOCAL(&thread->unknown_client, ERROR, "proto_%s - ignoring %s from unknown client IP address %pV",
1610+
inst->app_io->common.name, msg, fr_box_ipaddr(address.socket.inet.src_ipaddr));
16041611
return 0;
16051612
}
16061613

0 commit comments

Comments
 (0)