Skip to content

Commit

Permalink
lib: connection - Turn connection_init_client_ip*() name parameter in…
Browse files Browse the repository at this point in the history
…to an explicit hostname.

This way, the default connection name will be hostname:ip when hostname is not
NULL. This will be helpful once the connection API has TLS support.
  • Loading branch information
stephanbosch committed Mar 7, 2019
1 parent 06c4d34 commit 062ed1d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/lib-smtp/smtp-client-connection.c
Expand Up @@ -1488,9 +1488,6 @@ static void
smtp_client_connection_connect_next_ip(struct smtp_client_connection *conn)
{
const struct ip_addr *ip, *my_ip = &conn->set.my_ip;
const char *conn_name = (conn->host_is_ip ? NULL :
t_strdup_printf("%s:%u", conn->host,
conn->port));

timeout_remove(&conn->to_connect);

Expand All @@ -1506,7 +1503,8 @@ smtp_client_connection_connect_next_ip(struct smtp_client_connection *conn)
}

connection_init_client_ip_from(conn->client->conn_list, &conn->conn,
conn_name, ip, conn->port, my_ip);
(conn->host_is_ip ? NULL : conn->host),
ip, conn->port, my_ip);

smtp_client_connection_do_connect(conn);
}
Expand Down
12 changes: 9 additions & 3 deletions src/lib/connection.c
Expand Up @@ -590,10 +590,16 @@ void connection_init_client_fd(struct connection_list *list,
}

void connection_init_client_ip_from(struct connection_list *list,
struct connection *conn, const char *name,
struct connection *conn,
const char *hostname,
const struct ip_addr *ip, in_port_t port,
const struct ip_addr *my_ip)
{
const char *name = NULL;

if (hostname != NULL)
name = t_strdup_printf("%s:%u", hostname, port);

i_assert(list->set.client);

conn->remote_ip = *ip;
Expand All @@ -615,10 +621,10 @@ void connection_init_client_ip_from(struct connection_list *list,
}

void connection_init_client_ip(struct connection_list *list,
struct connection *conn, const char *name,
struct connection *conn, const char *hostname,
const struct ip_addr *ip, in_port_t port)
{
connection_init_client_ip_from(list, conn, name, ip, port, NULL);
connection_init_client_ip_from(list, conn, hostname, ip, port, NULL);
}

void connection_init_client_unix(struct connection_list *list,
Expand Down
5 changes: 3 additions & 2 deletions src/lib/connection.h
Expand Up @@ -174,11 +174,12 @@ void connection_init_server_ip(struct connection_list *list,
const struct ip_addr *remote_ip,
in_port_t remote_port) ATTR_NULL(3, 6);
void connection_init_client_ip(struct connection_list *list,
struct connection *conn, const char *name,
struct connection *conn, const char *hostname,
const struct ip_addr *ip, in_port_t port)
ATTR_NULL(3);
void connection_init_client_ip_from(struct connection_list *list,
struct connection *conn, const char *name,
struct connection *conn,
const char *hostname,
const struct ip_addr *ip, in_port_t port,
const struct ip_addr *my_ip) ATTR_NULL(3,6);
void connection_init_client_unix(struct connection_list *list,
Expand Down

0 comments on commit 062ed1d

Please sign in to comment.