@Override
    public String toString() {

        String remoteAddress = creds.getRemoteAddress();

        // Log X-Forwarded-For, if present and valid
        String header = creds.getHeader("X-Forwarded-For");
        if (header != null && X_FORWARDED_FOR.matcher(header).matches())
            return "[" + header + ", " + remoteAddress + "]";

        // If header absent or invalid, just use source IP
        return remoteAddress;

    }
Creates a new RemoteAddress representing the source address of the HTTP
request that provided the given Credentials.

@param creds
    The Credentials associated with the request whose source address
    should be represented by this RemoteAddress.
guacamole/src/main/java/org/apache/guacamole/event/RemoteAddress.java