diff options
author | jow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2013-05-06 08:44:54 +0000 |
---|---|---|
committer | jow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2013-05-06 08:44:54 +0000 |
commit | 7fcd308f5487ca56232786e87e9fd862b830e89b (patch) | |
tree | 116ab009eaca998f579951e0496ae3998876013f /package/network/services/ipset-dns/files | |
parent | f84b697c231ab36e0460008983dfc5645b8048e2 (diff) |
Add ipset-dns - a tiny DNS proxy service which puts resolved ip addresses into a specified ipset
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36552 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/network/services/ipset-dns/files')
-rw-r--r-- | package/network/services/ipset-dns/files/ipset-dns.config | 13 | ||||
-rwxr-xr-x | package/network/services/ipset-dns/files/ipset-dns.init | 64 |
2 files changed, 77 insertions, 0 deletions
diff --git a/package/network/services/ipset-dns/files/ipset-dns.config b/package/network/services/ipset-dns/files/ipset-dns.config new file mode 100644 index 000000000..52e87b27c --- /dev/null +++ b/package/network/services/ipset-dns/files/ipset-dns.config @@ -0,0 +1,13 @@ +# declare an ipset-dns listener instance, multiple allowed +config ipset-dns + # use given ipset + option ipset 'domain-filter' + + # use given listening port + # defaults to 53000 + instance number + #option port '53001' + + # use given upstream DNS server, + # defaults to first entry in /tmp/resolv.conf.auto + #option dns '8.8.8.8' + diff --git a/package/network/services/ipset-dns/files/ipset-dns.init b/package/network/services/ipset-dns/files/ipset-dns.init new file mode 100755 index 000000000..5d41539a7 --- /dev/null +++ b/package/network/services/ipset-dns/files/ipset-dns.init @@ -0,0 +1,64 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2013 OpenWrt.org + +START=61 + +SERVICE_DAEMONIZE=1 +SERVICE_WRITE_PID=1 + + +find_nameserver() { + . /lib/functions/network.sh + + local tmp + if network_find_wan tmp && network_get_dnsserver tmp "$tmp"; then + echo "${tmp%% *}" + return 0 + fi + + return 1 +} + +start_instance() { + local cfg="$1" + local ipset port dns + + config_get ipset "$cfg" ipset + [ -n "$ipset" ] || { + echo "No ipset specified for instance $cfg" >&2 + return 1 + } + + config_get dns "$cfg" dns "$DEFNS" + [ -n "$dns" ] || { + echo "No DNS server specified for instance $cfg" >&2 + return 1 + } + + config_get port "$cfg" port $((PORT++)) + + SERVICE_PID_FILE="/var/run/ipset-dns-$port.pid" \ + service_start /usr/sbin/ipset-dns "$ipset" "$port" "$dns" +} + +start() { + PORT=53001 + DEFNS="$(find_nameserver)" + + # required by ipset-dns to not daemonize itself + export NO_DAEMONIZE=1 + + config_load ipset-dns + config_foreach start_instance ipset-dns +} + +stop() { + local pid + for pid in /var/run/ipset-dns-*.pid; do + [ -f "$pid" ] || continue + SERVICE_PID_FILE="$pid" \ + service_stop /usr/sbin/ipset-dns + rm -f "$pid" + done +} + |