fix: use the `ip` command
- fixes #41
- fix: remove usage of deprecated
ifconfig
Now using ip (which is available since at least 2011).
- fix: stick with
ipfor the route check
The new code is more readable and contains less lines actually. But I needed to keep the macOS compatibility, so that's why the patch is more important.
If the macOs support can be dropped, then I could simplify more, LMK.
OK, the code quite changed since the first commit. It's is very simple on Linux while keeping the compat with macOS.
Awesome @BoboTiG! Thanks a lot.
I'll put @herr-seppia as reviewer, as I can't test it properly this week. Looks very good though!
Superseded by #123.
@BoboTiG my PR still doesn't fix the underlying issue, we still rely on ifconfig and route. Ideally we'd upgrade to something more modern like ip and iproute2 in the near future to deal with the local IP. Feel free to tackle #41, and completely rid the script of ifconfig if you have time.
The most important thing is that the behavior that we currently have still works on DigitalOcean/Vultr/Hetzner/
Thank you for putting in the effort to help!
@HDauven I'll see to do a second round after #123 is merged, and will try to split the new code in functions for an easier review.