class IpList
extends Object
Modifier and Type | Class and Description |
---|---|
private class |
IpList.IpAddr
Data class to keep track of the four numeric components of an IP
address.
|
private class |
IpList.IpRange
Data structure to keep track of a range of IP addresses and whether
they are "positive" or "negative".
|
Modifier and Type | Field and Description |
---|---|
private ArrayList<IpList.IpRange> |
ranges
List of IpRanges.
|
Constructor and Description |
---|
IpList(String path)
Constructs and loads an IP map from the specified file.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isApproved(String ipAddrStr)
Parses the given IP address and checks whether it falls within one
of the positive ranges of the map, and doesn't fall in one of the
excluded ranges.
|
private void |
processEntry(String line,
boolean isPositive)
Used by readMap to parse a single entry in the IP map file.
|
private void |
readRanges(String path)
Reads the contents the given file into the IP map.
|
private ArrayList<IpList.IpRange> ranges
public IpList(String path) throws IOException
path
- Path to the file to load the IP map from.IOException
- If the IP map file couldn't be opened.public boolean isApproved(String ipAddrStr)
ipAddrStr
- A string of the form "a.b.c.d" where each component
is a decimal number from 0-255.private void readRanges(String path) throws IOException
path
- Path to the file to loadIOException
- If the file couldn't be read from.private void processEntry(String line, boolean isPositive)
line
- The line of text to parseisPositive
- true if this is an "exclude" line