add a way to detect network interface on macOS

- typically returns en0, or if a VPN is on it will most likely show one of the `utun` interfaces
This commit is contained in:
Emma 2024-01-30 11:16:57 -08:00
parent ac097bbe5c
commit 5f47b1644d

View file

@ -26,6 +26,11 @@ interface_get() {
name="$(ip -o route get 192.168.0.0 | awk '{print $5}')"
fi
;;
Darwin)
if type route >/dev/null; then
name="$(route -n get 192.168.0.0 2>/dev/null | awk '/interface: / {print $2}')"
fi
;;
esac
fi