jakewmeyer / geo Goto Github PK
View Code? Open in Web Editor NEW:earth_americas: A Bash utility for easy wan, lan, router, dns, mac address, and geolocation output, with clean stdout for piping
License: MIT License
:earth_americas: A Bash utility for easy wan, lan, router, dns, mac address, and geolocation output, with clean stdout for piping
License: MIT License
The regular expression in router_search should be more stringent. If any of the user's network interfaces contain "default" the router_search function may return incorrect results.
The ifconfig command is deprecated on several distributions (such as https://www.archlinux.org/news/deprecation-of-net-tools/), so consider testing for the existence of the newer ip
command and use it instead:
$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether b8:27:eb:02:29:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::ba27:ebff:fe02:296f/64 scope link
valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:0f:60:01:e5:a8 brd ff:ff:ff:ff:ff:ff
inet 172.24.1.1/24 brd 172.14.1.244 scope global wlan0
valid_lft forever preferred_lft forever
inet6 fe80::20f:60ff:fe01:e5a8/64 scope link
valid_lft forever preferred_lft forever
4: mon.wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN qlen 1000
link/ieee802.11/radiotap 00:0f:60:01:e5:a8 brd ff:ff:ff:ff:ff:ff
The ifconfig command is deprecated on several distributions (such as https://www.archlinux.org/news/deprecation-of-net-tools/), so consider testing for the existence of the newer ip
command and use it instead:
$ ip link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether b8:27:eb:02:29:6f brd ff:ff:ff:ff:ff:ff
None of the URLs that are curl'd use https. This is generally bad practice, though in your case because your scripts don't do more than print the output, an attacker could at best print unexpected things to the screen, perhaps tricking the user.
On Linux Geo requires dnsutils for dig
Shellcheck (http://www.shellcheck.net/) finds some potential issues:
In geo line 45:
if [ "$(uname)" == "Darwin" ]; then
^-- SC2039: In POSIX sh, == in place of = is undefined.
In geo line 57:
cat /etc/resolv.conf |grep -i nameserver|head -n1|cut -d ' ' -f2
^-- SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
In geo line 62:
ifconfig $MAC | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'
^-- SC2086: Double quote to prevent globbing and word splitting.
In geo line 72:
if [ $OPTIONS == "all" ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2039: In POSIX sh, == in place of = is undefined.
All of geo's flags are in short form. It would be better to provide alternate like --wan
for -w
, --lan
for -l
and such.
I know you are using getopts
and it doesn't support long flags but still it is possible to implement.
In ./geo line 47:
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
^-- SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]].
^-- SC2046: Quote this to prevent word splitting.
^-- SC2039: In POSIX sh, == in place of = is undefined.
Shebang should be corrected to
#!/usr/bin/env bash
for portability as /bin/sh might not be bash.
I've made an AUR package for Geo here https://aur.archlinux.org/packages/geo-bash/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.