implement IPv4 range bans

This commit is contained in:
Martin Michelsen
2024-04-21 01:12:51 -07:00
parent 79bf6b3fa9
commit de42135532
18 changed files with 296 additions and 71 deletions
+9 -4
View File
@@ -235,12 +235,17 @@ void IPStackSimulator::disconnect_client(struct bufferevent* bev) {
void IPStackSimulator::dispatch_on_listen_accept(
struct evconnlistener* listener, evutil_socket_t fd,
struct sockaddr* address, int socklen, void* ctx) {
reinterpret_cast<IPStackSimulator*>(ctx)->on_listen_accept(
listener, fd, address, socklen);
reinterpret_cast<IPStackSimulator*>(ctx)->on_listen_accept(listener, fd, address, socklen);
}
void IPStackSimulator::on_listen_accept(struct evconnlistener* listener,
evutil_socket_t fd, struct sockaddr*, int) {
void IPStackSimulator::on_listen_accept(struct evconnlistener* listener, evutil_socket_t fd, struct sockaddr*, int) {
struct sockaddr_storage remote_addr;
get_socket_addresses(fd, nullptr, &remote_addr);
if (this->state->banned_ipv4_ranges->check(remote_addr)) {
close(fd);
return;
}
int listen_fd = evconnlistener_get_fd(listener);
const ListeningSocket* listening_socket;