On 10 Feb 2012, at 12:14, Maurice Kelly wrote:

> On 10 Feb 2012, at 11:41, Nick Kew wrote:
> 
>> It would be great if you could ignore my comments and just try it for 
>> yourself.
>> A second independent opinion might tell us something worthwhile about
>> just how useful the API really is as of now.
> 
> 
> No problem - will download the 3.1.2 release and give it a go with that.


Only managed to do a quick test but I seem to be able to get the IP address 
from the SSN_START hook.

Below you'll see the plugin function I'm using. I've added it as with the 
following hook:

TSHttpHookAdd(TS_HTTP_SSN_START_HOOK, TSContCreate(start_hook, NULL));

and the start_hook  function:

static int
start_hook(TSCont contp, TSEvent event, void *edata) {
    TSDebug(DEBUG_ID, "Entering start_hook()");
    TSHttpSsn ssnp;
    TSHttpTxn txnp;
    const struct sockaddr* sa;
    const struct sockaddr_in* si;

    switch (event) {
        case TS_EVENT_HTTP_SSN_START:
            ssnp = (TSHttpSsn)edata;
            sa = TSHttpSsnClientAddrGet(ssnp);
            si = (const struct sockaddr_in*)sa;
            TSDebug(DEBUG_ID, "Address from SSN START: %s", 
inet_ntoa(si->sin_addr));

            TSHttpSsnHookAdd(ssnp, TS_HTTP_TXN_START_HOOK, contp);

            TSHttpSsnReenable(ssnp, TS_EVENT_HTTP_CONTINUE);
            break;
        case TS_EVENT_HTTP_TXN_START:
            txnp = (TSHttpTxn)edata;
            sa = TSHttpTxnClientAddrGet(txnp);
            si = (const struct sockaddr_in*)sa;
            TSDebug(DEBUG_ID, "Address from TXN_START: %s", 
inet_ntoa(si->sin_addr));

            TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
        default:
            break;
    }

    return 0;
}

The output reads:
[Feb 10 16:24:27.266] Server {0x7fc34756e700} DIAG: (testssn) Entering 
start_hook()
[Feb 10 16:24:27.266] Server {0x7fc34756e700} DIAG: (testssn) Address from SSN 
START: 192.168.91.1
[Feb 10 16:24:27.266] Server {0x7fc34756e700} DIAG: (testssn) Entering 
start_hook()
[Feb 10 16:24:27.266] Server {0x7fc34756e700} DIAG: (testssn) Address from 
TXN_START: 192.168.91.1

Is this what you would have expected?

Cheers,

Maurice

Reply via email to