summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2013-06-17 11:55:30 +0000
committerJo-Philipp Wich <jow@openwrt.org>2013-06-17 11:55:30 +0000
commitdfea3bae11dd5c207182371ce1fdca763fb5bbe0 (patch)
treecd6611ccca46e35886c37ac22ee1f88a92af71c6 /package
parent265a2deba3bf3984c2246e8b097723f2e79224a8 (diff)
downloadmtk-20170518-dfea3bae11dd5c207182371ce1fdca763fb5bbe0.zip
mtk-20170518-dfea3bae11dd5c207182371ce1fdca763fb5bbe0.tar.gz
mtk-20170518-dfea3bae11dd5c207182371ce1fdca763fb5bbe0.tar.bz2
dnsmasq: use host-record instead of address
Using "--address" for individual host A records is broken, use "--host-record" instead. The following patch changes dnsmasq.init to build individual host records using "--host-record" instead of "--address". Signed-off-by: Adam Gensler <openwrt at gnslr.us> [jow: shorter description, simplified shell script code] SVN-Revision: 36943
Diffstat (limited to 'package')
-rw-r--r--package/network/services/dnsmasq/Makefile2
-rw-r--r--package/network/services/dnsmasq/files/dnsmasq.init56
2 files changed, 35 insertions, 23 deletions
diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile
index 467c934..6938ba1 100644
--- a/package/network/services/dnsmasq/Makefile
+++ b/package/network/services/dnsmasq/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=dnsmasq
PKG_VERSION:=2.66
-PKG_RELEASE:=2
+PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
index cc5ff7d..630c07d 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -74,7 +74,7 @@ append_addnhosts() {
}
append_bogusnxdomain() {
- xappend "--bogus-nxdomain=$1"
+ xappend "--bogus-nxdomain=$1"
}
dnsmasq() {
@@ -393,7 +393,7 @@ dhcp_option_add() {
dhcp_domain_add() {
local cfg="$1"
- local ip name names
+ local ip name names record
config_get names "$cfg" name "$2"
[ -n "$names" ] || return 0
@@ -401,22 +401,11 @@ dhcp_domain_add() {
config_get ip "$cfg" ip "$3"
[ -n "$ip" ] || return 0
- local oIFS="$IFS"; IFS="."; set -- $ip; IFS="$oIFS"
- local raddr="${4:+$4.$3.$2.$1.in-addr.arpa}"
-
for name in $names; do
- local fqdn="$name"
-
- [ "${fqdn%.*}" == "$fqdn" ] && \
- fqdn="$fqdn${DOMAIN:+.$DOMAIN}"
-
- xappend "--address=/$fqdn/$ip"
-
- [ -n "$raddr" ] && {
- xappend "--ptr-record=$raddr,$fqdn"
- raddr=""
- }
+ record="${record:+$record/}$name"
done
+
+ xappend "--address=/$record/$ip"
}
dhcp_srv_add() {
@@ -469,6 +458,27 @@ dhcp_cname_add() {
xappend "--cname=${cname},${target}"
}
+dhcp_hostrecord_add() {
+ local cfg="$1"
+ local names addresses record val
+
+ config_get names "$cfg" name "$2"
+ if [ -z "$names" ]; then
+ return 0
+ fi
+
+ config_get addresses "$cfg" ip "$3"
+ if [ -z "$addresses" ]; then
+ return 0
+ fi
+
+ for val in $names $addresses; do
+ record="${record:+$record,}$val"
+ done
+
+ xappend "--host-record=$record"
+}
+
start() {
include /lib/network
scan_interfaces
@@ -501,6 +511,14 @@ start() {
config_foreach dhcp_remoteid_add remoteid
config_foreach dhcp_subscrid_add subscrid
config_foreach dhcp_domain_add domain
+ config_foreach dhcp_hostrecord_add hostrecord
+
+ # add own hostname
+ [ $ADD_LOCAL_HOSTNAME -eq 1 ] && [ -n "$lanaddr" ] && {
+ local hostname="$(uci_get system @system[0] hostname OpenWrt)"
+ dhcp_hostrecord_add "" "$hostname${DOMAIN:+.$DOMAIN $hostname}" "$lanaddr"
+ }
+
echo >> $CONFIGFILE
config_foreach dhcp_srv_add srvhost
config_foreach dhcp_mx_add mxhost
@@ -510,12 +528,6 @@ start() {
config_foreach dhcp_cname_add cname
echo >> $CONFIGFILE
- # add own hostname
- [ $ADD_LOCAL_HOSTNAME -eq 1 ] && [ -n "$lanaddr" ] && {
- local hostname="$(uci_get system.@system[0].hostname)"
- dhcp_domain_add "" "${hostname:-OpenWrt}" "$lanaddr"
- }
-
service_start /usr/sbin/dnsmasq -C $CONFIGFILE && {
rm -f /tmp/resolv.conf
[ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && {