IpSubnetFilter Class — netty Architecture
Architecture documentation for the IpSubnetFilter class in IpSubnetFilter.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 639d6b66_d0e8_891b_e1a9_3afd71f59c8a["IpSubnetFilter"] 7bef23ad_c4d1_d920_3be0_75ae824e4e7d["IpSubnetFilter.java"] 639d6b66_d0e8_891b_e1a9_3afd71f59c8a -->|defined in| 7bef23ad_c4d1_d920_3be0_75ae824e4e7d 97dafcdf_024d_373a_bbbc_bb5d73ab52c5["IpSubnetFilter()"] 639d6b66_d0e8_891b_e1a9_3afd71f59c8a -->|method| 97dafcdf_024d_373a_bbbc_bb5d73ab52c5 c12594e6_7b08_645f_83c9_d3a474ec1c75["accept()"] 639d6b66_d0e8_891b_e1a9_3afd71f59c8a -->|method| c12594e6_7b08_645f_83c9_d3a474ec1c75 971c3ecb_dbe2_73b5_5309_fbca0e2a2df3["sortAndFilter()"] 639d6b66_d0e8_891b_e1a9_3afd71f59c8a -->|method| 971c3ecb_dbe2_73b5_5309_fbca0e2a2df3
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/ipfilter/IpSubnetFilter.java lines 54–226
@Sharable
public class IpSubnetFilter extends AbstractRemoteAddressFilter<InetSocketAddress> {
private final boolean acceptIfNotFound;
private final IpSubnetFilterRule[] ipv4Rules;
private final IpSubnetFilterRule[] ipv6Rules;
private final IpFilterRuleType ipFilterRuleTypeIPv4;
private final IpFilterRuleType ipFilterRuleTypeIPv6;
/**
* <p> Create new {@link IpSubnetFilter} Instance with specified {@link IpSubnetFilterRule} as array. </p>
* <p> {@code acceptIfNotFound} is set to {@code true}. </p>
*
* @param rules {@link IpSubnetFilterRule} as an array
*/
public IpSubnetFilter(IpSubnetFilterRule... rules) {
this(true, Arrays.asList(ObjectUtil.checkNotNull(rules, "rules")));
}
/**
* <p> Create new {@link IpSubnetFilter} Instance with specified {@link IpSubnetFilterRule} as array
* and specify if we'll accept a connection if we don't find it in the rule(s). </p>
*
* @param acceptIfNotFound {@code true} if we'll accept connection if not found in rule(s).
* @param rules {@link IpSubnetFilterRule} as an array
*/
public IpSubnetFilter(boolean acceptIfNotFound, IpSubnetFilterRule... rules) {
this(acceptIfNotFound, Arrays.asList(ObjectUtil.checkNotNull(rules, "rules")));
}
/**
* <p> Create new {@link IpSubnetFilter} Instance with specified {@link IpSubnetFilterRule} as {@link List}. </p>
* <p> {@code acceptIfNotFound} is set to {@code true}. </p>
*
* @param rules {@link IpSubnetFilterRule} as a {@link List}
*/
public IpSubnetFilter(List<IpSubnetFilterRule> rules) {
this(true, rules);
}
/**
* <p> Create new {@link IpSubnetFilter} Instance with specified {@link IpSubnetFilterRule} as {@link List}
* and specify if we'll accept a connection if we don't find it in the rule(s). </p>
*
* @param acceptIfNotFound {@code true} if we'll accept connection if not found in rule(s).
* @param rules {@link IpSubnetFilterRule} as a {@link List}
*/
public IpSubnetFilter(boolean acceptIfNotFound, List<IpSubnetFilterRule> rules) {
ObjectUtil.checkNotNull(rules, "rules");
this.acceptIfNotFound = acceptIfNotFound;
int numAcceptIPv4 = 0;
int numRejectIPv4 = 0;
int numAcceptIPv6 = 0;
int numRejectIPv6 = 0;
List<IpSubnetFilterRule> unsortedIPv4Rules = new ArrayList<IpSubnetFilterRule>();
List<IpSubnetFilterRule> unsortedIPv6Rules = new ArrayList<IpSubnetFilterRule>();
// Iterate over rules and check for `null` rule.
for (IpSubnetFilterRule ipSubnetFilterRule : rules) {
ObjectUtil.checkNotNull(ipSubnetFilterRule, "rule");
if (ipSubnetFilterRule.getFilterRule() instanceof IpSubnetFilterRule.Ip4SubnetFilterRule) {
unsortedIPv4Rules.add(ipSubnetFilterRule);
if (ipSubnetFilterRule.ruleType() == IpFilterRuleType.ACCEPT) {
numAcceptIPv4++;
} else {
numRejectIPv4++;
}
} else {
unsortedIPv6Rules.add(ipSubnetFilterRule);
if (ipSubnetFilterRule.ruleType() == IpFilterRuleType.ACCEPT) {
numAcceptIPv6++;
} else {
numRejectIPv6++;
}
}
}
Source
Frequently Asked Questions
What is the IpSubnetFilter class?
IpSubnetFilter is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/ipfilter/IpSubnetFilter.java.
Where is IpSubnetFilter defined?
IpSubnetFilter is defined in handler/src/main/java/io/netty/handler/ipfilter/IpSubnetFilter.java at line 54.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free