summaryrefslogtreecommitdiff
path: root/http-internal.h
diff options
context:
space:
mode:
authorAzat Khuzhin <a3at.mail@gmail.com>2013-10-01 19:12:13 +0400
committerNick Mathewson <nickm@torproject.org>2013-10-14 11:22:29 -0400
commit0c7f0405e36c45c88139189dd4c720aa0c4903f5 (patch)
tree6693dd271741ea3f3b16c55e60d02ee2533729da /http-internal.h
parent4464bd23963267615d759eb6377cf1bb13f7d47f (diff)
downloadlibevent-0c7f0405e36c45c88139189dd4c720aa0c4903f5.tar.gz
http: implement new evhttp_connection_get_addr() api.
Basically tcp final handshake looks like this: (C - client, S - server) ACK[C] - FIN/ACK[S] - FIN/ACK[S] - ACK [C] However there are servers, that didn't close connection like this, while it is still _considered_ as valid, and using libevent http layer we can do requests to such servers. Modified handshake: (C - client, S - server) ACK[C] - RST/ACK[S] - RST/ACK[S] And in this case we can't extract IP address from socket, because it is already closed, and getpeername() will return: "transport endpoint is not connected". So we need to store address that we are connecting to, after we know it, and that is what this patch do. I have reproduced it, however it have some extra packages. (I will try to fix it) https://github.com/azat/nfq-examples/blob/master/nfqnl_rst_fin.c
Diffstat (limited to 'http-internal.h')
-rw-r--r--http-internal.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/http-internal.h b/http-internal.h
index d25753bb..82dd402a 100644
--- a/http-internal.h
+++ b/http-internal.h
@@ -99,6 +99,13 @@ struct evhttp_connection {
struct event_base *base;
struct evdns_base *dns_base;
+
+ /* Saved conn_addr, to extract IP address from it.
+ *
+ * Because some servers may reset/close connection without waiting clients,
+ * in that case we can't extract IP address even in close_cb.
+ * So we need to save it, just after we connected to remote server. */
+ struct sockaddr_storage *conn_address;
};
/* A callback for an http server */