const char *host, unsigned int port)
{
struct dns_lookup_settings dns_lookup_set;
+ struct ip_addr *ips;
+ unsigned int ips_count;
+ int ret;
client->input_state = LMTP_INPUT_STATE_GREET;
client->host = p_strdup(client->pool, host);
client->set.dns_client_socket_path;
dns_lookup_set.timeout_msecs = LMTP_CLIENT_DNS_LOOKUP_TIMEOUT_MSECS;
- if (net_addr2ip(host, &client->ip) < 0) {
- if (dns_lookup(host, &dns_lookup_set,
- lmtp_client_dns_done, client) < 0)
+ if (net_addr2ip(host, &client->ip) == 0) {
+ /* IP address */
+ } else if (dns_lookup_set.dns_client_socket_path == NULL) {
+ /* no dns-client, use blocking lookup */
+ ret = net_gethostbyname(host, &ips, &ips_count);
+ if (ret != 0) {
+ i_error("lmtp client: DNS lookup of %s failed: %s",
+ client->host, net_gethosterror(ret));
return -1;
+ }
+ client->ip = ips[0];
} else {
- if (lmtp_client_connect(client) < 0)
+ if (dns_lookup(host, &dns_lookup_set,
+ lmtp_client_dns_done, client) < 0)
return -1;
+ return 0;
}
+
+ if (lmtp_client_connect(client) < 0)
+ return -1;
return 0;
}