wg-quick: darwin: reorder functions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
80ff1f8ded
commit
986feba2ee
|
@ -193,6 +193,24 @@ collect_endpoints() {
|
||||||
done < <(wg show "$REAL_INTERFACE" 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() {
|
set_endpoint_direct_route() {
|
||||||
local old_endpoints endpoint old_gateway4 old_gateway6 remove_all_old=0 added=( )
|
local old_endpoints endpoint old_gateway4 old_gateway6 remove_all_old=0 added=( )
|
||||||
old_endpoints=( "${ENDPOINTS[@]}" )
|
old_endpoints=( "${ENDPOINTS[@]}" )
|
||||||
|
@ -244,24 +262,6 @@ set_endpoint_direct_route() {
|
||||||
ENDPOINTS=( "${added[@]}" )
|
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() {
|
set_dns() {
|
||||||
collect_new_service_dns
|
collect_new_service_dns
|
||||||
local service response
|
local service response
|
||||||
|
|
Loading…
Reference in a new issue