wg-quick: darwin: reorder functions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
80ff1f8ded
commit
986feba2ee
|
@ -159,7 +159,7 @@ set_mtu() {
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done < <(netstat -nr -f inet)
|
done < <(netstat -nr -f inet)
|
||||||
[[ -n $defaultif && $(ifconfig "$defaultif") =~ mtu\ ([0-9]+) ]] && mtu="${BASH_REMATCH[1]}"
|
[[ -n $defaultif && $(ifconfig "$defaultif") =~ mtu\ ([0-9]+) ]] && mtu="${BASH_REMATCH[1]}"
|
||||||
[[ $mtu -gt 0 ]] || mtu=1500
|
[[ $mtu -gt 0 ]] || mtu=1500
|
||||||
mtu=$(( mtu - 80 ))
|
mtu=$(( mtu - 80 ))
|
||||||
[[ $(ifconfig "$REAL_INTERFACE") =~ mtu\ ([0-9]+) ]] && current_mtu="${BASH_REMATCH[1]}"
|
[[ $(ifconfig "$REAL_INTERFACE") =~ mtu\ ([0-9]+) ]] && current_mtu="${BASH_REMATCH[1]}"
|
||||||
|
@ -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 New Issue