Package com.browserup.bup.proxy.dns
Class AbstractHostNameRemapper
- java.lang.Object
-
- com.browserup.bup.proxy.dns.AbstractHostNameRemapper
-
- All Implemented Interfaces:
AdvancedHostResolver,HostResolver
- Direct Known Subclasses:
DnsJavaResolver,NativeResolver
public abstract class AbstractHostNameRemapper extends java.lang.Object implements AdvancedHostResolver
Base class that provides host name remapping capabilities for AdvancedHostResolvers. Subclasses must implementresolveRemapped(String)instead ofHostResolver.resolve(String), which takes the remapped host as the input parameter.
-
-
Constructor Summary
Constructors Constructor Description AbstractHostNameRemapper()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.StringapplyRemapping(java.lang.String originalHost)Applies this class's host name remappings to the specified original host, returning the remapped host name (if any), or the originalHost if there is no remapped host name.voidclearHostRemappings()Removes all hostname remappings.java.util.Map<java.lang.String,java.lang.String>getHostRemappings()Returns all host remappings in effect.java.util.Collection<java.lang.String>getOriginalHostnames(java.lang.String remappedHost)Returns the original address or addresses that are remapped to the specified remappedHost.voidremapHost(java.lang.String originalHost, java.lang.String remappedHost)Remaps an individual host.voidremapHosts(java.util.Map<java.lang.String,java.lang.String> hostRemappings)Replaces the host remappings in the existing list of remappings (if any) with the specified remappings.voidremoveHostRemapping(java.lang.String originalHost)Removes the specified host remapping.java.util.Collection<java.net.InetAddress>resolve(java.lang.String originalHost)Retrieves the remapped hostname and resolves it usingresolveRemapped(String).abstract java.util.Collection<java.net.InetAddress>resolveRemapped(java.lang.String remappedHost)Resolves the specified remapped host.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.browserup.bup.proxy.dns.AdvancedHostResolver
clearDNSCache, setNegativeDNSCacheTimeout, setPositiveDNSCacheTimeout
-
-
-
-
Method Detail
-
remapHosts
public void remapHosts(java.util.Map<java.lang.String,java.lang.String> hostRemappings)
Description copied from interface:AdvancedHostResolverReplaces the host remappings in the existing list of remappings (if any) with the specified remappings. The remappings will be applied in the order specified by the Map's iterator. Note: The original hostnames must exactly match the requested hostname. It is not a domain or regular expression match.- Specified by:
remapHostsin interfaceAdvancedHostResolver- Parameters:
hostRemappings- Map of<original hostname, remapped hostname>
-
remapHost
public void remapHost(java.lang.String originalHost, java.lang.String remappedHost)Description copied from interface:AdvancedHostResolverRemaps an individual host. If there are any existing remappings, the new remapping will be applied last, after all existing remappings are applied. If there is already a remapping for the specified originalHost, it will be removed before the new remapping is added to the end of the host remapping list (and will therefore be the last remapping applied).- Specified by:
remapHostin interfaceAdvancedHostResolver- Parameters:
originalHost- Original host to remap. Must exactly match the requested hostname (not a domain or regular expression match).remappedHost- hostname that will replace originalHost
-
removeHostRemapping
public void removeHostRemapping(java.lang.String originalHost)
Description copied from interface:AdvancedHostResolverRemoves the specified host remapping. If the remapping does not exist, this method has no effect.- Specified by:
removeHostRemappingin interfaceAdvancedHostResolver- Parameters:
originalHost- currently-remapped hostname
-
clearHostRemappings
public void clearHostRemappings()
Description copied from interface:AdvancedHostResolverRemoves all hostname remappings.- Specified by:
clearHostRemappingsin interfaceAdvancedHostResolver
-
getHostRemappings
public java.util.Map<java.lang.String,java.lang.String> getHostRemappings()
Description copied from interface:AdvancedHostResolverReturns all host remappings in effect. Iterating over the returned Map is guaranteed to return remappings in the order in which the remappings are actually applied.- Specified by:
getHostRemappingsin interfaceAdvancedHostResolver- Returns:
- Map of
<original hostname, remapped hostname>
-
getOriginalHostnames
public java.util.Collection<java.lang.String> getOriginalHostnames(java.lang.String remappedHost)
Description copied from interface:AdvancedHostResolverReturns the original address or addresses that are remapped to the specified remappedHost. Iterating over the returned Collection is guaranteed to return original mappings in the order in which the remappings are applied.- Specified by:
getOriginalHostnamesin interfaceAdvancedHostResolver- Parameters:
remappedHost- remapped hostname- Returns:
- original hostnames that are remapped to the specified remappedHost, or an empty Collection if no remapping is defined to the remappedHost
-
applyRemapping
public java.lang.String applyRemapping(java.lang.String originalHost)
Applies this class's host name remappings to the specified original host, returning the remapped host name (if any), or the originalHost if there is no remapped host name.- Parameters:
originalHost- original host name to resolve- Returns:
- a remapped host, or the original host if no mapping exists
-
resolveRemapped
public abstract java.util.Collection<java.net.InetAddress> resolveRemapped(java.lang.String remappedHost)
Resolves the specified remapped host. Subclasses should provide resolution by implementing this method, rather than overridingHostResolver.resolve(String).- Parameters:
remappedHost- remapped hostname to resolve- Returns:
- resolved InetAddresses, or an empty list if no addresses were found
-
resolve
public java.util.Collection<java.net.InetAddress> resolve(java.lang.String originalHost)
Retrieves the remapped hostname and resolves it usingresolveRemapped(String).- Specified by:
resolvein interfaceHostResolver- Parameters:
originalHost- original hostname to resolve- Returns:
- InetAddresses resolved from the remapped hostname, or an empty list if no addresses were found
-
-