Class ProxyChain


  • public class ProxyChain
    extends Object
    Representation of a proxy chain as found in HTTP X-Forwarded-For header.
    • Constructor Detail

      • ProxyChain

        public ProxyChain​(IPAddress origin,
                          List<IPAddress> proxies)
        Creates a new chain from a origin (the original client) and all intermediate proxies.
        Parameters:
        origin - the origin
        proxies - the proxies
      • ProxyChain

        public ProxyChain​(List<IPAddress> chain)
        Creates a new chain from a list of addresses as found in the X-Forwarded-For header. The list has to have at least one member.
        Parameters:
        chain - the chain
    • Method Detail

      • getOrigin

        public IPAddress getOrigin()
        Get the origin of the request (the clients address).
        Returns:
        the origin
      • getProxies

        public List<IPAddress> getProxies()
        Get a list of all intermediate proxy servers.
        Returns:
        the proxies
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • fromForwardedForHeader

        public static Optional<ProxyChain> fromForwardedForHeader​(String header)
        Creates a Proxy chain from the X-Forwarded-For HTTP header.
        Parameters:
        header - the X-Forwarded-For header
        Returns:
        a ProxyChain if the header is present, non empty and well formed.