aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/services/dnsmasq
diff options
context:
space:
mode:
authorAleksandr Mezin <mezin.alexander@gmail.com>2020-10-23 11:02:37 +0600
committerHans Dedecker <dedeckeh@gmail.com>2020-11-11 20:47:34 +0100
commitacb336235cc640980ea549655b0702daf9e628f8 (patch)
tree21096d476425dd036760bbe92fc4a0f0f1a3c1e5 /package/network/services/dnsmasq
parentde768829a5c6cd1c7889ba25c50db07827cfc96c (diff)
downloadupstream-acb336235cc640980ea549655b0702daf9e628f8.tar.gz
upstream-acb336235cc640980ea549655b0702daf9e628f8.tar.bz2
upstream-acb336235cc640980ea549655b0702daf9e628f8.zip
dnsmasq: 'ipset' config sections
Allow configuring ipsets with dedicated config sections: config ipset list name 'ss_rules_dst_forward' list name 'ss_rules6_dst_forward' list domain 't.me' list domain 'telegram.org' instead of current, rather inconvenient syntax: config dnsmasq ... list ipset '/t.me/telegram.org/ss_rules_dst_forward,ss_rules6_dst_forward' Current syntax will still continue to work though. With this change, a LuCI GUI for DNS ipsets should be easy to implement. Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> [PKG_RELEASE increase]
Diffstat (limited to 'package/network/services/dnsmasq')
-rw-r--r--package/network/services/dnsmasq/Makefile2
-rw-r--r--package/network/services/dnsmasq/files/dnsmasq.init27
2 files changed, 28 insertions, 1 deletions
diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile
index 4086aa25e0..ba10ded333 100644
--- a/package/network/services/dnsmasq/Makefile
+++ b/package/network/services/dnsmasq/Makefile
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=dnsmasq
PKG_UPSTREAM_VERSION:=2.82
PKG_VERSION:=$(subst test,~~test,$(subst rc,~rc,$(PKG_UPSTREAM_VERSION)))
-PKG_RELEASE:=9
+PKG_RELEASE:=10
PKG_SOURCE:=$(PKG_NAME)-$(PKG_UPSTREAM_VERSION).tar.xz
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 7ecc542b44..680e72f9e7 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -769,6 +769,29 @@ dhcp_relay_add() {
fi
}
+dnsmasq_ipset_add() {
+ local cfg="$1"
+ local ipsets domains
+
+ add_ipset() {
+ ipsets="${ipsets:+$ipsets,}$1"
+ }
+
+ add_domain() {
+ # leading '/' is expected
+ domains="$domains/$1"
+ }
+
+ config_list_foreach "$cfg" "name" add_ipset
+ config_list_foreach "$cfg" "domain" add_domain
+
+ if [ -z "$ipsets" ] || [ -z "$domains" ]; then
+ return 0
+ fi
+
+ xappend "--ipset=$domains/$ipsets"
+}
+
dnsmasq_start()
{
local cfg="$1"
@@ -1057,6 +1080,10 @@ dnsmasq_start()
echo >> $CONFIGFILE_TMP
echo >> $CONFIGFILE_TMP
+ config_foreach filter_dnsmasq ipset dnsmasq_ipset_add "$cfg"
+ echo >> $CONFIGFILE_TMP
+
+ echo >> $CONFIGFILE_TMP
mv -f $CONFIGFILE_TMP $CONFIGFILE
mv -f $HOSTFILE_TMP $HOSTFILE