How an adapter can get the HTTP client IP address?

Created by Alex Rousskov
Keywords:
Last updated by:
Alex Rousskov

Using libecap v0.2.0, it may be possible to retrieve the client IP address by querying the host transaction for the option named metaClientIp. See libecap::host::Xaction::option() and visitEachOption() APIs, inherited by libecap::host::Xaction from its libecap::Options parent. Host applications implement those APIs to provide adapters with transaction-specific meta-information. For example, if your adapter calls the libecap::host::Xaction::option() method with libecap::metaClientIp name as a parameter, it may get the client IP address string back.

Please note that supplying client IP is an optional feature and not all host applications will support it. FWIW, Squid supports it starting with v3.2.0.6 (to enable this feature, turn adaptation_send_client_ip in squid.conf on).

BTW, no host application supports sharing MAC addresses with adaptation services, and ICAP does not have a "standard" header for sharing that information either. Nevertheless, it is possible to add such support to the host application and to the adapter using the same libecap::host::Xaction::option() and visitEachOption() interfaces.