mirror of
https://github.com/ivanilves/xiringuito.git
synced 2025-05-17 15:50:10 -07:00
When routes expire in macOS, `netstat -r` shows a trailing exclamation point to indicate this. In the current version of this code, this will set `DEF_GW_IF` to contain a `!`, causing subsequent DNS modifications on OSX to fail. This change ignores the the `!` that can be set in this case.
12 lines
361 B
Bash
Executable File
12 lines
361 B
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Get name of the MacOSX network service (device connection)
|
|
#
|
|
if [[ -n "${FORCE_NETWORK_SERVICE}" ]]; then
|
|
echo "${FORCE_NETWORK_SERVICE}"
|
|
exit 0
|
|
fi
|
|
|
|
DEF_GW_IF=$(netstat -nr | grep default | awk '!/tun|!/ {print $NF}' | tail -n1)
|
|
networksetup -listnetworkserviceorder | grep -B1 " Device: ${DEF_GW_IF})" | head -n1 | sed 's/^(.*) //'
|