From: Pasi Sjöholm <pasi.sjoh...@jollamobile.com>

A new append_domain()- and remove_domain()-functions which both
call append_or_remove_domain()-function by setting boolean append-
variable accordingly.

This enables a capability to remove domains from the dns-server's
domain list.
---
 src/dnsproxy.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index c37eee9..1e8fcfb 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -2649,7 +2649,7 @@ static bool resolv(struct request_data *req,
        return false;
 }
 
-static void append_domain(int index, const char *domain)
+static void append_or_remove_domain(int index, const char *domain, bool append)
 {
        GSList *list;
 
@@ -2680,13 +2680,26 @@ static void append_domain(int index, const char *domain)
                        }
                }
 
-               if (!dom_found) {
+               if (!dom_found && append) {
                        data->domains =
                                g_list_append(data->domains, g_strdup(domain));
+               } else if (dom_found && !append) {
+                       data->domains =
+                               g_list_remove(data->domains, dom);
                }
        }
 }
 
+static void append_domain(int index, const char *domain)
+{
+       append_or_remove_domain(index, domain, true);
+}
+
+static void remove_domain(int index, const char *domain)
+{
+       append_or_remove_domain(index, domain, false);
+}
+
 static void flush_requests(struct server_data *server)
 {
        GSList *list;
-- 
2.1.4

_______________________________________________
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Reply via email to