- java.lang.Object
-
- io.netty5.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 forRuleBasedIpFilterthat group IP addresses into subnets. Supports both, IPv4 and IPv6.
-
-
Constructor Summary
Constructors Constructor Description IpSubnetFilterRule(String ipAddress, int cidrPrefix, IpFilterRuleType ruleType)IpSubnetFilterRule(InetAddress ipAddress, int cidrPrefix, IpFilterRuleType ruleType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(IpSubnetFilterRule ipSubnetFilterRule)booleanmatches(InetSocketAddress remoteAddress)IpFilterRuleTyperuleType()
-
-
-
Constructor Detail
-
IpSubnetFilterRule
public IpSubnetFilterRule(String ipAddress, int cidrPrefix, IpFilterRuleType ruleType)
-
IpSubnetFilterRule
public IpSubnetFilterRule(InetAddress ipAddress, int cidrPrefix, IpFilterRuleType ruleType)
-
-
Method Detail
-
matches
public boolean matches(InetSocketAddress remoteAddress)
- Specified by:
matchesin interfaceIpFilterRule- Returns:
- This method should return true if remoteAddress is valid according to your criteria. False otherwise.
-
ruleType
public IpFilterRuleType 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
public int compareTo(IpSubnetFilterRule ipSubnetFilterRule)
- Specified by:
compareToin interfaceComparable<IpSubnetFilterRule>
-
-