-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use the ip
command
#84
base: main
Are you sure you want to change the base?
Conversation
Now using `ip` (which is available since at least 2011).
bin/detect_ips.sh
Outdated
(( ( ip & mask ) == ( gw & mask ) )) && | ||
int2ip $ip myIp && int2ip $mask netMask | ||
} | ||
} | ||
done < <(/sbin/ifconfig) | ||
done < <(ip -4 -c=never -br addr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example of output from such a command:
lo UNKNOWN 127.0.0.1/8
enp4s0 UP 192.168.2.10/24
br-23a6b14a9fa6 DOWN 172.18.0.1/16
br-4abc919a1eb3 DOWN 172.20.0.1/16
docker0 UP 172.17.0.1/16
br-b804039dfb11 DOWN 172.19.0.1/16
bin/detect_ips.sh
Outdated
while IFS=$' :\t\r\n' read before netmask after; do | ||
mask=$netmask | ||
done < <(/usr/bin/ipcalc -n -b $rhs | grep Netmask) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code will convert IP/24
to 255.255.255.0
.
This comment was marked as outdated.
This comment was marked as outdated.
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! |
ifconfig
Now using
ip
(which is available since at least 2011).ip
for the route checkThe 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.