diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/common.inc b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/common.inc index e5f082a..cb1cf49 100644 --- a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/common.inc +++ b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/common.inc @@ -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() { diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/exceptions-add.sh b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/exceptions-add.sh new file mode 100755 index 0000000..41a1047 --- /dev/null +++ b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/exceptions-add.sh @@ -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 diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/exceptions-remove.sh b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/exceptions-remove.sh new file mode 100644 index 0000000..97dc102 --- /dev/null +++ b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/exceptions-remove.sh @@ -0,0 +1,9 @@ +#! /bin/sh + +RESOLVER_DIR='/etc/resolver' + +. ./common.inc + +for domain in $DOMAINS_EXCEPTIONS; do + rm -f "${RESOLVER_DIR}/${domain}" +done