__attribute__((format(printf, 1, 2)));
int __connman_iptables_commit(const char *table_name);
-int __connman_dnsproxy_init(connman_bool_t dnsproxy);
+int __connman_dnsproxy_init(void);
void __connman_dnsproxy_cleanup(void);
int __connman_dnsproxy_append(const char *interface, const char *domain, const char *server);
int __connman_dnsproxy_remove(const char *interface, const char *domain, const char *server);
gsize resplen;
};
-static connman_bool_t dnsproxy_enabled = TRUE;
static GSList *server_list = NULL;
static GSList *request_list = NULL;
static GSList *request_pending_list = NULL;
destroy_udp_listener();
}
-int __connman_dnsproxy_init(connman_bool_t dnsproxy)
+int __connman_dnsproxy_init(void)
{
int err;
- DBG("dnsproxy %d", dnsproxy);
-
- dnsproxy_enabled = dnsproxy;
- if (dnsproxy_enabled == FALSE)
- return 0;
+ DBG("");
err = create_listener();
if (err < 0)
{
DBG("");
- if (dnsproxy_enabled == FALSE)
- return;
-
connman_notifier_unregister(&dnsproxy_notifier);
destroy_listener();
__connman_stats_init();
__connman_resolver_init(option_dnsproxy);
- __connman_dnsproxy_init(option_dnsproxy);
__connman_ipconfig_init();
__connman_rtnl_init();
__connman_task_init();
__connman_task_cleanup();
__connman_rtnl_cleanup();
__connman_ipconfig_cleanup();
- __connman_dnsproxy_cleanup();
__connman_resolver_cleanup();
__connman_stats_cleanup();
{
DBG("dnsproxy %d", dnsproxy);
- dnsproxy_enabled = dnsproxy;
+ if (dnsproxy == FALSE)
+ return 0;
+
+ if (__connman_dnsproxy_init() < 0) {
+ /* Fall back to resolv.conf */
+ return 0;
+ }
+
+ dnsproxy_enabled = TRUE;
+
return 0;
}
void __connman_resolver_cleanup(void)
{
DBG("");
+
+ if (dnsproxy_enabled == TRUE)
+ __connman_dnsproxy_cleanup();
}