TSHttpTxnClientAddrGet

Synopsis

#include <ts/ts.h>
struct sockaddr const *TSHttpTxnClientAddrGet(TSHttpTxn txnp)

Description

Return the socket address of the client that initiated the transaction txnp. The returned pointer references storage owned by Traffic Server and is only valid for the duration of the current callback; plugins that need to keep the value across callbacks must copy it into their own storage.

The returned struct sockaddr is address-family agnostic. Inspect the sa_family field (or use the ats_ip_* helpers) to dispatch on IPv4 versus IPv6.

If the listener that accepted the connection has the pp-clnt flag set and a PROXY Protocol header was successfully parsed, the returned address is the PROXY-Protocol source address rather than the immediate TCP peer. Without pp-clnt the returned address is the immediate TCP peer even when PROXY Protocol is enabled. See Proxy Protocol for the full enumeration of surfaces gated by pp-clnt.

Return Value

A pointer to the client address, or nullptr if txnp is invalid or no client address is available.

See Also

TSAPI(3ts), TSHttpSsnClientAddrGet(), TSNetVConnClientAddrGet()