Add scripts for adding/removing standard exceptions

This commit is contained in:
Frank Denis
2012-08-01 15:54:09 -07:00
parent a863680347
commit ea2203f26e
3 changed files with 46 additions and 0 deletions
@@ -23,6 +23,8 @@ INTERFACE_PROXY_MASK="24"
INTERFACE_PROBES="127.0.0.55"
INTERFACE_PROBES_MASK="24"
DOMAINS_EXCEPTIONS='routerlogin.net lan local localdomain private intranet'
export PATH="${DNSCRYPT_USR_BASE_DIR}/bin:${DNSCRYPT_USR_BASE_DIR}/scripts:$PATH"
init_interfaces() {
@@ -0,0 +1,35 @@
#! /bin/sh
RESOLVER_DIR='/etc/resolver'
. ./common.inc
get_gw() {
route -n get default | while read line; do
case "$line" in
gateway:\ *)
echo "$line" | sed 's/ *gateway: *//'
return
;;
esac
done
}
get_dhcp_dns() {
cat "${STATES_DIR}/dhcp-dns" 2> /dev/null
}
name_servers=$(get_dhcp_dns || get_gw)
[ x"$name_servers" = 'x' ] && exit 0
mkdir -p "$RESOLVER_DIR" || exit 1
name_server="$gw"
for domain in $DOMAINS_EXCEPTIONS; do
echo '# automatically generated by the dnscrypt user interface' \
> "${RESOLVER_DIR}/${domain}"
for name_server in $name_servers; do
echo "nameserver ${name_server}" >> "${RESOLVER_DIR}/${domain}"
done
done
@@ -0,0 +1,9 @@
#! /bin/sh
RESOLVER_DIR='/etc/resolver'
. ./common.inc
for domain in $DOMAINS_EXCEPTIONS; do
rm -f "${RESOLVER_DIR}/${domain}"
done