in core/src/main/java/org/apache/ftpserver/ipfilter/RemoteIpFilter.java [167:222]
public boolean accept(IoSession session) {
InetAddress address = ((InetSocketAddress) session.getRemoteAddress())
.getAddress();
switch (type) {
case ALLOW:
for (Subnet subnet : this) {
if (subnet.inSubnet(address)) {
if (LOGGER.isDebugEnabled()) {
LOGGER
.debug(
"Allowing connection from {} because it matches with the whitelist subnet {}",
address, subnet);
}
return true;
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER
.debug(
"Denying connection from {} because it does not match any of the whitelist subnets",
address);
}
return false;
case DENY:
if (isEmpty()) {
if (LOGGER.isDebugEnabled()) {
LOGGER
.debug(
"Allowing connection from {} because blacklist is empty",
address);
}
return true;
}
for (Subnet subnet : this) {
if (subnet.inSubnet(address)) {
if (LOGGER.isDebugEnabled()) {
LOGGER
.debug(
"Denying connection from {} because it matches with the blacklist subnet {}",
address, subnet);
}
return false;
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER
.debug(
"Allowing connection from {} because it does not match any of the blacklist subnets",
address);
}
return true;
default:
throw new IllegalStateException("Unknown or unimplemented filter type: "
+ type);
}
}