#include "auth.h"
#include "dns-lookup.h"
-#define AUTH_DNS_SOCKET_PATH "dns-client"
-#define AUTH_DNS_DEFAULT_TIMEOUT_MSECS (1000*10)
#define AUTH_DNS_IDLE_TIMEOUT_MSECS (1000*60)
#define AUTH_DNS_CACHE_TTL_SECS 10
{
struct auth_passdb *passdb;
struct auth_userdb *userdb;
- struct dns_client_settings dns_set;
- struct dns_client_parameters dns_params;
+ const char *error;
+ const struct dns_client_parameters params = {
+ .idle_timeout_msecs = AUTH_DNS_IDLE_TIMEOUT_MSECS,
+ .cache_ttl_secs = AUTH_DNS_CACHE_TTL_SECS
+ };
for (passdb = auth->masterdbs; passdb != NULL; passdb = passdb->next)
auth_passdb_init(passdb);
for (userdb = auth->userdbs; userdb != NULL; userdb = userdb->next)
userdb_init(userdb->userdb);
- i_zero(&dns_set);
- dns_set.dns_client_socket_path = AUTH_DNS_SOCKET_PATH;
- dns_set.timeout_msecs = AUTH_DNS_DEFAULT_TIMEOUT_MSECS;
- dns_params.idle_timeout_msecs = AUTH_DNS_IDLE_TIMEOUT_MSECS;
- dns_params.cache_ttl_secs = AUTH_DNS_CACHE_TTL_SECS;
-
- auth->dns_client = dns_client_init(&dns_set, &dns_params, NULL);
+ if (dns_client_init(¶ms, auth_event, &auth->dns_client, &error) < 0)
+ i_fatal("%s", error);
}
static void auth_deinit(struct auth *auth)
AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib \
- -I$(top_srcdir)/src/lib-test
+ -I$(top_srcdir)/src/lib-settings \
+ -I$(top_srcdir)/src/lib-var-expand \
+ -I$(top_srcdir)/src/lib-test \
+ -DPKG_RUNDIR=\""$(rundir)"\"
libdns_client_la_SOURCES = \
dns-client-cache.c \
+ dns-client-settings.c \
dns-lookup.c
headers = \
test_libs = \
libdns-client.la \
+ ../lib-settings/libsettings.la \
../lib-dns/libdns.la \
../lib-test/libtest.la \
+ ../lib-var-expand/libvar_expand.la \
../lib/liblib.la
test_dns_lookup_SOURCES = test-dns-lookup.c
--- /dev/null
+/* Copyright (c) 2005-2024 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "settings-parser.h"
+#include "dns-lookup.h"
+#include "strfuncs.h"
+
+static bool dns_client_settings_check(void *_set, pool_t pool,
+ const char **error_r);
+
+#undef DEF
+#define DEF(type, name) \
+ SETTING_DEFINE_STRUCT_##type(#name, name, struct dns_client_settings)
+
+#undef DEF_MSECS
+#define DEF_MSECS(type, name) \
+ SETTING_DEFINE_STRUCT_##type("dns_client_"#name, name##_msecs, struct dns_client_settings)
+
+static const struct setting_define dns_client_setting_defines[] = {
+ DEF(STR_HIDDEN, dns_client_socket_path),
+ DEF(STR_HIDDEN, base_dir),
+ DEF_MSECS(TIME_MSECS, timeout),
+
+ SETTING_DEFINE_LIST_END
+};
+
+static const struct dns_client_settings dns_client_default_settings = {
+ .dns_client_socket_path = "dns-client",
+ .base_dir = PKG_RUNDIR,
+ .timeout_msecs = 10 * 1000,
+};
+
+const struct setting_parser_info dns_client_setting_parser_info = {
+ .name = "dns_client",
+
+ .defines = dns_client_setting_defines,
+ .defaults = &dns_client_default_settings,
+
+ .pool_offset1 = 1 + offsetof(struct dns_client_settings, pool),
+ .struct_size = sizeof(struct dns_client_settings),
+ .check_func = dns_client_settings_check,
+};
+
+/* <settings checks> */
+static bool
+dns_client_settings_check(void *_set, pool_t pool, const char **error_r ATTR_UNUSED)
+{
+ struct dns_client_settings *set = _set;
+ size_t len;
+ len = strlen(set->base_dir);
+ if (len > 0 &&
+ set->dns_client_socket_path[0] != '\0' &&
+ !str_begins_with(set->dns_client_socket_path, "./")) {
+ if (set->base_dir[len - 1] == '/')
+ set->base_dir = p_strndup(pool, set->base_dir, len);
+ set->dns_client_socket_path = p_strconcat(pool, set->base_dir, "/",
+ set->dns_client_socket_path, NULL);
+ }
+ return TRUE;
+}
+/* </settings checks> */
#include "time-util.h"
#include "dns-client-cache.h"
#include "dns-lookup.h"
+#include "settings.h"
static struct event_category event_category_dns = {
.name = "dns"
event_create_passthrough(lookup->event)->
set_name("dns_request_finished");
- if (!lookup->cached) {
+ if (!lookup->cached && lookup->client != NULL) {
dns_client_cache_entry(lookup->client->cache, lookup->cache_key,
&lookup->result);
}
lookup->context = context;
lookup->ptr_lookup = ptr_lookup;
lookup->result.ret = EAI_FAIL;
- if (event == NULL)
+ if (event == NULL && client != NULL)
lookup->event = event_create(client->conn.event);
else {
lookup->event = event_create(event);
return lookup;
}
-int dns_lookup(const char *host, const struct dns_client_settings *set,
- const struct dns_client_parameters *params,
+static int
+dns_client_init_handle_failure(const struct dns_client_parameters *params,
+ struct event *event_parent,
+ const char *cmd_param,
+ bool ptr_lookup,
+ dns_lookup_callback_t *callback,
+ void *context,
+ struct dns_client **client_r)
+{
+ const char *error;
+ int ret = dns_client_init(params, event_parent, client_r, &error);
+ if (ret < 0) {
+ pool_t pool = pool_alloconly_create("dns lookup", 512);
+ struct dns_lookup *tmp_lookup = dns_lookup_create(pool, NULL,
+ ptr_lookup,
+ cmd_param,
+ event_parent,
+ callback, context);
+ tmp_lookup->result.error = error;
+ dns_lookup_callback(tmp_lookup);
+ dns_lookup_free(&tmp_lookup);
+ }
+ return ret;
+}
+
+int dns_lookup(const char *host, const struct dns_client_parameters *params,
struct event *event_parent, dns_lookup_callback_t *callback,
void *context, struct dns_lookup **lookup_r)
{
struct dns_client *client;
+ int ret = dns_client_init_handle_failure(params, event_parent,
+ host, FALSE, callback,
+ context, &client);
i_assert(params == NULL || params->cache_ttl_secs == 0);
- client = dns_client_init(set, params, event_parent);
+ if (ret < 0)
+ return -1;
client->deinit_client_at_free = TRUE;
return dns_client_lookup(client, host, client->conn.event, callback,
context, lookup_r);
}
int dns_lookup_ptr(const struct ip_addr *ip,
- const struct dns_client_settings *set,
const struct dns_client_parameters *params,
struct event *event_parent,
dns_lookup_callback_t *callback, void *context,
struct dns_client *client;
i_assert(params == NULL || params->cache_ttl_secs == 0);
- client = dns_client_init(set, params, event_parent);
+ if (dns_client_init_handle_failure(params, event_parent,
+ net_ip2addr(ip), TRUE,
+ callback, context, &client) < 0)
+ return -1;
client->deinit_client_at_free = TRUE;
return dns_client_lookup_ptr(client, ip, client->conn.event,
callback, context, lookup_r);
*_lookup = NULL;
timeout_remove(&lookup->to);
- if (client->deinit_client_at_free)
- dns_client_deinit(&client);
- else if (client->head == NULL && client->connected &&
- client->to_idle == NULL) {
- client->to_idle = timeout_add_to(client->ioloop,
- client->idle_timeout_msecs,
- dns_client_idle_timeout, client);
+ if (client != NULL) {
+ if (client->deinit_client_at_free)
+ dns_client_deinit(&client);
+ else if (client->head == NULL && client->connected &&
+ client->to_idle == NULL) {
+ client->to_idle = timeout_add_to(client->ioloop,
+ client->idle_timeout_msecs,
+ dns_client_idle_timeout, client);
+ }
}
event_unref(&lookup->event);
pool_unref(&lookup->pool);
.client = TRUE,
};
-struct dns_client *dns_client_init(const struct dns_client_settings *set,
- const struct dns_client_parameters *params,
- struct event *event_parent)
+int dns_client_init(const struct dns_client_parameters *params,
+ struct event *event_parent,
+ struct dns_client **client_r,
+ const char **error_r)
{
struct dns_client *client;
-
- i_assert(set->dns_client_socket_path[0] != '\0');
+ struct dns_client_settings *set;
+ i_assert(event_parent != NULL);
+ if (settings_get(event_parent, &dns_client_setting_parser_info, 0, &set, error_r) < 0)
+ return -1;
client = i_new(struct dns_client, 1);
client->timeout_msecs = set->timeout_msecs;
client->cache = dns_client_cache_init(params->cache_ttl_secs,
dns_client_cache_refresh, client);
}
- return client;
+ settings_free(set);
+ *client_r = client;
+ return 0;
}
void dns_client_deinit(struct dns_client **_client)
struct dns_lookup **lookup_r)
{
int ret;
+ if (client->path[0] == '\0') {
+ /* Fallback to gethostbyname() */
+ pool_t pool = pool_alloconly_create("dns_lookup", 512);
+ struct dns_lookup *lookup = dns_lookup_create(pool, NULL,
+ FALSE, NULL,
+ client->conn.event_parent,
+ callback, context);
+ *lookup_r = lookup;
+ unsigned int ips_count;
+ struct ip_addr *ips;
+ ret = lookup->result.ret = net_gethostbyname(host, &ips, &ips_count);
+ if (lookup->result.ret != 0) {
+ lookup->result.error =
+ t_strdup_printf("net_gethostbyname() failed: %s",
+ net_gethosterror(lookup->result.ret));
+ }
+ lookup->result.ips_count = ips_count;
+ if (ips_count > 0)
+ lookup->result.ips =
+ p_memdup(pool, ips,
+ sizeof(struct ip_addr) * ips_count);
+ dns_lookup_callback(lookup);
+ dns_lookup_free(&lookup);
+ return ret;
+ }
T_BEGIN {
ret = dns_client_lookup_common(client, "IP", host, FALSE, event,
callback, context, lookup_r);
#endif
struct dns_lookup;
+struct dns_client;
struct dns_client_settings {
+ pool_t pool;
const char *dns_client_socket_path;
+ const char *base_dir;
unsigned int timeout_msecs;
};
started, -1 if there was an error communicating with the UNIX socket.
When failing with -1, the callback is called before returning from the
function. */
-int dns_lookup(const char *host, const struct dns_client_settings *set,
- const struct dns_client_parameters *params,
- struct event *event_parent,
- dns_lookup_callback_t *callback, void *context,
- struct dns_lookup **lookup_r) ATTR_NULL(4);
-#define dns_lookup(host, set, params, event_parent, callback, context, lookup_r) \
+int dns_lookup(const char *host, const struct dns_client_parameters *params,
+ struct event *event_parent, dns_lookup_callback_t *callback,
+ void *context, struct dns_lookup **lookup_r) ATTR_NULL(4);
+#define dns_lookup(host, params, event_parent, callback, context, lookup_r) \
dns_lookup(host - \
CALLBACK_TYPECHECK(callback, void (*)( \
const struct dns_lookup_result *, typeof(context))), \
- set, params, event_parent, (dns_lookup_callback_t *)callback, context, lookup_r)
+ params, event_parent, (dns_lookup_callback_t *)callback, context, lookup_r)
int dns_lookup_ptr(const struct ip_addr *ip,
- const struct dns_client_settings *set,
const struct dns_client_parameters *params,
struct event *event_parent,
dns_lookup_callback_t *callback, void *context,
struct dns_lookup **lookup_r) ATTR_NULL(4);
-#define dns_lookup_ptr(host, set, params, event_parent, callback, context, lookup_r) \
+#define dns_lookup_ptr(host, params, event_parent, callback, context, lookup_r) \
dns_lookup_ptr(host - \
CALLBACK_TYPECHECK(callback, void (*)( \
const struct dns_lookup_result *, typeof(context))), \
- set, params, event_parent, \
+ params, event_parent, \
(dns_lookup_callback_t *)callback, context, lookup_r)
/* Abort the DNS lookup without calling the callback. */
void dns_lookup_abort(struct dns_lookup **lookup);
void dns_lookup_switch_ioloop(struct dns_lookup *lookup);
/* Alternative API for clients that need to do multiple DNS lookups. */
-struct dns_client *dns_client_init(const struct dns_client_settings *set,
- const struct dns_client_parameters *params,
- struct event *event_parent);
+int dns_client_init(const struct dns_client_parameters *params,
+ struct event *event_parent,
+ struct dns_client **client_r,
+ const char **error_r);
void dns_client_deinit(struct dns_client **client);
/* Connect immediately to the dns-lookup socket. */
void dns_client_switch_ioloop(struct dns_client *client);
+extern const struct setting_parser_info dns_client_setting_parser_info;
+
#endif
#include "ostream.h"
#include "connection.h"
#include "dns-lookup.h"
+#include "settings.h"
#include <unistd.h>
#define TEST_SOCKET_NAME ".test-dns-server"
+static struct settings_simple test_set;
+
+static const char *const set_dns_test[] = {
+ "dns_client_socket_path", TEST_SOCKET_NAME,
+ "base_dir", "",
+ "dns_client_timeout", "1s",
+ NULL
+};
+
static const struct {
const char *name;
const char *reply;
static void test_dns_expect_result_ips(const char *name, const char *result)
{
- const struct dns_client_settings set = {
- .dns_client_socket_path = TEST_SOCKET_NAME,
- .timeout_msecs = 1000,
- };
struct dns_lookup *lookup;
struct test_expect_result ctx = {
.ret = result == NULL ? -1 : 0,
.result = result
};
- test_assert(dns_lookup(name, &set, NULL, NULL, test_callback_ips,
- &ctx, &lookup) == 0);
+ test_assert(dns_lookup(name, NULL, test_set.event, test_callback_ips, &ctx, &lookup) == 0);
io_loop_run(test_server.loop);
}
static void test_dns_expect_result_name(const char *name, const char *result)
{
- const struct dns_client_settings set = {
- .dns_client_socket_path = TEST_SOCKET_NAME,
- .timeout_msecs = 1000,
- };
struct dns_lookup *lookup;
struct test_expect_result ctx = {
.ret = result == NULL ? -1 : 0,
};
struct ip_addr addr;
i_assert(net_addr2ip(name, &addr) == 0);
- test_assert(dns_lookup_ptr(&addr, &set, NULL, NULL, test_callback_name,
- &ctx, &lookup) == 0);
+ test_assert(dns_lookup_ptr(&addr, NULL, test_set.event, test_callback_name, &ctx, &lookup) == 0);
io_loop_run(test_server.loop);
}
static void test_dns_lookup(void)
{
test_begin("dns lookup");
+ settings_simple_update(&test_set, set_dns_test);
create_dns_server(&test_server);
test_dns_expect_result_ips("localhost", "127.0.0.1\t::1");
test_begin("dns lookup (timeout)");
create_dns_server(&test_server);
- const struct dns_client_settings set = {
- .dns_client_socket_path = TEST_SOCKET_NAME,
- .timeout_msecs = 1000,
- };
struct dns_lookup *lookup;
struct test_expect_result ctx = {
.ret = EAI_FAIL,
.result = NULL,
};
- test_assert(dns_lookup("waitfor1500", &set, NULL, NULL, test_callback_ips,
- &ctx, &lookup) == 0);
+ test_assert(dns_lookup("waitfor1500", NULL, test_set.event,
+ test_callback_ips, &ctx, &lookup) == 0);
io_loop_run(current_ioloop);
destroy_dns_server(&test_server);
test_begin("dns lookup (abort)");
create_dns_server(&test_server);
- const struct dns_client_settings set = {
- .dns_client_socket_path = TEST_SOCKET_NAME,
- .timeout_msecs = 1000,
- };
struct dns_lookup *lookup;
struct test_expect_result ctx = {
.ret = -4,
.result = NULL,
};
- test_assert(dns_lookup("waitfor1500", &set, NULL, NULL, test_callback_ips,
- &ctx, &lookup) == 0);
+ test_assert(dns_lookup("waitfor1500", NULL, test_set.event,
+ test_callback_ips, &ctx, &lookup) == 0);
struct timeout *to = timeout_add_short(100, io_loop_stop, current_ioloop);
io_loop_run(current_ioloop);
timeout_remove(&to);
struct dns_lookup *lookup;
struct timeout *to;
struct event *event = event_create(NULL);
+ struct dns_client *client;
+ int init_res;
+ const char *err;
test_begin("dns lookup (cached)");
create_dns_server(&test_server);
- const struct dns_client_settings set = {
- .dns_client_socket_path = TEST_SOCKET_NAME,
- .timeout_msecs = 1000,
- };
-
const struct dns_client_parameters params = {
.cache_ttl_secs = 4,
};
-
- struct dns_client *client = dns_client_init(&set, ¶ms, event);
+ init_res = dns_client_init(¶ms, test_set.event, &client, &err);
+ test_assert(init_res == 0);
/* lookup localhost */
ctx.result = "127.0.0.1\t::1";
NULL
};
- return test_run(test_functions);
+ lib_init();
+ settings_simple_init(&test_set, set_dns_test);
+ int ret = test_run(test_functions);
+ settings_simple_deinit(&test_set);
+ lib_deinit();
+ return ret;
}
.error = ctx->error,
};
doveadm_client_callback(conn, &reply);
+ event_unref(&conn->conn.event);
pool_unref(&conn->pool);
}
{
struct doveadm_client_dns_lookup_context *ctx =
p_new(conn->pool, struct doveadm_client_dns_lookup_context, 1);
- struct dns_client_settings dns_set;
-
- i_zero(&dns_set);
- dns_set.dns_client_socket_path = conn->set.dns_client_socket_path;
- dns_set.timeout_msecs = DOVEADM_CLIENT_DNS_TIMEOUT_MSECS;
ctx->conn = conn;
- if (dns_lookup(conn->set.hostname, &dns_set, NULL, conn->conn.event,
+ if (dns_lookup(conn->set.hostname, NULL, conn->conn.event,
doveadm_client_dns_lookup_callback, ctx,
&conn->dns_lookup) != 0) {
*error_r = t_strdup(ctx->error);
conn = p_new(pool, struct doveadm_client, 1);
conn->pool = pool;
conn->refcount = 1;
+ /* DNS lookup needs the event before connection is initialized. */
+ conn->conn.event = event_create(NULL);
doveadm_client_settings_dup(set, &conn->set, pool);
if (set->socket_path != NULL) {
} else if (doveadm_client_resolve_hostname(conn, &error) != 0) {
*error_r = t_strdup(error);
+ event_unref(&conn->conn.event);
pool_unref(&pool);
return -1;
}
#include "time-util.h"
#include "dns-lookup.h"
#include "http-response-parser.h"
+#include "settings.h"
#include "http-client-private.h"
{
struct http_client_host_shared *hshared = host->shared;
struct http_client_context *cctx = hshared->cctx;
- struct dns_client_settings dns_set;
i_assert(!hshared->explicit_ip);
i_assert(hshared->dns_lookup == NULL);
if (cctx->dns_client != NULL) {
- e_debug(hshared->event, "Performing asynchronous DNS lookup");
+ e_debug(host->client->event, "Performing asynchronous DNS lookup");
+ /* Note: dns_client_lookup() takes DNS settings from cctx->dns_client
+ and may differ from host->client DNS settings */
(void)dns_client_lookup(cctx->dns_client, hshared->name,
- hshared->event,
+ host->client->event,
http_client_host_shared_dns_callback,
hshared, &hshared->dns_lookup);
- } else if (cctx->dns_client_socket_path != NULL) {
+ } else {
struct ioloop *prev_ioloop = current_ioloop;
- i_assert(cctx->dns_lookup_timeout_msecs > 0);
- e_debug(hshared->event, "Performing asynchronous DNS lookup");
- i_zero(&dns_set);
- dns_set.dns_client_socket_path = cctx->dns_client_socket_path;
- dns_set.timeout_msecs = cctx->dns_lookup_timeout_msecs;
+ /* host->client->event is used in order to
+ get client-specific DNS settings. */
+ e_debug(host->client->event, "Performing asynchronous DNS lookup");
io_loop_set_current(cctx->ioloop);
- (void)dns_lookup(hshared->name, &dns_set, NULL, hshared->event,
+ (void)dns_lookup(hshared->name, NULL, host->client->event,
http_client_host_shared_dns_callback,
hshared, &hshared->dns_lookup);
io_loop_set_current(prev_ioloop);
- } else {
- /* FIXME: fully removed in the following commits */
- i_unreached();
}
}
struct ioloop *ioloop;
struct dns_client *dns_client;
- char *dns_client_socket_path;
unsigned int dns_ttl_msecs;
- unsigned int dns_lookup_timeout_msecs;
struct http_client *clients_list;
struct connection_list *conn_list;
static const struct setting_define http_client_setting_defines[] = {
SETTING_DEFINE_STRUCT_STR_HIDDEN("base_dir", base_dir,
struct http_client_settings),
- DEF(STR_HIDDEN, dns_client_socket_path),
DEF_MSECS(TIME_MSECS_HIDDEN, dns_ttl),
DEF(STR_HIDDEN, user_agent),
static const struct http_client_settings http_client_default_settings = {
.base_dir = PKG_RUNDIR,
- .dns_client_socket_path = "dns-client",
.dns_ttl_msecs = HTTP_CLIENT_DEFAULT_DNS_TTL_MSECS,
.user_agent = "",
connection_list_deinit(&cctx->conn_list);
event_unref(&cctx->event);
- i_free(cctx->dns_client_socket_path);
pool_unref(&cctx->pool);
}
/* Revert back to default settings */
cctx->dns_client = NULL;
- i_free(cctx->dns_client_socket_path);
cctx->dns_ttl_msecs = UINT_MAX;
- cctx->dns_lookup_timeout_msecs = HTTP_CLIENT_DEFAULT_DNS_LOOKUP_TIMEOUT_MSECS;
/* Override with available client settings */
for (client = cctx->clients_list; client != NULL;
client = client->next) {
if (cctx->dns_client == NULL)
cctx->dns_client = client->dns_client;
- if (cctx->dns_client_socket_path == NULL &&
- client->set->dns_client_socket_path != NULL &&
- client->set->dns_client_socket_path[0] != '\0') {
- /* FIXME: This base_dir expansion shouldn't be here.
- Maybe support %{set:base_dir}/dns-client?
- The "./" check is to avoid breaking unit tests. */
- if (client->set->dns_client_socket_path[0] == '/' ||
- str_begins_with(client->set->dns_client_socket_path, "./")) {
- cctx->dns_client_socket_path =
- i_strdup(client->set->dns_client_socket_path);
- } else {
- cctx->dns_client_socket_path =
- i_strdup_printf("%s/%s",
- client->set->base_dir,
- client->set->dns_client_socket_path);
- }
- }
if (client->set->dns_ttl_msecs != 0 &&
cctx->dns_ttl_msecs > client->set->dns_ttl_msecs)
cctx->dns_ttl_msecs = client->set->dns_ttl_msecs;
struct http_client_settings {
pool_t pool;
- /* a) If http_client_set_dns_client() is used, all lookups are done
- via it.
- b) If dns_client_socket_path is set, each DNS lookup does its own
- dns-lookup UNIX socket connection.
- c) Otherwise, blocking gethostbyname() lookups are used. */
- const char *dns_client_socket_path;
/* A copy of base_dir setting. FIXME: this should not be here. */
const char *base_dir;
/* How long to cache DNS records internally
#include "http-url.h"
#include "http-request.h"
#include "http-client.h"
+#include "http-client-private.h"
+#include "settings.h"
#include <unistd.h>
#include <sys/signal.h>
#define CLIENT_PROGRESS_TIMEOUT 10
#define SERVER_KILL_TIMEOUT_SECS 20
+static struct settings_root *set_root;
+
static void main_deinit(void);
/*
struct http_client_settings http_client_set;
test_client_defaults(&http_client_set);
- http_client_set.dns_client_socket_path = "./frop";
+ settings_root_override(set_root, "dns_client_socket_path",
+ "./frop", SETTINGS_OVERRIDE_TYPE_CODE);
test_begin("dns service failure");
test_run_client_server(&http_client_set,
test_client_defaults(&http_client_set);
http_client_set.request_timeout_msecs = 2000;
http_client_set.connect_timeout_msecs = 2000;
- http_client_set.dns_client_socket_path = "./dns-test";
+ settings_root_override(set_root, "dns_client_socket_path",
+ "./dns-test", SETTINGS_OVERRIDE_TYPE_CODE);
test_begin("dns timeout");
test_run_client_server(&http_client_set,
struct http_client_settings http_client_set;
test_client_defaults(&http_client_set);
- http_client_set.dns_client_socket_path = "./dns-test";
+ settings_root_override(set_root, "dns_client_socket_path",
+ "./dns-test", SETTINGS_OVERRIDE_TYPE_CODE);
test_begin("dns lookup failure");
test_run_client_server(&http_client_set,
struct http_client_settings http_client_set;
test_client_defaults(&http_client_set);
- http_client_set.dns_client_socket_path = "./dns-test";
http_client_set.dns_ttl_msecs = 1000;
+ settings_root_override(set_root, "dns_client_socket_path",
+ "./dns-test", SETTINGS_OVERRIDE_TYPE_CODE);
test_begin("dns lookup ttl");
test_run_client_server(&http_client_set,
struct http_client_settings http_client_set;
test_client_defaults(&http_client_set);
- http_client_set.dns_client_socket_path = "./dns-test";
http_client_set.dns_ttl_msecs = 10000;
http_client_set.max_idle_time_msecs = 1000;
http_client_set.request_max_attempts = 1;
http_client_set.request_timeout_msecs = 1000;
+ settings_root_override(set_root, "dns_client_socket_path",
+ "./dns-test", SETTINGS_OVERRIDE_TYPE_CODE);
test_begin("reconnect failure");
test_run_client_server(&http_client_set,
test_client_defaults(&http_client_set);
http_client_set.connect_timeout_msecs = 1000;
http_client_set.request_timeout_msecs = 1000;
- http_client_set.dns_client_socket_path = "./dns-test";
+ settings_root_override(set_root, "dns_client_socket_path",
+ "./dns-test", SETTINGS_OVERRIDE_TYPE_CODE);
http_client_set.max_connect_attempts = 4;
test_begin("multi IP attempts (connection refused)");
struct http_client_settings http_client_set;
test_client_defaults(&http_client_set);
- http_client_set.dns_client_socket_path = "./dns-test";
http_client_set.dns_ttl_msecs = 400;
http_client_set.max_parallel_connections = 1;
http_client_set.max_idle_time_msecs = 100;
http_client_set.request_max_attempts = 2;
+ settings_root_override(set_root, "dns_client_socket_path",
+ "./dns-test", SETTINGS_OVERRIDE_TYPE_CODE);
test_begin("idle hosts");
test_run_client_server(&http_client_set,
lib_init();
main_init();
+ struct http_client_context *cctx = http_client_get_global_context();
+ set_root = settings_root_init();
+ event_set_ptr(cctx->event, SETTINGS_EVENT_ROOT, set_root);
while ((c = getopt(argc, argv, "D")) > 0) {
switch (c) {
ret = test_run(test_functions);
test_subprocesses_deinit();
+ event_set_ptr(cctx->event, SETTINGS_EVENT_ROOT, NULL);
+ settings_root_deinit(&set_root);
+
main_deinit();
lib_deinit();
#include "dns-lookup.h"
#include "iostream-ssl.h"
#include "iostream-openssl.h"
+#include "settings.h"
+#include "lib-event-private.h"
#include <fcntl.h>
#include <unistd.h>
+static struct settings_root *set_root;
+
struct http_test_request {
struct io *io;
struct istream *payload;
http_client_request_submit(http_req);
}
+static bool
+test_event_callback(struct event *event,
+ enum event_callback_type type,
+ struct failure_context *ctx ATTR_UNUSED,
+ const char *fmt ATTR_UNUSED,
+ va_list args ATTR_UNUSED)
+{
+ if (type == EVENT_CALLBACK_TYPE_CREATE && event->parent == NULL)
+ event_set_ptr(event, SETTINGS_EVENT_ROOT, set_root);
+ return TRUE;
+}
+
int main(int argc, char *argv[])
{
struct dns_client *dns_client;
- struct dns_client_settings dns_set;
- struct dns_client_parameters dns_params;
struct http_client_settings http_set;
struct http_client_context *http_cctx;
struct http_client *http_client1, *http_client2, *http_client3, *http_client4;
struct ssl_iostream_settings ssl_set;
struct stat st;
const char *error;
+ const char *dns_client_socket_path = PKG_RUNDIR"/dns-client";
lib_init();
+ set_root = settings_root_init();
+ settings_root_override(set_root, "dns_client_timeout", "30s", SETTINGS_OVERRIDE_TYPE_CODE);
+ event_register_callback(test_event_callback);
+
ssl_iostream_openssl_init();
ioloop = io_loop_create();
io_loop_set_running(ioloop);
the binary in all systems (but is in others! so linking
safe-memset.lo directly causes them to fail.) If safe_memset() isn't
included, libssl-iostream plugin loading fails. */
- i_zero_safe(&dns_set);
- dns_set.dns_client_socket_path = PKG_RUNDIR"/dns-client";
- dns_set.timeout_msecs = 30*1000;
- dns_params.idle_timeout_msecs = UINT_MAX;
+ struct dns_client_parameters params = {
+ .idle_timeout_msecs = UINT_MAX,
+ };
+ struct event *event = event_create(NULL);
/* check if there is a DNS client */
- if (access(dns_set.dns_client_socket_path, R_OK|W_OK) == 0) {
- dns_client = dns_client_init(&dns_set, &dns_params, NULL);
+ if (access(dns_client_socket_path, R_OK|W_OK) == 0) {
+ if (dns_client_init(¶ms, event, &dns_client, &error) < 0)
+ i_fatal("%s", error);
if (dns_client_connect(dns_client, &error) < 0)
i_fatal("Couldn't initialize DNS client: %s", error);
} else {
dns_client = NULL;
+ settings_root_override(set_root, "dns_client_socket_path", "", SETTINGS_OVERRIDE_TYPE_CODE);
}
i_zero(&ssl_set);
ssl_set.pool = null_pool;
http_cctx = http_client_context_create();
- struct event *event = event_create(NULL);
event_set_forced_debug(event, TRUE);
http_client1 = http_client_init_shared(http_cctx, &http_set, event);
http_client2 = http_client_init_shared(http_cctx, &http_set, event);
http_client3 = http_client_init_shared(http_cctx, &http_set, event);
http_client4 = http_client_init_shared(http_cctx, &http_set, event);
- event_unref(&event);
http_client_set_ssl_settings(http_client1, &ssl_set);
http_client_set_ssl_settings(http_client2, &ssl_set);
http_client_deinit(&http_client2);
http_client_deinit(&http_client3);
http_client_deinit(&http_client4);
+ settings_root_deinit(&set_root);
+ event_unref(&event);
http_client_context_unref(&http_cctx);
io_loop_destroy(&ioloop);
ssl_iostream_context_cache_free();
ssl_iostream_openssl_deinit();
+ event_unregister_callback(test_event_callback);
lib_deinit();
}
struct ioloop *ioloop;
bool stop_on_state_finish;
- /* Set to imapc_settings attributes with possible override by the
- imapc_parameters. */
- const char *dns_client_socket_path;
const char *imapc_rawlog_dir;
const char *password;
};
p_strdup(pool, params->temp_path_prefix);
client->params.flags = params->flags;
- /* Set the overridden parameter only if it is set. */
- client->dns_client_socket_path =
- (params->override_dns_client_socket_path != NULL) ?
- p_strdup(pool, params->override_dns_client_socket_path) :
- p_strdup(pool, client->set->dns_client_socket_path);
client->imapc_rawlog_dir =
(params->override_rawlog_dir != NULL) ?
p_strdup(pool, params->override_rawlog_dir) :
#include "imap-parser.h"
#include "imapc-client-private.h"
#include "imapc-connection.h"
+#include "settings.h"
#include <unistd.h>
#include <ctype.h>
void imapc_connection_connect(struct imapc_connection *conn)
{
- struct dns_client_settings dns_set;
- struct ip_addr ip, *ips;
- unsigned int ips_count;
- int ret;
+ struct ip_addr ip;
if (conn->fd != -1 || conn->dns_lookup != NULL)
return;
(conn->reconnect_ok ? "true" : "false"),
(long)conn->last_connect.tv_sec);
- i_zero(&dns_set);
- dns_set.dns_client_socket_path = conn->client->dns_client_socket_path;
- dns_set.timeout_msecs = conn->client->set->imapc_connection_timeout_interval_msecs;
-
imapc_connection_set_state(conn, IMAPC_CONNECTION_STATE_CONNECTING);
if (conn->ips_count > 0) {
/* do nothing */
conn->ips_count = 1;
conn->ips = i_new(struct ip_addr, conn->ips_count);
conn->ips[0] = ip;
- } else if (*dns_set.dns_client_socket_path == '\0') {
- ret = net_gethostbyname(conn->client->set->imapc_host,
- &ips, &ips_count);
- if (ret != 0) {
- e_error(conn->event, "net_gethostbyname(%s) failed: %s",
- conn->client->set->imapc_host,
- net_gethosterror(ret));
- imapc_connection_set_disconnected(conn);
- return;
- }
- conn->ips_count = ips_count;
- conn->ips = i_new(struct ip_addr, ips_count);
- memcpy(conn->ips, ips, ips_count * sizeof(*ips));
} else {
- (void)dns_lookup(conn->client->set->imapc_host, &dns_set, NULL,
+ (void)dns_lookup(conn->client->set->imapc_host, NULL,
conn->event, imapc_connection_dns_callback,
conn, &conn->dns_lookup);
return;
DEF(STR, pop3_deleted_flag),
- DEF(STR_HIDDEN, dns_client_socket_path),
-
SETTING_DEFINE_LIST_END
};
.imapc_max_line_length = SET_SIZE_UNLIMITED,
.pop3_deleted_flag = "",
-
- .dns_client_socket_path = "dns-client",
};
static const struct setting_keyvalue imapc_default_settings_keyvalue[] = {
const char *pop3_deleted_flag;
- const char *dns_client_socket_path;
-
enum imapc_features parsed_features;
unsigned int throttle_init_msecs;
unsigned int throttle_max_msecs;
#include "settings-parser.h"
#include "master-service.h"
#include "master-service-settings.h"
+#include "dns-lookup.h"
#define DLUA_DOVECOT_HTTP "http"
#define DLUA_HTTP_CLIENT "struct http_client"
settings_override(instance, real_key, value, SETTINGS_OVERRIDE_TYPE_CODE);
} else if (setting_parser_info_find_key(&ssl_setting_parser_info, key, &idx)) {
settings_override(instance, key, value, SETTINGS_OVERRIDE_TYPE_CODE);
+ } else if (setting_parser_info_find_key(&dns_client_setting_parser_info, key, &idx)) {
+ settings_override(instance, key, value, SETTINGS_OVERRIDE_TYPE_CODE);
} else {
*error_r = t_strdup_printf("%s is unknown setting", key);
}
static void test_dns_lua_common(const char *luascript)
{
- const struct dns_client_settings set = {
- .dns_client_socket_path = TEST_DNS_SERVER_SOCKET_PATH,
- .timeout_msecs = 1000,
+ static const char *const set_dns_test[] = {
+ "dns_client_socket_path", TEST_DNS_SERVER_SOCKET_PATH,
+ "dns_client_timeout", "1s",
+ "base_dir", "",
+ NULL
};
+ const char *error;
struct settings_simple test_set;
- settings_simple_init(&test_set, NULL);
+ settings_simple_init(&test_set, set_dns_test);
- struct dns_client *client = dns_client_init(&set, NULL, NULL);
+ struct dns_client *client;
+ if (dns_client_init(NULL, test_set.event, &client, &error) < 0)
+ i_fatal("%s", error);
struct dlua_script *script;
- const char *error;
if (dlua_script_create_string(luascript, &script, test_set.event, &error) < 0)
i_fatal("dlua_script_create_string() failed: %s", error);
if (dlua_script_init(script, &error) < 0)
struct program_client client;
const char *address;
- struct dns_client_settings dns_set;
struct dns_lookup *lookup;
unsigned int ips_count;
unsigned int ips_left;
if (pclient->params.dns_client_socket_path != NULL) {
e_debug(pclient->event,
"Performing asynchronous DNS lookup");
- prclient->dns_set.dns_client_socket_path =
- pclient->params.dns_client_socket_path;
- prclient->dns_set.timeout_msecs =
- pclient->params.client_connect_timeout_msecs;
- (void)dns_lookup(prclient->address, &prclient->dns_set,
- NULL, pclient->event,
+ (void)dns_lookup(prclient->address, NULL,
+ pclient->event,
program_client_net_connect_resolved,
prclient, &prclient->lookup);
return 0;
static void
smtp_client_connection_lookup_ip(struct smtp_client_connection *conn)
{
- struct dns_client_settings dns_set;
-
if (conn->ips_count != 0)
return;
conn->event,
smtp_client_connection_dns_callback, conn,
&conn->dns_lookup);
- } else if (conn->set.dns_client_socket_path != NULL) {
- i_zero(&dns_set);
- dns_set.dns_client_socket_path =
- conn->set.dns_client_socket_path;
- dns_set.timeout_msecs = conn->set.connect_timeout_msecs;
+ } else {
e_debug(conn->event, "Performing asynchronous DNS lookup");
- (void)dns_lookup(conn->host, &dns_set, NULL, conn->event,
+
+ (void)dns_lookup(conn->host, NULL, conn->event,
smtp_client_connection_dns_callback, conn,
&conn->dns_lookup);
- } else {
- /* FIXME: fully removed in the following commits */
- i_unreached();
}
}
}
client->set.dns_client = set->dns_client;
- client->set.dns_client_socket_path =
- p_strdup(pool, set->dns_client_socket_path);
client->set.rawlog_dir = p_strdup_empty(pool, set->rawlog_dir);
if (set->ssl != NULL) {
const char *const *extra_capabilities;
struct dns_client *dns_client;
- const char *dns_client_socket_path;
/* SSL settings; if NULL, settings_get() is used automatically */
const struct ssl_iostream_settings *ssl;
#include "smtp-client.h"
#include "smtp-client-connection.h"
#include "smtp-client-transaction.h"
+#include "settings.h"
+#include "smtp-client-private.h"
#include <sys/signal.h>
#include <unistd.h>
bool version_sent:1;
};
+struct test_smtp_client_settings {
+ const char *dns_client_socket_path;
+ const char *dns_client_timeout;
+};
+
typedef void (*test_server_init_t)(unsigned int index);
typedef bool
(*test_client_init_t)(const struct smtp_client_settings *client_set);
static void server_connection_deinit(struct server_connection **_conn);
/* client */
-static void test_client_defaults(struct smtp_client_settings *smtp_set);
+static void test_client_defaults(struct smtp_client_settings *smtp_set,
+ struct test_smtp_client_settings *test_set);
static void test_client_deinit(void);
/* test*/
unsigned int server_tests_count,
test_dns_init_t dns_test) ATTR_NULL(3);
+static void test_root_event_free(struct event *event)
+{
+ struct settings_root *set_root =
+ event_get_ptr(event, SETTINGS_EVENT_ROOT);
+ settings_root_deinit(&set_root);
+ event_unref(&event);
+}
+
/*
* Host lookup failed
*/
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("host lookup failed");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("connection refused");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("connection lost prematurely");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
smtp_client_set.connect_timeout_msecs = 1000;
test_begin("connection timed out");
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
smtp_client_set.connect_timeout_msecs = 1000;
test_begin("broken payload");
test_server_broken_payload, 1, NULL);
test_end();
+ test_client_defaults(&smtp_client_set, NULL);
+ smtp_client_set.connect_timeout_msecs = 1000;
+
test_begin("broken payload (later)");
test_run_client_server(&smtp_client_set,
test_client_broken_payload_later,
test_server_broken_payload, 1, NULL);
test_end();
+ test_client_defaults(&smtp_client_set, NULL);
+ smtp_client_set.connect_timeout_msecs = 1000;
+
test_begin("broken payload (later, chunking)");
test_run_client_server(&smtp_client_set,
test_client_broken_payload_later,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("connection lost");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("unexpected reply");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("partial reply");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("premature reply");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("early data reply");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("bad reply");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("bad greeting");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
smtp_client_set.command_timeout_msecs = 1000;
test_begin("command timed out");
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("command aborted early");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("client deinit early");
static void test_dns_service_failure(void)
{
struct smtp_client_settings smtp_client_set;
+ struct test_smtp_client_settings test_set = {
+ .dns_client_socket_path = "./frop",
+ };
- test_client_defaults(&smtp_client_set);
- smtp_client_set.dns_client_socket_path = "./frop";
+ test_client_defaults(&smtp_client_set, &test_set);
test_begin("dns service failure");
test_run_client_server(&smtp_client_set,
static void test_dns_timeout(void)
{
struct smtp_client_settings smtp_client_set;
+ struct test_smtp_client_settings test_set = {
+ .dns_client_timeout = "2s",
+ };
- test_client_defaults(&smtp_client_set);
- smtp_client_set.connect_timeout_msecs = 2000;
- smtp_client_set.dns_client_socket_path = "./dns-test";
+ test_client_defaults(&smtp_client_set, &test_set);
test_begin("dns timeout");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
- smtp_client_set.dns_client_socket_path = "./dns-test";
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("dns lookup failure");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("authentication");
test_run_client_server(&smtp_client_set,
{
struct smtp_client_settings smtp_client_set;
- test_client_defaults(&smtp_client_set);
+ test_client_defaults(&smtp_client_set, NULL);
test_begin("transaction timeout");
test_run_client_server(&smtp_client_set,
/* ssl settings */
ssl_iostream_test_settings_client(&ssl_set);
- test_client_defaults(&smtp_client_set);
- smtp_client_set.dns_client_socket_path = "./dns-test";
+ test_client_defaults(&smtp_client_set, NULL);
smtp_client_set.ssl = &ssl_set;
test_begin("invalid ssl certificate");
* Test client
*/
-static void test_client_defaults(struct smtp_client_settings *smtp_set)
+static void test_client_defaults(struct smtp_client_settings *smtp_set,
+ struct test_smtp_client_settings *test_set)
{
/* client settings */
i_zero(smtp_set);
smtp_set->my_hostname = "frop.example.com";
smtp_set->debug = debug;
+
+ struct event *event = event_create(NULL);
+ struct settings_root *set_root = settings_root_init();
+
+ const char *path = test_set != NULL &&
+ test_set->dns_client_socket_path != NULL ?
+ test_set->dns_client_socket_path : "./dns-test";
+ settings_root_override(set_root, "dns_client_socket_path",
+ path, SETTINGS_OVERRIDE_TYPE_CODE);
+ if (test_set != NULL && test_set->dns_client_timeout != NULL) {
+ settings_root_override(set_root, "dns_client_timeout",
+ test_set->dns_client_timeout,
+ SETTINGS_OVERRIDE_TYPE_CODE);
+ }
+ event_set_ptr(event, SETTINGS_EVENT_ROOT, set_root);
+ smtp_set->event_parent = event;
}
static void test_client_progress_timeout(void *context ATTR_UNUSED)
struct test_server_data {
unsigned int index;
test_server_init_t server_test;
+ test_dns_init_t dns_test;
+ struct event *root_event;
};
static int test_open_server_fd(in_port_t *bind_port)
if (debug)
i_debug("Terminated");
+ test_root_event_free(data->root_event);
i_close_fd(&fd_listen);
i_free(bind_ports);
main_deinit();
return 0;
}
-static int test_run_dns(test_dns_init_t dns_test)
+static int test_run_dns(struct test_server_data *data)
{
i_set_failure_prefix("DNS: ");
test_subprocess_notify_signal_send_parent(SIGUSR1);
ioloop = io_loop_create();
- dns_test();
+ data->dns_test();
io_loop_destroy(&ioloop);
if (debug)
i_close_fd(&fd_listen);
i_free(bind_ports);
main_deinit();
+ test_root_event_free(data->root_event);
return 0;
}
unsigned int server_tests_count,
test_dns_init_t dns_test)
{
+ struct event *root_event = client_set->event_parent;
unsigned int i;
if (server_tests_count > 0) {
i_zero(&data);
data.index = i;
data.server_test = server_test;
+ data.root_event = root_event;
/* Fork server */
fd_listen = fds[i];
}
if (dns_test != NULL) {
+ struct test_server_data data = {
+ .dns_test = dns_test,
+ .root_event = root_event,
+ };
int fd;
i_unlink_if_exists("./dns-test");
/* Fork DNS service */
fd_listen = fd;
test_subprocess_notify_signal_reset(SIGUSR1);
- test_subprocess_fork(test_run_dns, dns_test, FALSE);
+ test_subprocess_fork(test_run_dns, &data, FALSE);
test_subprocess_notify_signal_wait(SIGUSR1,
TEST_SIGNALS_DEFAULT_TIMEOUT_MS);
i_close_fd(&fd_listen);
i_free(bind_ports);
i_unlink_if_exists("./dns-test");
+ test_root_event_free(root_event);
}
/*
#include <unistd.h>
#define POP3C_MAX_INBUF_SIZE (1024*32)
-#define POP3C_DNS_LOOKUP_TIMEOUT_MSECS (1000*30)
#define POP3C_CONNECT_TIMEOUT_MSECS (1000*30)
#define POP3C_COMMAND_TIMEOUT_MSECS (1000*60*5)
static int pop3c_client_dns_lookup(struct pop3c_client *client)
{
- struct dns_client_settings dns_set;
-
i_assert(client->state == POP3C_CLIENT_STATE_CONNECTING);
if (client->set.dns_client_socket_path[0] == '\0') {
client->ip = ips[0];
pop3c_client_connect_ip(client);
} else {
- i_zero(&dns_set);
- dns_set.dns_client_socket_path =
- client->set.dns_client_socket_path;
- dns_set.timeout_msecs = POP3C_DNS_LOOKUP_TIMEOUT_MSECS;
- if (dns_lookup(client->set.host, &dns_set, NULL, client->event,
+ if (dns_lookup(client->set.host, NULL, client->event,
pop3c_dns_callback, client,
&client->dns_lookup) < 0)
return -1;
i_zero(&lmtp_set);
lmtp_set.my_hostname = client->my_domain;
lmtp_set.extra_capabilities = extra_capabilities;
- lmtp_set.dns_client_socket_path = dns_client_socket_path;
lmtp_set.max_reply_size = LMTP_MAX_REPLY_SIZE;
lmtp_set.rawlog_dir = client->lmtp_set->lmtp_proxy_rawlog_dir;
#include <stdio.h>
#include <unistd.h>
-#define DNS_CLIENT_SOCKET_PATH "dns-client"
-
#define LMTP_MASTER_FIRST_LISTEN_FD 3
#define IS_STANDALONE() \
struct smtp_server_settings smtp_server_set;
struct smtp_client_settings smtp_client_set;
const char *username = NULL, *auth_socket_path = "auth-master";
- const char *tmp_socket_path;
const char *error;
int c;
smtp_server = smtp_server_init(&smtp_server_set);
smtp_server_command_register(smtp_server, "BURL", cmd_burl, 0);
- if (t_abspath(DNS_CLIENT_SOCKET_PATH, &tmp_socket_path, &error) < 0)
- i_fatal("t_abspath(%s) failed: %s", DNS_CLIENT_SOCKET_PATH, error);
-
/* initialize SMTP client */
i_zero(&smtp_client_set);
smtp_client_set.my_hostname = my_hostdomain();
smtp_client_set.debug = submission_debug;
- smtp_client_set.dns_client_socket_path = tmp_socket_path;
smtp_client = smtp_client_init(&smtp_client_set);
if (!IS_STANDALONE())