Thanks Masakazu for the info. I checked again, and this time i am printing the output of TSHttpTxnServerAddrGet in the function triggered by TS_HTTP_SEND_RESPONSE_HDR_HOOK . But still i am seeing the same issue. All the bytes in sockaddr struct are 0. Is there any alternative to the usage of TSHttpTxnServerAddrGet api ? Please let me know. thanks, gaurav
On Sat, Aug 19, 2017 at 1:48 PM, Masakazu Kitajo <[email protected]> wrote: > Some of the addresses are not available on early stages. I guess you may > be using an inappropriate hook. > > [Aug 19 16:49:18.063] Server {0xb000a000} DIAG: (foo) > HOOK_READ_REQUEST_HEADERS_PRE_REMAP > [Aug 19 16:49:18.063] Server {0xb000a000} DIAG: (foo) > TSHttpTxnClientAddrGet: 127.0.0.1 > [Aug 19 16:49:18.063] Server {0xb000a000} DIAG: (foo) > TSHttpTxnIncomingAddrGet: 127.0.0.1 > [Aug 19 16:49:18.063] Server {0xb000a000} DIAG: (foo) > TSHttpTxnServerAddrGet: 0.0.0.0 > [Aug 19 16:49:18.064] Server {0xb000a000} DIAG: (foo) > HOOK_READ_REQUEST_HEADERS_POST_REMAP > [Aug 19 16:49:18.064] Server {0xb000a000} DIAG: (foo) > TSHttpTxnClientAddrGet: 127.0.0.1 > [Aug 19 16:49:18.064] Server {0xb000a000} DIAG: (foo) > TSHttpTxnIncomingAddrGet: 127.0.0.1 > [Aug 19 16:49:18.064] Server {0xb000a000} DIAG: (foo) > TSHttpTxnServerAddrGet: 0.0.0.0 > [Aug 19 16:49:18.103] Server {0xb000a000} DIAG: (foo) HOOK_OS_DNS > [Aug 19 16:49:18.103] Server {0xb000a000} DIAG: (foo) > TSHttpTxnClientAddrGet: 127.0.0.1 > [Aug 19 16:49:18.103] Server {0xb000a000} DIAG: (foo) > TSHttpTxnIncomingAddrGet: 127.0.0.1 > [Aug 19 16:49:18.103] Server {0xb000a000} DIAG: (foo) > TSHttpTxnServerAddrGet: 54.225.79.9 > [Aug 19 16:49:18.106] Server {0xb000a000} DIAG: (foo) > HOOK_SEND_REQUEST_HEADERS > [Aug 19 16:49:18.106] Server {0xb000a000} DIAG: (foo) > TSHttpTxnClientAddrGet: 127.0.0.1 > [Aug 19 16:49:18.106] Server {0xb000a000} DIAG: (foo) > TSHttpTxnIncomingAddrGet: 127.0.0.1 > [Aug 19 16:49:18.106] Server {0xb000a000} DIAG: (foo) > TSHttpTxnOutGoingAddrGet: 192.168.1.22 > [Aug 19 16:49:18.106] Server {0xb000a000} DIAG: (foo) > TSHttpTxnServerAddrGet: 54.225.79.9 > [Aug 19 16:49:18.685] Server {0xb000a000} DIAG: (foo) > HOOK_SEND_RESPONSE_HEADERS > [Aug 19 16:49:18.685] Server {0xb000a000} DIAG: (foo) > TSHttpTxnClientAddrGet: 127.0.0.1 > [Aug 19 16:49:18.685] Server {0xb000a000} DIAG: (foo) > TSHttpTxnIncomingAddrGet: 127.0.0.1 > [Aug 19 16:49:18.685] Server {0xb000a000} DIAG: (foo) > TSHttpTxnOutGoingAddrGet: 192.168.1.22 > [Aug 19 16:49:18.685] Server {0xb000a000} DIAG: (foo) > TSHttpTxnServerAddrGet: 54.225.79.9 > > Thanks, > Masakazu > > > On Fri, Aug 18, 2017 at 5:36 PM, Gaurav Bansal <[email protected]> wrote: > >> Thanks Masakazu for the info. I tried the api's you told in the links >> above. Out of these : >> i) TSHttpSsnClientAddrGet : works fine as expected giving client port/ip. >> ii) TSHttpTxnServerAddrGet : always provides 0 for sin_port & sin_addr >> members of sockaddr_in struct (infact all the bytes in sockaddr structure >> returned by this api are 0). Are there any known issues with this api ? Is >> there any other way to get the server ip/port in the plugin ? >> >> thanks, >> gaurav >> >> >> On Wed, Aug 16, 2017 at 5:58 PM, Masakazu Kitajo <[email protected]> >> wrote: >> >>> Hi Gaurav, >>> >>> Here you are. These are C++ API but you can use TSHttpTxn* functions >>> directly if you use C API. >>> https://github.com/apache/trafficserver/blob/7.1.0/lib/cppap >>> i/Transaction.cc#L284-L306 >>> >>> You can find some of them on our documentation (not all of them, >>> unfortunately). >>> https://docs.trafficserver.apache.org/en/latest/developer-gu >>> ide/api/functions/TSHttpTxnServerAddrGet.en.html >>> >>> Thanks, >>> Masakazu >>> >>> >>> On Wed, Aug 16, 2017 at 7:55 PM, Gaurav Bansal <[email protected]> >>> wrote: >>> >>>> hi all, >>>> I am writing a plugin and need the value of client/server >>>> ip-address/port-number. Is there any existing api, using which i can get >>>> these OR any structure from which i can get these values ? Definitely these >>>> would have been stored in some structure while parsing the ip headers, just >>>> want to know how to access them from the plugin. >>>> thanks, >>>> gaurav >>>> >>> >>> >> >
