wg-quick: darwin: reorder functions

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2018-05-17 04:58:27 +02:00
parent 80ff1f8ded
commit 986feba2ee
1 changed files with 19 additions and 19 deletions

View File

@ -193,6 +193,24 @@ collect_endpoints() {
done < <(wg show "$REAL_INTERFACE" endpoints)
}
declare -A SERVICE_DNS
collect_new_service_dns() {
local service get_response
local -A found_services
{ read -r _ && while read -r service; do
[[ $service == "*"* ]] && service="${service:1}"
found_services["$service"]=1
[[ -n ${SERVICE_DNS["$service"]} ]] && continue
get_response="$(cmd networksetup -getdnsservers "$service")"
[[ $get_response == *" "* ]] && get_response="Empty"
[[ -n $get_response ]] && SERVICE_DNS["$service"]="$get_response"
done; } < <(networksetup -listallnetworkservices)
for service in "${!SERVICE_DNS[@]}"; do
[[ ${found_services["$service"]} == 1 ]] || unset SERVICE_DNS["$service"]
done
}
set_endpoint_direct_route() {
local old_endpoints endpoint old_gateway4 old_gateway6 remove_all_old=0 added=( )
old_endpoints=( "${ENDPOINTS[@]}" )
@ -244,24 +262,6 @@ set_endpoint_direct_route() {
ENDPOINTS=( "${added[@]}" )
}
declare -A SERVICE_DNS
collect_new_service_dns() {
local service get_response
local -A found_services
{ read -r _ && while read -r service; do
[[ $service == "*"* ]] && service="${service:1}"
found_services["$service"]=1
[[ -n ${SERVICE_DNS["$service"]} ]] && continue
get_response="$(cmd networksetup -getdnsservers "$service")"
[[ $get_response == *" "* ]] && get_response="Empty"
[[ -n $get_response ]] && SERVICE_DNS["$service"]="$get_response"
done; } < <(networksetup -listallnetworkservices)
for service in "${!SERVICE_DNS[@]}"; do
[[ ${found_services["$service"]} == 1 ]] || unset SERVICE_DNS["$service"]
done
}
set_dns() {
collect_new_service_dns
local service response