Class IpSubnetFilterRule
java.lang.Object
io.netty.handler.ipfilter.IpSubnetFilterRule
- All Implemented Interfaces:
IpFilterRule, Comparable<IpSubnetFilterRule>
public final class IpSubnetFilterRule
extends Object
implements IpFilterRule, Comparable<IpSubnetFilterRule>
Use this class to create rules for
RuleBasedIpFilter that group IP addresses into subnets.
Supports both, IPv4 and IPv6.-
Constructor Summary
ConstructorsConstructorDescriptionIpSubnetFilterRule(String ipAddress, int cidrPrefix, IpFilterRuleType ruleType) Create a newIpSubnetFilterRuleinstanceIpSubnetFilterRule(String ipAddressWithCidr, IpFilterRuleType ruleType) Create a newIpSubnetFilterRuleinstanceIpSubnetFilterRule(InetAddress ipAddress, int cidrPrefix, IpFilterRuleType ruleType) Create a newIpSubnetFilterRuleinstance -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(IpSubnetFilterRule ipSubnetFilterRule) booleanmatches(InetSocketAddress remoteAddress) ruleType()
-
Constructor Details
-
IpSubnetFilterRule
Create a newIpSubnetFilterRuleinstance- Parameters:
ipAddressWithCidr- IP Address with CIDR notation, e.g. (192.168.0.0/16) or (2001:db8::/32)ruleType-IpFilterRuleTypeto use
-
IpSubnetFilterRule
Create a newIpSubnetFilterRuleinstance- Parameters:
ipAddress- IP Address asStringcidrPrefix- CIDR PrefixruleType-IpFilterRuleTypeto use
-
IpSubnetFilterRule
Create a newIpSubnetFilterRuleinstance- Parameters:
ipAddress- IP Address asInetAddresscidrPrefix- CIDR PrefixruleType-IpFilterRuleTypeto use
-
-
Method Details
-
matches
- Specified by:
matchesin interfaceIpFilterRule- Returns:
- This method should return true if remoteAddress is valid according to your criteria. False otherwise.
-
ruleType
- Specified by:
ruleTypein interfaceIpFilterRule- Returns:
- This method should return
IpFilterRuleType.ACCEPTif allIpFilterRule.matches(InetSocketAddress)for whichIpFilterRule.matches(InetSocketAddress)returns true should the accepted. If you want to exclude all of those IP addresses thenIpFilterRuleType.REJECTshould be returned.
-
compareTo
- Specified by:
compareToin interfaceComparable<IpSubnetFilterRule>
-