Functionality for determining client IP address.

 Methods

Returns client IP address.

getIpAddress() : string

Returns

stringIP address.

Checks proxy handling setting.

getUseProxy() : bool

Returns

boolCurrent setting value.

Set the header to introspect for proxy IPs

setProxyHeader(string $header) : \Zend\Http\PhpEnvironment\RemoteAddress

Parameters

$header

string

Returns

Set list of trusted proxy addresses

setTrustedProxies(array $trustedProxies) : \Zend\Http\PhpEnvironment\RemoteAddress

Parameters

$trustedProxies

array

Returns

Changes proxy handling setting.

setUseProxy(bool $useProxy) : \Zend\Http\PhpEnvironment\RemoteAddress

This must be static method, since validators are recovered automatically at session read, so this is the only way to switch setting.

Parameters

$useProxy

bool

Whether to check also proxied IP addresses.

Returns

Attempt to get the IP address for a proxied client

getIpAddressFromProxy() : false | string

Returns

falsestring

Normalize a header string

normalizeProxyHeader(string $header) : string

Normalizes a header string to a format that is compatible with $_SERVER

Parameters

$header

string

Returns

string

 Properties

 

HTTP header to introspect for proxies

$proxyHeader : string

 

List of trusted proxy IP addresses

$trustedProxies : array

 

Whether to use proxy addresses or not.

$useProxy : bool

As default this setting is disabled - IP address is mostly needed to increase security. HTTP_* are not reliable since can easily be spoofed. It can be enabled just for more flexibility, but if user uses proxy to connect to trusted services it's his/her own risk, only reliable field for IP address is $_SERVER['REMOTE_ADDR'].