Allow specifying external domain names to be routed through VPN

This commit is contained in:
Janis Jansons 2023-12-14 16:45:26 +02:00
parent 907724b864
commit e2c5e90641
4 changed files with 26 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
routes.txt routes.txt
domains.txt
run.sh run.sh

View File

@ -15,6 +15,7 @@ brew install vpn-slice
brew install oath-toolkit brew install oath-toolkit
brew install swiftbar brew install swiftbar
brew install terminal-notifier brew install terminal-notifier
brew install bind
``` ```
On Macos add server address, username, password and 2fa seed in keychain with these names: On Macos add server address, username, password and 2fa seed in keychain with these names:

2
domains.txt.sample Normal file
View File

@ -0,0 +1,2 @@
www.example.com
en.wikipedia.org

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
ROUTE_FILE=routes.txt ROUTE_FILE=routes.txt
DOMAIN_FILE=domains.txt
VPN_SLICE=vpn-slice VPN_SLICE=vpn-slice
@ -50,12 +51,32 @@ if test -f "$ROUTE_FILE"; then
echo "Loading subnets from $ROUTE_FILE" echo "Loading subnets from $ROUTE_FILE"
while read p; do while read p; do
case "$p" in \#*) continue ;; esac case "$p" in \#*) continue ;; esac
add_subnet $p if [ "$p" != "" ]; then
echo "Subnet: ${p}"
add_subnet $p
fi
done <$ROUTE_FILE done <$ROUTE_FILE
else else
echo "$ROUTE_FILE does not exist. This should not happen." echo "$ROUTE_FILE does not exist. This should not happen."
fi fi
if test -f "$DOMAIN_FILE"; then
echo "Loading domains from $DOMAIN_FILE"
while read d; do
case "$d" in \#*) continue ;; esac
echo "Domain: ${d}"
if [ "$d" != "" ]; then
for p in `dig +short "$d" a | grep '^[.0-9]*$'`; do
echo "Resolved IP for domain ${d}: ${p}"
add_subnet $p/32
done
fi
done <$DOMAIN_FILE
else
echo "$DOMAIN_FILE does not exist. Ignoring."
fi
# Load default script # Load default script
$VPN_SLICE -S $VPN_SLICE -S