Class PatternRule
java.lang.Object
org.jboss.netty.handler.ipfilter.PatternRule
- All Implemented Interfaces:
Comparable<Object>, IpFilterRule, IpSet
The Class PatternRule represents an IP filter rule using string patterns.
Rule Syntax:
Example: allow localhost:
new PatternRule(true, "n:localhost")
Example: allow local lan:
new PatternRule(true, "i:192.168.0.*")
Example: block all
new PatternRule(false, "n:*")
Rule Syntax:
Rule ::= [n|i]:address n stands for computer name, i for ip address address ::= <regex> | localhost regex is a regular expression with '*' as multi character and '?' as single character wild card
Example: allow localhost:
new PatternRule(true, "n:localhost")
Example: allow local lan:
new PatternRule(true, "i:192.168.0.*")
Example: block all
new PatternRule(false, "n:*")
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Patternprivate booleanprivate booleanprivate static final InternalLoggerprivate Patternprivate final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Stringintbooleancontains(InetAddress inetAddress) Compares the given InetAddress against the IpSet and returns true if the InetAddress is contained in this Rule and false if not.returns the pattern.booleanbooleanprivate static booleanisLocalhost(InetAddress address) private void
-
Field Details
-
logger
-
ipPattern
-
namePattern
-
isAllowRule
private boolean isAllowRule -
localhost
private boolean localhost -
pattern
-
-
Constructor Details
-
PatternRule
Instantiates a new pattern rule.- Parameters:
allow- indicates if this is an allow or block rulepattern- the filter pattern
-
-
Method Details
-
getPattern
-
isAllowRule
public boolean isAllowRule()- Specified by:
isAllowRulein interfaceIpFilterRule- Returns:
- True if this Rule is an ALLOW rule
-
isDenyRule
public boolean isDenyRule()- Specified by:
isDenyRulein interfaceIpFilterRule- Returns:
- True if this Rule is a DENY rule
-
contains
Description copied from interface:IpSetCompares the given InetAddress against the IpSet and returns true if the InetAddress is contained in this Rule and false if not. -
parse
-
addRule
-
isLocalhost
-
compareTo
- Specified by:
compareToin interfaceComparable<Object>
-