From e57e88ee6c3359c2dbdced9b7a12f35249ed1bcc Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Tue, 21 Jan 2014 03:59:15 +0100
Subject: [PATCH] gluon-mesh-batman-adv: add DNS support

---
 .../gluon/dnsmasq.d/010-mesh-batman-adv.conf  |  1 +
 .../mesh-batman-adv/invariant/011-mesh        |  4 ++++
 .../lib/gluon/odhcp6c.d/010-mesh-batman-adv   | 21 +++++++++++++++++++
 3 files changed, 26 insertions(+)
 create mode 120000 package/gluon-mesh-batman-adv/files/lib/gluon/dnsmasq.d/010-mesh-batman-adv.conf
 create mode 100755 package/gluon-mesh-batman-adv/generate/lib/gluon/odhcp6c.d/010-mesh-batman-adv

diff --git a/package/gluon-mesh-batman-adv/files/lib/gluon/dnsmasq.d/010-mesh-batman-adv.conf b/package/gluon-mesh-batman-adv/files/lib/gluon/dnsmasq.d/010-mesh-batman-adv.conf
new file mode 120000
index 000000000..f4b89cbee
--- /dev/null
+++ b/package/gluon-mesh-batman-adv/files/lib/gluon/dnsmasq.d/010-mesh-batman-adv.conf
@@ -0,0 +1 @@
+/var/gluon/mesh-batman-adv/dnsmasq.conf
\ No newline at end of file
diff --git a/package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/invariant/011-mesh b/package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/invariant/011-mesh
index 6398d2c33..5ce85c61c 100755
--- a/package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/invariant/011-mesh
+++ b/package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/invariant/011-mesh
@@ -26,6 +26,10 @@ uci_set firewall client output 'ACCEPT'
 uci_set firewall client forward 'REJECT'
 uci_commit firewall
 
+uci_set dhcp '@dnsmasq[0]' boguspriv '0'
+uci_set dhcp '@dnsmasq[0]' localise_queries '0'
+uci_set dhcp '@dnsmasq[0]' rebind_protection '0'
+
 uci_remove dhcp client
 uci_add dhcp dhcp client
 uci_set dhcp client interface 'client'
diff --git a/package/gluon-mesh-batman-adv/generate/lib/gluon/odhcp6c.d/010-mesh-batman-adv b/package/gluon-mesh-batman-adv/generate/lib/gluon/odhcp6c.d/010-mesh-batman-adv
new file mode 100755
index 000000000..5f7025229
--- /dev/null
+++ b/package/gluon-mesh-batman-adv/generate/lib/gluon/odhcp6c.d/010-mesh-batman-adv
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+[ "$INTERFACE" = 'client' ] || exit 0
+
+mkdir -p /var/gluon/mesh-batman-adv
+
+for ns in $RDNSS $RA_DNS; do
+	for domain in @mesh_domains@; do
+		echo "server=/$domain/$ns"
+	done
+done > /var/gluon/mesh-batman-adv/dnsmasq.conf.$$
+
+if cmp -s /var/gluon/mesh-batman-adv/dnsmasq.conf.$$ /var/gluon/mesh-batman-adv/dnsmasq.conf; then
+	rm /var/gluon/mesh-batman-adv/dnsmasq.conf.$$
+	exit 0
+fi
+
+lock /var/gluon/mesh-batman-adv/dnsmasq.conf.lock
+mv -f /var/gluon/mesh-batman-adv/dnsmasq.conf.$$ /var/gluon/mesh-batman-adv/dnsmasq.conf
+/etc/init.d/dnsmasq restart
+lock -u /var/gluon/mesh-batman-adv/dnsmasq.conf.lock
-- 
GitLab