Optimize configuration, and add blacklist ip features
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
# Add domains which you want to force to an IP address here.
|
||||
# The example below send any host in example.com to a local webserver.
|
||||
#address /example.com/127.0.0.1
|
||||
# address /example.com/127.0.0.1
|
||||
4
package/openwrt/blacklist-ip.conf
Normal file
4
package/openwrt/blacklist-ip.conf
Normal file
@@ -0,0 +1,4 @@
|
||||
# Add IP blacklist which you want to filtering from some DNS server here.
|
||||
# The example below filtering ip from the result of DNS server which is configured with -blacklist-ip.
|
||||
# blacklist-ip [ip/subnet]
|
||||
# blacklist-ip 254.0.0.1/16
|
||||
@@ -1,3 +1,4 @@
|
||||
/etc/config/smartdns
|
||||
/etc/smartdns/address.conf
|
||||
/etc/smartdns/blacklist-ip.conf
|
||||
/etc/smartdns/custom.conf
|
||||
|
||||
@@ -2,11 +2,25 @@
|
||||
|
||||
chmod +x /usr/sbin/smartdns
|
||||
chmod +x /etc/init.d/smartdns
|
||||
mkdir -p /var/etc/smartdns/
|
||||
|
||||
[ "${IPKG_NO_SCRIPT}" = "1" ] && exit 0
|
||||
|
||||
if [ ! -f "/var/etc/smartdns/address.conf" ]; then
|
||||
cp /etc/smartdns/address.conf /var/etc/smartdns/address.conf
|
||||
fi
|
||||
|
||||
if [ ! -f "/var/etc/smartdns/blacklist-ip.conf" ]; then
|
||||
cp /etc/smartdns/blacklist-ip.conf /var/etc/smartdns/blacklist-ip.conf
|
||||
fi
|
||||
|
||||
if [ ! -f "/var/etc/smartdns/custom.conf" ]; then
|
||||
cp /etc/smartdns/custom.conf /var/etc/smartdns/custom.conf
|
||||
fi
|
||||
|
||||
. ${IPKG_INSTROOT}/lib/functions.sh
|
||||
default_postinst $0 $@
|
||||
ret=$?
|
||||
/etc/init.d/smartdns enable
|
||||
exit $ret
|
||||
exit 0
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#!/bin/sh
|
||||
. ${IPKG_INSTROOT}/lib/functions.sh
|
||||
default_prerm $0 $@
|
||||
rm /var/etc/smartdns.conf -f
|
||||
rm /var/etc/smartdns/smartdns.conf -f
|
||||
exit 0
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
# log-num 2
|
||||
|
||||
# List of hosts that supply bogus NX domain results
|
||||
# bogus-nxdomain [ip]
|
||||
# bogus-nxdomain [ip/subnet]
|
||||
@@ -8,10 +8,13 @@ SERVICE_WRITE_PID=1
|
||||
SERVICE_DAEMONIZE=1
|
||||
SERVICE_PID_FILE="/var/run/smartdns.pid"
|
||||
BASECONFIGFILE="/etc/smartdns/smartdns.conf"
|
||||
SMARTDNS_CONF="/var/etc/smartdns.conf"
|
||||
ADDRESS_CONF="/etc/smartdns/address.conf"
|
||||
CUSTOM_CONF="/etc/smartdns/custom.conf"
|
||||
SMARTDNS_CONF_DIR="/var/etc/smartdns"
|
||||
SMARTDNS_CONF="$SMARTDNS_CONF_DIR/smartdns.conf"
|
||||
ADDRESS_CONF="$SMARTDNS_CONF_DIR/address.conf"
|
||||
BLACKLIST_IP_CONF="$SMARTDNS_CONF_DIR/blacklist-ip.conf"
|
||||
CUSTOM_CONF="$SMARTDNS_CONF_DIR/custom.conf"
|
||||
SMARTDNS_CONF_TMP="${SMARTDNS_CONF}.tmp"
|
||||
COREDUMP="0"
|
||||
|
||||
set_forward_dnsmasq()
|
||||
{
|
||||
@@ -109,9 +112,11 @@ conf_append()
|
||||
load_server()
|
||||
{
|
||||
local section="$1"
|
||||
local ADDITIONAL_ARGS=""
|
||||
config_get "port" "$section" "port" "53"
|
||||
config_get "type" "$section" "type" "udp"
|
||||
config_get "ip" "$section" "ip" ""
|
||||
config_get "blacklist_ip" "$section" "blacklist_ip" "0"
|
||||
|
||||
if [ -z "$port" ] || [ -z "$ip" ] || [ -z "$type" ]; then
|
||||
return
|
||||
@@ -130,8 +135,11 @@ load_server()
|
||||
fi
|
||||
fi
|
||||
|
||||
conf_append "$SERVER" "$ip:$port"
|
||||
if [ "$blacklist_ip" != "0" ]; then
|
||||
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -blacklist-ip"
|
||||
fi
|
||||
|
||||
conf_append "$SERVER" "$ip:$port $ADDITIONAL_ARGS"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
@@ -161,7 +169,7 @@ start_service() {
|
||||
fi
|
||||
SMARTDNS_PORT="$port"
|
||||
|
||||
mkdir -p $(dirname $SMARTDNS_CONF)
|
||||
mkdir -p $SMARTDNS_CONF_DIR
|
||||
|
||||
config_get "cache_size" "$section" "cache_size" ""
|
||||
if [ ! -z "$cache_size" ]; then
|
||||
@@ -227,11 +235,16 @@ start_service() {
|
||||
config_foreach load_server "server"
|
||||
|
||||
echo "conf-file $ADDRESS_CONF" >> $SMARTDNS_CONF_TMP
|
||||
echo "conf-file $BLACKLIST_IP_CONF" >> $SMARTDNS_CONF_TMP
|
||||
echo "conf-file $CUSTOM_CONF" >> $SMARTDNS_CONF_TMP
|
||||
|
||||
config_get_bool "enabled" "$section" "enabled" '0'
|
||||
mv $SMARTDNS_CONF_TMP $SMARTDNS_CONF
|
||||
[ "$enabled" -gt 0 ] || return 1
|
||||
if [ "$COREDUMP" = "1" ]; then
|
||||
args="$args -S"
|
||||
ulimit -c unlimited
|
||||
fi
|
||||
service_start /usr/sbin/smartdns $args -c $SMARTDNS_CONF
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ SMARTDNS_DIR=$CURR_DIR/../../
|
||||
SMARTDNS_BIN=$SMARTDNS_DIR/src/smartdns
|
||||
SMARTDNS_CONF=$SMARTDNS_DIR/etc/smartdns/smartdns.conf
|
||||
ADDRESS_CONF=$CURR_DIR/address.conf
|
||||
BLACKLIST_IP_CONF=$CURR_DIR/blacklist-ip.conf
|
||||
CUSTOM_CONF=$CURR_DIR/custom.conf
|
||||
|
||||
showhelp()
|
||||
@@ -33,6 +34,7 @@ build()
|
||||
|
||||
cp $SMARTDNS_CONF $ROOT/root/etc/smartdns/
|
||||
cp $ADDRESS_CONF $ROOT/root/etc/smartdns/
|
||||
cp $BLACKLIST_IP_CONF $ROOT/root/etc/smartdns/
|
||||
cp $CUSTOM_CONF $ROOT/root/etc/smartdns/
|
||||
cp $CURR_DIR/files/etc $ROOT/root/ -af
|
||||
cp $SMARTDNS_BIN $ROOT/root/usr/sbin
|
||||
|
||||
Reference in New Issue
Block a user