dnsproxy: Add command line switch
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Wed, 26 Jan 2011 08:50:31 +0000 (09:50 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 26 Jan 2011 08:56:09 +0000 (09:56 +0100)
Command line switch to disable dnsproxy.

src/connman.h
src/dnsproxy.c
src/main.c

index 9d8e46c..6e80e6d 100644 (file)
@@ -612,5 +612,5 @@ int __connman_iptables_command(const char *format, ...)
                                __attribute__((format(printf, 1, 2)));
 int __connman_iptables_commit(const char *table_name);
 
-int __connman_dnsproxy_init(void);
+int __connman_dnsproxy_init(connman_bool_t dnsproxy);
 void __connman_dnsproxy_cleanup(void);
index cf907bc..960c057 100644 (file)
@@ -117,6 +117,7 @@ struct request_data {
        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;
@@ -1480,10 +1481,14 @@ static void destroy_listener(void)
        destroy_udp_listener();
 }
 
-int __connman_dnsproxy_init(void)
+int __connman_dnsproxy_init(connman_bool_t dnsproxy)
 {
        int err;
 
+       dnsproxy_enabled = dnsproxy;
+       if (dnsproxy_enabled == FALSE)
+               return 0;
+
        err = create_listener();
        if (err < 0)
                return err;
@@ -1509,6 +1514,9 @@ destroy:
 
 void __connman_dnsproxy_cleanup(void)
 {
+       if (dnsproxy_enabled == FALSE)
+               return;
+
        connman_notifier_unregister(&dnsproxy_notifier);
 
        connman_resolver_unregister(&dnsproxy_resolver);
index a38eb60..808c0d5 100644 (file)
@@ -63,6 +63,7 @@ static gchar *option_nodevice = NULL;
 static gchar *option_noplugin = NULL;
 static gchar *option_wifi = NULL;
 static gboolean option_detach = TRUE;
+static gboolean option_dnsproxy = TRUE;
 static gboolean option_compat = FALSE;
 static gboolean option_version = FALSE;
 
@@ -94,6 +95,9 @@ static GOptionEntry options[] = {
        { "nodaemon", 'n', G_OPTION_FLAG_REVERSE,
                                G_OPTION_ARG_NONE, &option_detach,
                                "Don't fork daemon to background" },
+       { "nodnsproxy", 'r', G_OPTION_FLAG_REVERSE,
+                               G_OPTION_ARG_NONE, &option_dnsproxy,
+                               "Don't enable DNS Proxy" },
        { "compat", 'c', 0, G_OPTION_ARG_NONE, &option_compat,
                                "Enable Network Manager compatibility" },
        { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
@@ -224,7 +228,7 @@ int main(int argc, char *argv[])
        __connman_config_init();
        __connman_stats_init();
 
-       __connman_dnsproxy_init();
+       __connman_dnsproxy_init(option_dnsproxy);
        __connman_resolver_init();
        __connman_ipconfig_init();
        __connman_rtnl_init();