Initial commit
This commit is contained in:
16
package/network/services/ipset-dns/files/ipset-dns.config
Normal file
16
package/network/services/ipset-dns/files/ipset-dns.config
Normal file
@@ -0,0 +1,16 @@
|
||||
# declare an ipset-dns listener instance, multiple allowed
|
||||
config ipset-dns
|
||||
# use given ipset for type A (IPv4) responses
|
||||
option ipset 'domain-filter-ipv4'
|
||||
|
||||
# use given ipset for type AAAA (IPv6) responses
|
||||
option ipset6 'domain-filter-ipv6'
|
||||
|
||||
# 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'
|
||||
|
||||
57
package/network/services/ipset-dns/files/ipset-dns.init
Executable file
57
package/network/services/ipset-dns/files/ipset-dns.init
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2013 OpenWrt.org
|
||||
|
||||
START=61
|
||||
|
||||
USE_PROCD=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 ipset6 port dns
|
||||
|
||||
config_get ipset "$cfg" ipset
|
||||
config_get ipset6 "$cfg" ipset6
|
||||
[ -n "$ipset$ipset6" ] || {
|
||||
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++))
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command /usr/sbin/ipset-dns "$ipset" "$ipset6" "$port" "$dns"
|
||||
procd_set_param env NO_DAEMONIZE=1
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger "ipset-dns"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
PORT=53001
|
||||
DEFNS="$(find_nameserver)"
|
||||
|
||||
config_load ipset-dns
|
||||
config_foreach start_instance ipset-dns
|
||||
}
|
||||
Reference in New Issue
Block a user