-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #418 from mysteriumnetwork/release-03-fixes
Backport of configuration fixes from #406
- Loading branch information
Showing
9 changed files
with
96 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/bin/bash | ||
|
||
# Mac name-resolution updater based on @cl's script here: | ||
# https://blog.netnerds.net/2011/10/openvpn-update-client-dns-on-mac-os-x-using-from-the-command-line/ | ||
# Openvpn envar parsing taken from the script in debian's openvpn package. | ||
# Smushed together and improved by @andrewgdotcom. | ||
|
||
# Parses DHCP options from openvpn to update resolv.conf | ||
# To use set as 'up' and 'down' script in your openvpn *.conf: | ||
# up /etc/openvpn/update-resolv-conf | ||
# down /etc/openvpn/update-resolv-conf | ||
|
||
[ "$script_type" ] || exit 0 | ||
[ "$dev" ] || exit 0 | ||
|
||
NMSRVRS=() | ||
SRCHS=() | ||
adapters=() | ||
|
||
NETWORKSETUP=/usr/sbin/networksetup | ||
|
||
# Set bash delimeter to be line break (temporarily) | ||
IFSSAVE=$IFS | ||
IFS=$'\n' | ||
# Get adapter list | ||
for i in `$NETWORKSETUP -listallnetworkservices |grep -v denotes`; do | ||
adapters=(${adapters[@]} "$i") | ||
done | ||
IFS=$IFSSAVE | ||
|
||
split_into_parts() | ||
{ | ||
part1="$1" | ||
part2="$2" | ||
part3="$3" | ||
} | ||
|
||
update_all_dns() | ||
{ | ||
for adapter in "${adapters[@]}" | ||
do | ||
echo updating dns for $adapter | ||
# set dns server to the vpn dns server | ||
if [[ "${SRCHS[@]}" ]]; then | ||
$NETWORKSETUP -setsearchdomains "$adapter" "${SRCHS[@]}" | ||
fi | ||
if [[ "${NMSRVRS[@]}" ]]; then | ||
$NETWORKSETUP -setdnsservers "$adapter" "${NMSRVRS[@]}" | ||
fi | ||
done | ||
} | ||
|
||
clear_all_dns() | ||
{ | ||
for adapter in "${adapters[@]}" | ||
do | ||
echo updating dns for $adapter | ||
$NETWORKSETUP -setdnsservers "$adapter" empty | ||
$NETWORKSETUP -setsearchdomains "$adapter" empty | ||
done | ||
} | ||
|
||
case "$script_type" in | ||
up) | ||
for optionvarname in ${!foreign_option_*} ; do | ||
option="${!optionvarname}" | ||
echo "$option" | ||
split_into_parts $option | ||
if [ "$part1" = "dhcp-option" ] ; then | ||
if [ "$part2" = "DNS" ] ; then | ||
NMSRVRS=(${NMSRVRS[@]} $part3) | ||
elif [ "$part2" = "DOMAIN" ] ; then | ||
SRCHS=(${SRCHS[@]} $part3) | ||
fi | ||
fi | ||
done | ||
update_all_dns | ||
;; | ||
down) | ||
clear_all_dns | ||
;; | ||
esac |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters