Top Description Inners Fields Constructors Methods
io.netty.handler.ipfilter

public final Class IpSubnetFilterRule

extends Object
implements IpFilterRule, Comparable<IpSubnetFilterRule>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable, io.netty.handler.ipfilter.IpFilterRule
Imports
io.netty.util.NetUtil, io.netty.util.internal.ObjectUtil, .SocketUtils, java.math.BigInteger, java.net.Inet4Address, .Inet6Address, .InetAddress, .InetSocketAddress, .UnknownHostException

Use this class to create rules for RuleBasedIpFilter that group IP addresses into subnets. Supports both, IPv4 and IPv6.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final IpFilterRule
private final String

Constructor Summary

AccessConstructor and Description
public
IpSubnetFilterRule(String ipAddress, int cidrPrefix, IpFilterRuleType ruleType)

public
IpSubnetFilterRule(InetAddress ipAddress, int cidrPrefix, IpFilterRuleType ruleType)

Method Summary

Modifier and TypeMethod and Description
private static int
compareInt(int x, int y)

Equivalent to Integer#compare(int, int)

public int
compareTo(IpSubnetFilterRule
the object to be compared.
ipSubnetFilterRule
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.
pack-priv int

Returns:

0 if IP Address match else difference index.
compareTo
(InetSocketAddress inetSocketAddress)

Implements java.lang.Comparable.compareTo.

It'll compare IP address with Ip4SubnetFilterRule#networkAddress or Ip6SubnetFilterRule#networkAddress.
pack-priv IpFilterRule
pack-priv String
getIpAddress()

Get IP Address of this rule

public boolean
public IpFilterRuleType
private static IpFilterRule
selectFilterRule(InetAddress ipAddress, int cidrPrefix, IpFilterRuleType ruleType)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

filterRuleback to summary
private final IpFilterRule filterRule
ipAddressback to summary
private final String ipAddress

Constructor Detail

IpSubnetFilterRuleback to summary
public IpSubnetFilterRule(String ipAddress, int cidrPrefix, IpFilterRuleType ruleType)
IpSubnetFilterRuleback to summary
public IpSubnetFilterRule(InetAddress ipAddress, int cidrPrefix, IpFilterRuleType ruleType)

Method Detail

compareIntback to summary
private static int compareInt(int x, int y)

Equivalent to Integer#compare(int, int)

compareToback to summary
public int compareTo(IpSubnetFilterRule ipSubnetFilterRule)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
ipSubnetFilterRule:IpSubnetFilterRule

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
compareToback to summary
pack-priv int compareTo(InetSocketAddress inetSocketAddress)

Implements java.lang.Comparable.compareTo.

It'll compare IP address with Ip4SubnetFilterRule#networkAddress or Ip6SubnetFilterRule#networkAddress.

Parameters
inetSocketAddress:InetSocketAddress

InetSocketAddress to match

Returns:int

0 if IP Address match else difference index.

getFilterRuleback to summary
pack-priv IpFilterRule getFilterRule()

Ip4SubnetFilterRule or Ip6SubnetFilterRule

getIpAddressback to summary
pack-priv String getIpAddress()

Get IP Address of this rule

matchesback to summary
public boolean matches(InetSocketAddress remoteAddress)

Implements io.netty.handler.ipfilter.IpFilterRule.matches.

Returns:boolean

Doc from io.netty.handler.ipfilter.IpFilterRule.matches.

This method should return true if remoteAddress is valid according to your criteria. False otherwise.

Annotations
@Override
ruleTypeback to summary
public IpFilterRuleType ruleType()

Implements io.netty.handler.ipfilter.IpFilterRule.ruleType.

Returns:IpFilterRuleType

Doc from io.netty.handler.ipfilter.IpFilterRule.ruleType.

This method should return IpFilterRuleType#ACCEPT if all IpFilterRule#matches(InetSocketAddress) for which matches(InetSocketAddress) returns true should the accepted. If you want to exclude all of those IP addresses then IpFilterRuleType#REJECT should be returned.

Annotations
@Override
selectFilterRuleback to summary
private static IpFilterRule selectFilterRule(InetAddress ipAddress, int cidrPrefix, IpFilterRuleType ruleType)
io.netty.handler.ipfilter back to summary

pack-priv final Class IpSubnetFilterRule.Ip4SubnetFilterRule

extends Object
implements IpFilterRule
Class Inheritance
  • java.lang.Object
  • io.netty.handler.ipfilter.IpSubnetFilterRule.Ip4SubnetFilterRule
All Implemented Interfaces
io.netty.handler.ipfilter.IpFilterRule

Field Summary

Modifier and TypeField and Description
private final int
private final IpFilterRuleType
private final int

Constructor Summary

AccessConstructor and Description
private
Ip4SubnetFilterRule(Inet4Address ipAddress, int cidrPrefix, IpFilterRuleType ruleType)

Method Summary

Modifier and TypeMethod and Description
public boolean
private static int
prefixToSubnetMask(int cidrPrefix)

public IpFilterRuleType
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

networkAddressback to summary
private final int networkAddress
ruleTypeback to summary
private final IpFilterRuleType ruleType
subnetMaskback to summary
private final int subnetMask

Constructor Detail

Ip4SubnetFilterRuleback to summary
private Ip4SubnetFilterRule(Inet4Address ipAddress, int cidrPrefix, IpFilterRuleType ruleType)

Method Detail

matchesback to summary
public boolean matches(InetSocketAddress remoteAddress)

Implements io.netty.handler.ipfilter.IpFilterRule.matches.

Returns:boolean

Doc from io.netty.handler.ipfilter.IpFilterRule.matches.

This method should return true if remoteAddress is valid according to your criteria. False otherwise.

Annotations
@Override
prefixToSubnetMaskback to summary
private static int prefixToSubnetMask(int cidrPrefix)
ruleTypeback to summary
public IpFilterRuleType ruleType()

Implements io.netty.handler.ipfilter.IpFilterRule.ruleType.

Returns:IpFilterRuleType

Doc from io.netty.handler.ipfilter.IpFilterRule.ruleType.

This method should return IpFilterRuleType#ACCEPT if all IpFilterRule#matches(InetSocketAddress) for which matches(InetSocketAddress) returns true should the accepted. If you want to exclude all of those IP addresses then IpFilterRuleType#REJECT should be returned.

Annotations
@Override
io.netty.handler.ipfilter back to summary

pack-priv final Class IpSubnetFilterRule.Ip6SubnetFilterRule

extends Object
implements IpFilterRule
Class Inheritance
  • java.lang.Object
  • io.netty.handler.ipfilter.IpSubnetFilterRule.Ip6SubnetFilterRule
All Implemented Interfaces
io.netty.handler.ipfilter.IpFilterRule

Field Summary

Modifier and TypeField and Description
private static final BigInteger
private final BigInteger
private final IpFilterRuleType
private final BigInteger

Constructor Summary

AccessConstructor and Description
private
Ip6SubnetFilterRule(Inet6Address ipAddress, int cidrPrefix, IpFilterRuleType ruleType)

Method Summary

Modifier and TypeMethod and Description
private static BigInteger
ipToInt(Inet6Address ipAddress)

public boolean
private static BigInteger
prefixToSubnetMask(int cidrPrefix)

public IpFilterRuleType
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MINUS_ONEback to summary
private static final BigInteger MINUS_ONE
networkAddressback to summary
private final BigInteger networkAddress
ruleTypeback to summary
private final IpFilterRuleType ruleType
subnetMaskback to summary
private final BigInteger subnetMask

Constructor Detail

Ip6SubnetFilterRuleback to summary
private Ip6SubnetFilterRule(Inet6Address ipAddress, int cidrPrefix, IpFilterRuleType ruleType)

Method Detail

ipToIntback to summary
private static BigInteger ipToInt(Inet6Address ipAddress)
matchesback to summary
public boolean matches(InetSocketAddress remoteAddress)

Implements io.netty.handler.ipfilter.IpFilterRule.matches.

Returns:boolean

Doc from io.netty.handler.ipfilter.IpFilterRule.matches.

This method should return true if remoteAddress is valid according to your criteria. False otherwise.

Annotations
@Override
prefixToSubnetMaskback to summary
private static BigInteger prefixToSubnetMask(int cidrPrefix)
ruleTypeback to summary
public IpFilterRuleType ruleType()

Implements io.netty.handler.ipfilter.IpFilterRule.ruleType.

Returns:IpFilterRuleType

Doc from io.netty.handler.ipfilter.IpFilterRule.ruleType.

This method should return IpFilterRuleType#ACCEPT if all IpFilterRule#matches(InetSocketAddress) for which matches(InetSocketAddress) returns true should the accepted. If you want to exclude all of those IP addresses then IpFilterRuleType#REJECT should be returned.

Annotations
@Override