Package io.netty.handler.ipfilter
Class IpSubnetFilterRule
- java.lang.Object
-
- io.netty.handler.ipfilter.IpSubnetFilterRule
-
- All Implemented Interfaces:
IpFilterRule
,java.lang.Comparable<IpSubnetFilterRule>
public final class IpSubnetFilterRule extends java.lang.Object implements IpFilterRule, java.lang.Comparable<IpSubnetFilterRule>
Use this class to create rules forRuleBasedIpFilter
that group IP addresses into subnets. Supports both, IPv4 and IPv6.
-
-
Constructor Summary
Constructors Constructor Description IpSubnetFilterRule(java.lang.String ipAddress, int cidrPrefix, IpFilterRuleType ruleType)
Create a newIpSubnetFilterRule
instanceIpSubnetFilterRule(java.lang.String ipAddressWithCidr, IpFilterRuleType ruleType)
Create a newIpSubnetFilterRule
instanceIpSubnetFilterRule(java.net.InetAddress ipAddress, int cidrPrefix, IpFilterRuleType ruleType)
Create a newIpSubnetFilterRule
instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(IpSubnetFilterRule ipSubnetFilterRule)
boolean
matches(java.net.InetSocketAddress remoteAddress)
IpFilterRuleType
ruleType()
-
-
-
Constructor Detail
-
IpSubnetFilterRule
public IpSubnetFilterRule(java.lang.String ipAddressWithCidr, IpFilterRuleType ruleType)
Create a newIpSubnetFilterRule
instance- Parameters:
ipAddressWithCidr
- IP Address with CIDR notation, e.g. (192.168.0.0/16) or (2001:db8::/32)ruleType
-IpFilterRuleType
to use
-
IpSubnetFilterRule
public IpSubnetFilterRule(java.lang.String ipAddress, int cidrPrefix, IpFilterRuleType ruleType)
Create a newIpSubnetFilterRule
instance- Parameters:
ipAddress
- IP Address asString
cidrPrefix
- CIDR PrefixruleType
-IpFilterRuleType
to use
-
IpSubnetFilterRule
public IpSubnetFilterRule(java.net.InetAddress ipAddress, int cidrPrefix, IpFilterRuleType ruleType)
Create a newIpSubnetFilterRule
instance- Parameters:
ipAddress
- IP Address asInetAddress
cidrPrefix
- CIDR PrefixruleType
-IpFilterRuleType
to use
-
-
Method Detail
-
matches
public boolean matches(java.net.InetSocketAddress remoteAddress)
- Specified by:
matches
in interfaceIpFilterRule
- Returns:
- This method should return true if remoteAddress is valid according to your criteria. False otherwise.
-
ruleType
public IpFilterRuleType ruleType()
- Specified by:
ruleType
in interfaceIpFilterRule
- Returns:
- This method should return
IpFilterRuleType.ACCEPT
if allIpFilterRule.matches(InetSocketAddress)
for whichIpFilterRule.matches(InetSocketAddress)
returns true should the accepted. If you want to exclude all of those IP addresses thenIpFilterRuleType.REJECT
should be returned.
-
compareTo
public int compareTo(IpSubnetFilterRule ipSubnetFilterRule)
- Specified by:
compareTo
in interfacejava.lang.Comparable<IpSubnetFilterRule>
-
-