actix-net
actix-net copied to clipboard
how to close connection immediately?
if client's connection of actix-web is probably attacking, how can I close it immediately and insert the address into a dynamic blocklist?
when a addr is in the blocklist, i don't what to parse the uri or headers from this addr, just close the connection without sending or receiving any of the message.
let listener = TcpListener::bind(...).await?;
while let (socket, addr) = listener.accept().await? {
if blocklist.contains(&addr) {
continue;
}
tokio::spawn(async move {
...
if connection_is_attacking() {
blocklist.insert(addr);
connection.close_immediately();
}
...
});
}