|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.AddrTools
public final class AddrTools
This class has tools for IP-address and DNS manipulation.
| Nested Class Summary | |
|---|---|
static class |
AddrTools.AddrPrefix
Immutable store of a non-null, non-zero-length unsigned-byte IP(v4) address prefix. |
| Field Summary | |
|---|---|
private static java.lang.ref.SoftReference<org.xbill.DNS.Cache> |
_cacheIN_SR
SoftReference to our shared DNS cache (for IN records); never null though referent may be. |
private static java.lang.Object |
_cacheIN_SR_lock
Lock for get/set access to _cacheIN_SR SoftReference value. |
private static int |
DEFAULT_DNS_CACHE_S
Default maximum time to positively cache a record for (seconds); strictly positive. |
private static int |
DEFAULT_DNS_NCACHE_S
Default maximum time to negatively cache a record for (seconds); strictly positive. |
private static org.xbill.DNS.Name[] |
EMPTY_SEARCH_PATH
Fixed empty search path for lookups. |
private static boolean |
RANDOMISE_RBL_LOOKUP_ORDER
If true then we randomise the order in which we do RBL lookups. |
private static org.xbill.DNS.ExtendedResolver |
RESOLVER_QUICK
Our ExtendedResolver with the normal servers but a short timeout. |
private static int |
RESOLVER_QUICK_RETRIES
Maximum retries of resolution against each DNS server/resolver; strictly positive. |
private static int |
RESOLVER_QUICK_TIMEOUT_S
Approximate total maximum timeout for DNS resolution in seconds; strictly positive. |
static boolean |
USE_DNSJAVA
If true, use DNSJava to do DNS lookups where possible, else use Java's built-in DNS resolver. |
| Constructor Summary | |
|---|---|
private |
AddrTools()
Prevent creation of instances of this class. |
| Method Summary | |
|---|---|
private static java.lang.String |
_checkOneAddrInDNSBL(java.lang.String prefix,
java.lang.String server)
Look up one address in DNSBL. |
private static org.xbill.DNS.Cache |
_getDNSCache()
Return access to the DNS cache, creating and initialising it if necessary; never null. |
(package private) static org.xbill.DNS.Record[] |
doQuickLookupWithTunedCache(org.xbill.DNS.Lookup lookup)
Do (quick) blocking lookup in our shared and tuned cache and resolver. |
static java.lang.String |
doReverseLookup(java.net.InetAddress addr,
boolean verify)
Do reverse lookup on IP address to get the name, returns null if lookup fails. |
static java.lang.String |
doReverseLookup(java.lang.String addr,
boolean verify)
Do reverse lookup on IP address to get the name, returns null if lookup fails. |
static boolean |
hasARecordQuick(java.lang.String name)
Return true if we can find an A record for the given name quickly. |
static java.lang.String |
isAddrBlackholed(java.util.Collection<java.lang.String> extantRBLServers,
java.net.InetAddress addr,
boolean quick)
Check an (IPv4) IP address with the RBL servers for being "blackholed". |
static java.lang.String |
toStringDottedQuad(java.net.InetAddress addr)
Convert an (IPv4) InetAddress to dotted-quad form. |
static java.lang.String |
toStringReverseDottedQuad(java.net.InetAddress addr)
Convert an (IPv4) InetAddress to reverse dotted-quad form with a trailing dot. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final boolean USE_DNSJAVA
private static final org.xbill.DNS.Name[] EMPTY_SEARCH_PATH
private static final int RESOLVER_QUICK_TIMEOUT_S
A value of a few seconds to a few tens of seconds should normally suffice, and puts a reasonable cap on the cost of a "full" lookup.
private static final int RESOLVER_QUICK_RETRIES
A value of 1 or 2 is typical.
private static java.lang.ref.SoftReference<org.xbill.DNS.Cache> _cacheIN_SR
We don't hand this out to other users, but they can give us a Lookup object and we will set the cache and other relevant parameters, and return the result to them.
This is intended to be highly threadable for many concurrent lookups.
Get/set access to this value is synchronised on the _cacheIN_SR_lock.
private static final java.lang.Object _cacheIN_SR_lock
private static final int DEFAULT_DNS_CACHE_S
private static final int DEFAULT_DNS_NCACHE_S
private static final org.xbill.DNS.ExtendedResolver RESOLVER_QUICK
private static final boolean RANDOMISE_RBL_LOOKUP_ORDER
This does not have to be "very" random, indeed, round-robin would probably do just as well.
| Constructor Detail |
|---|
private AddrTools()
| Method Detail |
|---|
private static org.xbill.DNS.Cache _getDNSCache()
This cache may have several parameters tuned for geo-lookup purposes, such as negative/positive cache time-limits.
static org.xbill.DNS.Record[] doQuickLookupWithTunedCache(org.xbill.DNS.Lookup lookup)
The caller should not extract/sequester/inspect the cache/resolver/etc properties that we set in the Lookup parameter, so this routine is only package-visible.
FIXME: As of 20060703: most expensive consumer of time for doHTML.jsp.
public static boolean hasARecordQuick(java.lang.String name)
java.lang.IllegalArgumentException - if argument is null or unparsable.
public static java.lang.String toStringDottedQuad(java.net.InetAddress addr)
throws java.lang.IllegalArgumentException
addr - parameter to convert to dotted-quad;
must be non-null IPv4 address
java.lang.IllegalArgumentException - if addr is null or not an IPv4 address
public static java.lang.String toStringReverseDottedQuad(java.net.InetAddress addr)
throws java.lang.IllegalArgumentException
Avoid doing any DNS lookup if at all possible.
addr - parameter to convert to reverse dotted-quad;
must be non-null IPv4 address
java.lang.IllegalArgumentException - if addr is null or not an IPv4 address
public static java.lang.String doReverseLookup(java.lang.String addr,
boolean verify)
This avoids the built-in JVM lookup routines to avoid the default infinite cacheing that it does for class-loading safety.
Blocks until it has an answer or times out.
addr - IP address to look up as numeric address; never nullverify - if true, attempt to verify with forward lookup of
the putative result, returning null if no suitable match is found
public static java.lang.String doReverseLookup(java.net.InetAddress addr,
boolean verify)
This avoids the built-in JVM lookup routines to avoid the default infinite cacheing that it does for class-loading safety.
Blocks until it has an answer or times out.
addr - IP address to look up; never nullverify - if true, attempt to verify with forward lookup of
the putative result, returning null if no suitable match is found
public static final java.lang.String isAddrBlackholed(java.util.Collection<java.lang.String> extantRBLServers,
java.net.InetAddress addr,
boolean quick)
throws java.lang.IllegalArgumentException
We may do these checks serially, or in parallel for speed. We may pick one RBL server at random each time for speed. The first suitable A record returned stops the search.
We may randomise the order in which we do lookup to spread the load amongst the RBL servers more fairly.
TODO: For now, always returns null for non-IPv4 addresses.
quick - if true, check just one of the BLs at random
java.lang.IllegalArgumentException - if given a null address
private static java.lang.String _checkOneAddrInDNSBL(java.lang.String prefix,
java.lang.String server)
|
DHD Multimedia Gallery V1.50.55 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||