Skip to main content

get_client_ip

Function get_client_ip 

Source
pub fn get_client_ip(session: &Session) -> String
Expand description

Gets the client’s IP address.

When trusted proxies are configured, X-Forwarded-For / X-Real-IP are only honoured if the direct TCP peer is a trusted proxy; otherwise the peer’s own address is returned. When no trusted proxies are configured the lookup order is:

  1. X-Forwarded-For (taking the first IP in the list)
  2. X-Real-IP
  3. The remote address of the direct TCP connection