crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

checkacl.cc (736B)


      1 #include "dispatcher"
      2 
      3 bool Dispatcher::check_acl() {
      4     if (config.nallow()) {
      5 	bool allowed = false;
      6 	for (unsigned n = 0; n < config.nallow(); n++)
      7 	    if (ipmatch(clientfd().clientaddr().sin_addr, config.allow(n))) {
      8 		allowed = true;
      9 		break;
     10 	    }
     11 	if (!allowed) {
     12 	    msg("Not serving client IP " <<
     13 		inet2string(clientfd().clientaddr().sin_addr) <<
     14 		": no match in allow list\n");
     15 	    return false;
     16 	}
     17     }
     18     if (config.ndeny()) {
     19 	for (unsigned n = 0; n < config.ndeny(); n++)
     20 	    if (ipmatch(clientfd().clientaddr().sin_addr, config.deny(n))) {
     21 		msg("Not serving client IP " <<
     22 		    inet2string(clientfd().clientaddr().sin_addr) <<
     23 		    ": match in deny list\n");
     24 		return false;
     25 	    }
     26     }
     27     return true;
     28 }