Refine ACL logic in local.c

This commit is contained in:
Mygod
2016-12-29 06:23:02 -06:00
committed by Max Lv
parent b9e19bfdb7
commit 422b9d3df2
+18 -20
View File
@@ -649,26 +649,24 @@ server_recv_cb(EV_P_ ev_io *w, int revents)
if (acl) {
int host_match = acl_match_host(host);
int ip_match = acl_match_host(ip);
int bypass = get_acl_mode() == WHITE_LIST;
if (get_acl_mode() == BLACK_LIST) {
if (ip_match > 0)
bypass = 1; // bypass IPs in black list
if (host_match > 0)
bypass = 1; // bypass hostnames in black list
else if (host_match < 0)
bypass = 0; // proxy hostnames in white list
} else if (get_acl_mode() == WHITE_LIST) {
if (ip_match < 0)
bypass = 0; // proxy IPs in white list
if (host_match < 0)
bypass = 0; // proxy hostnames in white list
else if (host_match > 0)
bypass = 1; // bypass hostnames in black list
int bypass = 0;
if (host_match > 0)
bypass = 1; // bypass hostnames in black list
else if (host_match < 0)
bypass = 0; // proxy hostnames in white list
else {
int ip_match = acl_match_host(ip);
switch (get_acl_mode()) {
case BLACK_LIST:
if (ip_match > 0)
bypass = 1; // bypass IPs in black list
break;
case WHITE_LIST:
bypass = 1;
if (ip_match < 0)
bypass = 0; // proxy IPs in white list
break;
}
}
if (bypass) {