]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: connection: Fix naming of remote/local_ip/port
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 22 Nov 2019 13:39:14 +0000 (15:39 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 26 Nov 2019 09:56:35 +0000 (11:56 +0200)
For client connections these fields were duplicated as "ip", "port" and
"client_ip".

Now make it explicit that client connections only have source_* and dest_*,
while server connections only have local_* and remote_*.

src/lib/connection.c

index 7b2e212701fa0077f8764f54487556a156d41d16..82c537d2068d830090728c7f3c2ab2a055396b6a 100644 (file)
@@ -353,16 +353,21 @@ void connection_update_event(struct connection *conn)
        event_set_append_log_prefix(conn->event, str_c(prefix));
 
        if (conn->local_ip.family > 0) {
-               event_add_str(conn->event, "local_ip",
+               event_add_str(conn->event, conn->list->set.client ?
+                             "source_ip" : "local_ip",
                              net_ip2addr(&conn->local_ip));
        }
 
        if (conn->remote_ip.family > 0) {
-               event_add_str(conn->event, "remote_ip",
+               event_add_str(conn->event, conn->list->set.client ?
+                             "dest_ip" : "remote_ip",
                              net_ip2addr(&conn->remote_ip));
        }
-       if (conn->remote_port > 0)
-               event_add_int(conn->event, "remote_port", conn->remote_port);
+       if (conn->remote_port > 0) {
+               event_add_int(conn->event, conn->list->set.client ?
+                             "dest_port" : "remote_port",
+                             conn->remote_port);
+       }
 
        if (conn->remote_pid != (pid_t)-1)
                event_add_int(conn->event, "remote_pid", conn->remote_pid);
@@ -616,11 +621,7 @@ void connection_init_client_ip_from(struct connection_list *list,
        connection_init(list, conn, name);
 
        event_field_clear(conn->event, "socket_path");
-
-       if (my_ip != NULL)
-               event_add_str(conn->event, "client_ip", net_ip2addr(my_ip));
-       event_add_str(conn->event, "ip", net_ip2addr(ip));
-       event_add_str(conn->event, "port", dec2str(port));
+       connection_update_event(conn);
 }
 
 void connection_init_client_ip(struct connection_list *list,