TSNetVConnClientAddrGet

Synopsis

#include <ts/ts.h>
struct sockaddr const *TSNetVConnClientAddrGet(TSVConn vc)

Description

Return the socket address of the client for the network virtual connection vc. 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.

This is the VConn-level counterpart of TSHttpTxnClientAddrGet() and is appropriate in low-level hooks (for example, SSL or TCP hooks) where no HTTP session or transaction is yet associated with the connection.

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. Use TSNetVConnRemoteAddrGet() if the immediate TCP peer is always required regardless of pp-clnt. See Proxy Protocol for the full enumeration of surfaces gated by pp-clnt.

Return Value

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

See Also

TSAPI(3ts), TSHttpTxnClientAddrGet(), TSHttpSsnClientAddrGet()