]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: server: Record ip:port in connection object for later use.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Fri, 29 Jun 2018 13:19:27 +0000 (15:19 +0200)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Mon, 2 Jul 2018 18:09:42 +0000 (20:09 +0200)
src/lib-http/http-server-connection.c
src/lib-http/http-server-private.h

index 08eec4bddc9afa25ac72db0ab2e98af2726348ef..a3715ae2fd5e74a99a4713157be5ba0af1f5af2a 100644 (file)
@@ -1067,8 +1067,6 @@ http_server_connection_create(struct http_server *server,
        const struct http_server_settings *set = &server->set;
        struct http_server_connection *conn;
        static unsigned int id = 0;
-       struct ip_addr addr;
-       in_port_t port;
        const char *name;
 
        i_assert(!server->shutting_down);
@@ -1100,10 +1098,10 @@ http_server_connection_create(struct http_server *server,
        }
 
        /* get a name for this connection */
-       if (fd_in != fd_out || net_getpeername(fd_in, &addr, &port) < 0) {
+       if (fd_in != fd_out || net_getpeername(fd_in, &conn->ip, &conn->port) < 0) {
                name = t_strdup_printf("[%u]", id);
        } else {
-               if (addr.family == 0) {
+               if (conn->ip.family == 0) {
                        struct net_unix_cred cred;
 
                        if (net_getunixcred(fd_in, &cred) < 0) {
@@ -1114,10 +1112,14 @@ http_server_connection_create(struct http_server *server,
                                name = t_strdup_printf
                                        ("unix:pid=%ld,uid=%ld [%u]", (long)cred.pid, (long)cred.uid, id);
                        }
-               } else if (addr.family == AF_INET6) {
-                       name = t_strdup_printf("[%s]:%u [%u]", net_ip2addr(&addr), port, id);
+               } else if (conn->ip.family == AF_INET6) {
+                       name = t_strdup_printf("[%s]:%u [%u]",
+                                              net_ip2addr(&conn->ip),
+                                              conn->port, id);
                } else {
-                       name = t_strdup_printf("%s:%u [%u]", net_ip2addr(&addr), port, id);
+                       name = t_strdup_printf("%s:%u [%u]",
+                                              net_ip2addr(&conn->ip),
+                                              conn->port, id);
                }
        }
 
index de95bf0cb0ef7e12d2724e5ec43eb49aa213c454..5820f67bfcb5ad063d36d368886eb0510882213e 100644 (file)
@@ -129,6 +129,8 @@ struct http_server_connection {
        const struct http_server_callbacks *callbacks;
        void *context;
 
+       struct ip_addr ip;
+       in_port_t port;
        unsigned int id; // DEBUG
 
        struct timeout *to_input, *to_idle;