getting source/destination ip-address/port number in plugin

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

getting source/destination ip-address/port number in plugin

Gaurav Bansal
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
Reply | Threaded
Open this post in threaded view
|

Re: getting source/destination ip-address/port number in plugin

Masakazu Kitajo-2
Hi Gaurav,

Here you are. These are C++ API but you can use TSHttpTxn* functions directly if you use C API.

You can find some of them on our documentation (not all of them, unfortunately).

Thanks,
Masakazu


On Wed, Aug 16, 2017 at 7:55 PM, Gaurav Bansal <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: getting source/destination ip-address/port number in plugin

Gaurav Bansal
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 <[hidden email]> wrote:
Hi Gaurav,

Here you are. These are C++ API but you can use TSHttpTxn* functions directly if you use C API.

You can find some of them on our documentation (not all of them, unfortunately).

Thanks,
Masakazu


On Wed, Aug 16, 2017 at 7:55 PM, Gaurav Bansal <[hidden email]> 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


Reply | Threaded
Open this post in threaded view
|

Re: getting source/destination ip-address/port number in plugin

Masakazu Kitajo-2
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 <[hidden email]> 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 <[hidden email]> wrote:
Hi Gaurav,

Here you are. These are C++ API but you can use TSHttpTxn* functions directly if you use C API.

You can find some of them on our documentation (not all of them, unfortunately).

Thanks,
Masakazu


On Wed, Aug 16, 2017 at 7:55 PM, Gaurav Bansal <[hidden email]> 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



Reply | Threaded
Open this post in threaded view
|

Re: getting source/destination ip-address/port number in plugin

Gaurav Bansal
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> wrote:
Hi Gaurav,

Here you are. These are C++ API but you can use TSHttpTxn* functions directly if you use C API.

You can find some of them on our documentation (not all of them, unfortunately).

Thanks,
Masakazu


On Wed, Aug 16, 2017 at 7:55 PM, Gaurav Bansal <[hidden email]> 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




Reply | Threaded
Open this post in threaded view
|

Re: getting source/destination ip-address/port number in plugin

Masakazu Kitajo-2
Hmm, maybe the response is served from cache?

AFAIK, there's no alternative API. It should return the address if available, or it should be fixed. Which version are you using?

It would be helpful if you could share your records.config, remap.config, and HTTP request / response headers.

Thanks,
Masakazu


On Mon, Aug 21, 2017 at 10:35 PM, Gaurav Bansal <[hidden email]> wrote:
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> wrote:
Hi Gaurav,

Here you are. These are C++ API but you can use TSHttpTxn* functions directly if you use C API.

You can find some of them on our documentation (not all of them, unfortunately).

Thanks,
Masakazu


On Wed, Aug 16, 2017 at 7:55 PM, Gaurav Bansal <[hidden email]> 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





Reply | Threaded
Open this post in threaded view
|

Re: getting source/destination ip-address/port number in plugin

Gaurav Bansal
Hi Masakazu,
1)The result is coming out same even without caching. Can caching affect the results ? Won't the destination ip address be parsed from the ip-headers which will be same irrespective of caching ?
2)The ATS version we are using is 6.2.1.
3)Please find below the records.config file (remap.config file doesn't have any config)
===========================================================================
CONFIG proxy.config.exec_thread.autoconfig INT 1
CONFIG proxy.config.exec_thread.autoconfig.scale FLOAT 1.500000
CONFIG proxy.config.exec_thread.limit INT 2
CONFIG proxy.config.ssl.number.threads INT -1
CONFIG proxy.config.accept_threads INT 1
CONFIG proxy.config.task_threads INT 2
CONFIG proxy.config.cache.threads_per_disk INT 8
CONFIG proxy.config.exec_thread.affinity INT 1
CONFIG proxy.config.http.server_ports STRING tr-in:80 tr-in:3128
CONFIG proxy.config.http2.enabled INT 1
CONFIG proxy.config.http.insert_request_via_str INT 1
CONFIG proxy.config.http.insert_response_via_str INT 1
CONFIG proxy.config.http.parent_proxy_routing_enable INT 0
CONFIG proxy.config.http.parent_proxy.retry_time INT 300
CONFIG proxy.config.http.parent_proxy.connect_attempts_timeout INT 30
CONFIG proxy.config.http.forward.proxy_auth_to_parent INT 0
CONFIG proxy.config.http.uncacheable_requests_bypass_parent INT 1
CONFIG proxy.config.http.keep_alive_no_activity_timeout_in INT 300
CONFIG proxy.config.http.keep_alive_no_activity_timeout_out INT 300
CONFIG proxy.config.http.transaction_no_activity_timeout_in INT 300
CONFIG proxy.config.http.transaction_no_activity_timeout_out INT 30
CONFIG proxy.config.http.transaction_active_timeout_in INT 900
CONFIG proxy.config.http.transaction_active_timeout_out INT 0
CONFIG proxy.config.http.accept_no_activity_timeout INT 120
CONFIG proxy.config.net.default_inactivity_timeout INT 86400
CONFIG proxy.config.http.connect_attempts_max_retries INT 3
CONFIG proxy.config.http.connect_attempts_max_retries_dead_server INT 1
CONFIG proxy.config.http.connect_attempts_rr_retries INT 3
CONFIG proxy.config.http.connect_attempts_timeout INT 30
CONFIG proxy.config.http.post_connect_attempts_timeout INT 1800
CONFIG proxy.config.http.down_server.cache_time INT 60
CONFIG proxy.config.http.down_server.abort_threshold INT 10
CONFIG proxy.config.http.negative_caching_enabled INT 0
CONFIG proxy.config.http.negative_caching_lifetime INT 1800
CONFIG proxy.config.http.anonymize_insert_client_ip INT 1
CONFIG proxy.config.http.insert_squid_x_forwarded_for INT 1
CONFIG proxy.config.http.push_method_enabled INT 0
CONFIG proxy.config.http.cache.http INT 1
CONFIG proxy.config.http.cache.ignore_client_cc_max_age INT 1
CONFIG proxy.config.http.normalize_ae_gzip INT 1
CONFIG proxy.config.http.cache.cache_responses_to_cookies INT 1
CONFIG proxy.config.http.cache.cache_urls_that_look_dynamic INT 1
CONFIG proxy.config.http.cache.when_to_revalidate INT 0
CONFIG proxy.config.http.cache.required_headers INT 2
CONFIG proxy.config.http.cache.heuristic_min_lifetime INT 3600
CONFIG proxy.config.http.cache.heuristic_max_lifetime INT 86400
CONFIG proxy.config.http.cache.heuristic_lm_factor FLOAT 0.100000
CONFIG proxy.config.net.connections_throttle INT 30000
CONFIG proxy.config.net.max_connections_in INT 30000
CONFIG proxy.config.net.max_connections_active_in INT 10000
CONFIG proxy.config.cache.ram_cache.size INT -1
CONFIG proxy.config.cache.ram_cache_cutoff INT 4194304
CONFIG proxy.config.cache.limits.http.max_alts INT 5
CONFIG proxy.config.cache.max_doc_size INT 0
CONFIG proxy.config.cache.min_average_object_size INT 128
CONFIG proxy.config.log.logging_enabled INT 3
CONFIG proxy.config.log.max_space_mb_for_logs INT 25000
CONFIG proxy.config.log.max_space_mb_headroom INT 1000
CONFIG proxy.config.log.rolling_enabled INT 1
CONFIG proxy.config.log.rolling_interval_sec INT 86400
CONFIG proxy.config.log.rolling_size_mb INT 10
CONFIG proxy.config.log.auto_delete_rolled_files INT 1
CONFIG proxy.config.log.periodic_tasks_interval INT 5
CONFIG proxy.config.url_remap.remap_required INT 0
CONFIG proxy.config.url_remap.pristine_host_hdr INT 0
CONFIG proxy.config.reverse_proxy.enabled INT 0
CONFIG proxy.config.icp.enabled INT 0
CONFIG proxy.config.diags.debug.enabled INT 1
CONFIG proxy.config.diags.debug.tags STRING test_plugin*
CONFIG proxy.config.dump_mem_info_frequency INT 0
CONFIG proxy.config.http.slow.log.threshold INT 0
LOCAL proxy.local.cluster.type INT 3
CONFIG proxy.config.cluster.ethernet_interface STRING lo0
CONFIG proxy.config.cluster.cluster_port INT 8086
CONFIG proxy.config.cluster.rsport INT 8088
CONFIG proxy.config.cluster.mcport INT 8089
CONFIG proxy.config.cluster.mc_group_addr STRING 224.0.1.37
CONFIG proxy.config.log.logfile_dir STRING /data/apps/traffic_server/logs
CONFIG proxy.config.net.listen_backlog INT 2048
===========================================================================

4)Here is the curl request that gave me all zero result with the said api :
$ curl -4x localhost:3128 www.purple.com -vvv -o /tmp/1
* About to connect() to proxy localhost port 3128 (#0)
*   Trying 127.0.0.1...
* Adding handle: conn: 0x8028c9600
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x8028c9600) send_pipe: 1, recv_pipe: 0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to localhost (127.0.0.1) port 3128 (#0)
> GET HTTP://www.purple.com/ HTTP/1.1
> User-Agent: curl/7.31.0
> Host: www.purple.com
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< Date: Tue, 22 Aug 2017 07:32:54 GMT
* Server ATS/6.2.1 is not blacklisted
< Server: ATS/6.2.1
< Last-Modified: Wed, 19 Jul 2017 16:09:59 GMT
< ETag: "5f4-554addd2310c6"
< Accept-Ranges: bytes
< Content-Type: text/html
< Content-Length: 1524
< Age: 1
< Proxy-Connection: keep-alive
< Via: http/1.1 (ApacheTrafficServer/6.2.1)
<
  0  1524    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0{ [data not shown]
100  1524  100  1524    0     0   1814      0 --:--:-- --:--:-- --:--:--  1814
* Connection #0 to host localhost left intact

5)Is there any structure which gets populated with the ip headers of the packet which we can directly access from the plugin ?

Please let me know if there is something which can help me resolve this.
thanks,
gaurav

On Mon, Aug 21, 2017 at 7:55 PM, Masakazu Kitajo <[hidden email]> wrote:
Hmm, maybe the response is served from cache?

AFAIK, there's no alternative API. It should return the address if available, or it should be fixed. Which version are you using?

It would be helpful if you could share your records.config, remap.config, and HTTP request / response headers.

Thanks,
Masakazu


On Mon, Aug 21, 2017 at 10:35 PM, Gaurav Bansal <[hidden email]> wrote:
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> wrote:
Hi Gaurav,

Here you are. These are C++ API but you can use TSHttpTxn* functions directly if you use C API.

You can find some of them on our documentation (not all of them, unfortunately).

Thanks,
Masakazu


On Wed, Aug 16, 2017 at 7:55 PM, Gaurav Bansal <[hidden email]> 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






Reply | Threaded
Open this post in threaded view
|

Re: getting source/destination ip-address/port number in plugin

Alan Carroll-2
There is and it is accessible through the API Masakazu pointed out. Caching can affect the result because if there is a cache hit no connection to the origin is created and therefore no IP address for it is present. ATS doesn't do an IP address lookup on the request FQDN if that address won't be used. I would try using different URLs and see if the result varies, or set 'CONFIG proxy.config.http.cache.http INT 1' to 0.

Reply | Threaded
Open this post in threaded view
|

Re: getting source/destination ip-address/port number in plugin

Masakazu Kitajo-3
I confirmed below with the foo plugin:
- TSHttpTxnServerAddrGet works on version 6.2.1
- Both forward proxy and reverse proxy are fine
- Cache affects the result (as Alan pointed out)

Gaurav, can you try TS_HTTP_READ_RESPONSE_HDR_HOOK?  You can get the address on this hook for sure, if the event happened. If it doesn't happen, it means that the address doesn't exist because no connection was made.



On Wed, Aug 23, 2017 at 5:52 AM, Alan Carroll <[hidden email]> wrote:
There is and it is accessible through the API Masakazu pointed out. Caching can affect the result because if there is a cache hit no connection to the origin is created and therefore no IP address for it is present. ATS doesn't do an IP address lookup on the request FQDN if that address won't be used. I would try using different URLs and see if the result varies, or set 'CONFIG proxy.config.http.cache.http INT 1' to 0.