[PATCH v4 3/5] dnsproxy: Add command line switch

Daniel Wagner wagi at monom.org
Wed Jan 26 00:50:31 PST 2011


From: Daniel Wagner <daniel.wagner at bmw-carit.de>

Command line switch to disable dnsproxy.
---
 src/connman.h  |    2 +-
 src/dnsproxy.c |   10 +++++++++-
 src/main.c     |    6 +++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 9d8e46c..6e80e6d 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -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);
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index cf907bc..960c057 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -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);
diff --git a/src/main.c b/src/main.c
index a38eb60..808c0d5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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();
-- 
1.7.3.5




More information about the connman mailing list