Refine APIs for auto-blocking

This commit is contained in:
Max Lv
2016-11-11 16:38:13 +08:00
parent 05450b51d4
commit 1ed725daf8
3 changed files with 21 additions and 5 deletions
+2 -3
View File
@@ -327,8 +327,7 @@ report_addr(int fd, int err_level)
peer_name = get_peer_name(fd);
if (peer_name != NULL) {
LOGE("failed to handshake with %s", peer_name);
// Block all requests from this IP, if the err# exceeds 128.
if (check_block_list(peer_name, err_level)) {
if (update_block_list(peer_name, err_level)) {
LOGE("add %s to block list", peer_name);
}
}
@@ -1499,7 +1498,7 @@ accept_cb(EV_P_ ev_io *w, int revents)
in_white_list = 1;
}
}
if (!in_white_list && check_block_list(peer_name, 0)) {
if (!in_white_list && check_block_list(peer_name)) {
LOGE("block all requests from %s", peer_name);
close(serverfd);
return;