src/main/php/request/WebRequest.php
public function originatingIpAddress()
    {
        try {
            if ($this->headers->contain('HTTP_X_FORWARDED_FOR')) {
                $remoteAddresses = explode(',', $this->headers->value('HTTP_X_FORWARDED_FOR')->value());
                return new IpAddress(trim($remoteAddresses[0]));
            }

            if ($this->headers->contain('REMOTE_ADDR')) {
                return new IpAddress($this->headers->value('REMOTE_ADDR')->value());
            }
        } catch (\InvalidArgumentException $iae) {
            // treat as if no ip address available
        }

        return null;
    }
public function originatingIpAddress()
    {
        try {
            if ($this->headers->contain('HTTP_X_FORWARDED_FOR')) {
                $remoteAddresses = explode(',', $this->headers->value('HTTP_X_FORWARDED_FOR')->value());
                return new IpAddress(trim($remoteAddresses[0]));
            }

            if ($this->headers->contain('REMOTE_ADDR')) {
                return new IpAddress($this->headers->value('REMOTE_ADDR')->value());
            }
        } catch (\InvalidArgumentException $iae) {
            // treat as if no ip address available
        }

        return null;
    }
public function originatingIpAddress ( ) { try { if ( $ this -> headers -> contain ( 'HTTP_X_FORWARDED_FOR' ) ) { $ remoteAddresses = explode ( ',' , $ this -> headers -> value ( 'HTTP_X_FORWARDED_FOR' ) -> value ( ) ) ; return new IpAddress ( trim ( $ remoteAddresses [ 0 ] ) ) ; } if ( $ this -> headers -> contain ( 'REMOTE_ADDR' ) ) { return new IpAddress ( $ this -> headers -> value ( 'REMOTE_ADDR' ) -> value ( ) ) ; } } catch ( \ InvalidArgumentException $ iae ) { // treat as if no ip address available } return null ; }
returns the ip address which issued the request originally

The originating IP address is the IP address of the client which issued
the request. In case the request was routed via several proxies it will
still return the real client IP, and not the IP address of the last proxy
in the chain.

Please note that the method relies on the values of REMOTE_ADDR provided
by PHP and the X-Forwarded-For header. If none of these is present the
return value will be null. Additionally, if the value of these headers
does not contain a syntactically correct IP address, the return value
will be null.

Also, the return value might not neccessarily be an existing IP address
nor the real IP address of the client, as it may be spoofed.

@return  \stubbles\peer\IpAddress
@since   3.0.0
returns the ip address which issued the request originally