]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: client: Add smtp_client_connection_create_ip().
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 10 Mar 2018 18:13:24 +0000 (19:13 +0100)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 12 Mar 2018 14:28:40 +0000 (16:28 +0200)
This allows making SMTP client connections without performing a DNS lookup. The
optional hostname parameter is used to verify the hostname in the SSL
certificate from the server, if any.

src/lib-smtp/smtp-client-connection.c
src/lib-smtp/smtp-client-connection.h

index a024d8aabb1155da7b5f0d3c631680d68d2e9b27..811dde546b70aa576e48a4c40d37d67cbcf68366 100644 (file)
@@ -1712,6 +1712,25 @@ smtp_client_connection_create(struct smtp_client *client,
        return conn;
 }
 
+struct smtp_client_connection *
+smtp_client_connection_create_ip(struct smtp_client *client,
+       enum smtp_protocol protocol, const struct ip_addr *ip, in_port_t port,
+       const char *hostname, enum smtp_client_connection_ssl_mode ssl_mode,
+       const struct smtp_client_settings *set)
+{
+       struct smtp_client_connection *conn;
+
+       if (hostname == NULL)
+               hostname = net_ip2addr(ip);
+
+       conn = smtp_client_connection_create(client, protocol, hostname, port,
+                                            ssl_mode, set);
+       conn->ips_count = 1;
+       conn->ips = i_new(struct ip_addr, conn->ips_count);
+       conn->ips[0] = *ip;
+       return conn;
+}
+
 void smtp_client_connection_ref(struct smtp_client_connection *conn)
 {
        i_assert(conn->refcount >= 0);
index 09f4c9937a4b1da1110524e92b6c630f26f5c38d..31ebfdb1e9741fff0eec1aba0d64c01f1549e4de 100644 (file)
@@ -40,6 +40,12 @@ smtp_client_connection_create(struct smtp_client *client,
        enum smtp_client_connection_ssl_mode ssl_mode,
        const struct smtp_client_settings *set)
        ATTR_NULL(6);
+struct smtp_client_connection *
+smtp_client_connection_create_ip(struct smtp_client *client,
+       enum smtp_protocol protocol, const struct ip_addr *ip, in_port_t port,
+       const char *hostname, enum smtp_client_connection_ssl_mode ssl_mode,
+       const struct smtp_client_settings *set)
+       ATTR_NULL(5,7);
 void smtp_client_connection_ref(struct smtp_client_connection *conn);
 void smtp_client_connection_unref(struct smtp_client_connection **_conn);
 void smtp_client_connection_close(struct smtp_client_connection **_conn);