Skip to content

Commit

Permalink
add a way to detect network interface on macOS
Browse files Browse the repository at this point in the history
- typically returns en0, or if a VPN is on it will most likely show one of the `utun` interfaces
  • Loading branch information
emmagamma committed Jan 30, 2024
1 parent ac097bb commit 5f47b16
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scripts/network_bandwidth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 5f47b16

Please sign in to comment.