Package org.jboss.netty.handler.ipfilter
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 Pattern
private boolean
private boolean
private static final InternalLogger
private Pattern
private final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
int
boolean
contains
(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.boolean
boolean
private static boolean
isLocalhost
(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
returns the pattern.- Returns:
- the pattern
-
isAllowRule
public boolean isAllowRule()- Specified by:
isAllowRule
in interfaceIpFilterRule
- Returns:
- True if this Rule is an ALLOW rule
-
isDenyRule
public boolean isDenyRule()- Specified by:
isDenyRule
in interfaceIpFilterRule
- Returns:
- True if this Rule is a DENY rule
-
contains
Description copied from interface:IpSet
Compares 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:
compareTo
in interfaceComparable<Object>
-