Skip to content

Commit

Permalink
Merge pull request #4 from kirill-zak/feature/ud-02
Browse files Browse the repository at this point in the history
ud-02 Add support for DNS servers
  • Loading branch information
kirill-zak authored Apr 5, 2018
2 parents 29088a0 + 1a8f2a4 commit 6948dd4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ Add list of domains into `domains.conf`
./unblocker.sh
```

## Optional

You can add you own DNS server - just add it into `dns.conf`.
4 changes: 4 additions & 0 deletions dns.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1.1.1.1
8.8.8.8
8.8.4.4
77.88.8.8
48 changes: 41 additions & 7 deletions unblocker.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/bin/sh

## Intial settings
#######################################
## Intial settings ##
#######################################

SCRIPT_DIR=`pwd`
CONFIG_PATH="$SCRIPT_DIR/settings.conf"
DOMAINS_PATH="$SCRIPT_DIR/domains.conf"
DNS_PATH="$SCRIPT_DIR/dns.conf"

#######################################
## Check and read configuration file ##
#######################################

## Check and read configuration file
## Settings file
if [ ! -f "$CONFIG_PATH" ]; then
echo "Configuration file is not exist!" >&2
exit 1
Expand All @@ -25,12 +33,38 @@ if [ ! -f "$DOMAINS_PATH" ]; then
exit 1
fi

## Add Google DNS into route table
route add 8.8.8.8/32 dev $TUN;
route add 8.8.4.4/32 dev $TUN;
route add 77.88.8.8/32 dev $TUN;
## Check DNS configuration file
if [ ! -f "$DNS_PATH" ]; then
echo "DNS file is not exist" >&2
exit 1
fi

#######################################
## Process dns ##
#######################################

while read -r DNS
do
echo "Start to process DNS [$DNS]..." >&2

## Check on exist route to DNS
DNS_EXIST="$(ip route get "$DNS" | awk 'NR==1{print $3}')"

if [ "$DNS_EXIST" == "$TUN" ]; then
echo "Route for DNS [$DNS] already exist" >&2
else
echo " * Adding route for DNS [$DNS]" >&2
route add "$DNS" dev "$TUN"
fi

echo "End of process DNS [$DNS]" >&2
echo "" >&2
done < "$DNS_PATH"

#######################################
## Process domains ##
#######################################

## Process domains
while read -r DOMAIN
do
echo "Start to process domain [$DOMAIN]..." >&2
Expand Down

0 comments on commit 6948dd4

Please sign in to comment.