cnping
cnping copied to clipboard
Added option to bind to specific network interface
As suggested in #67 i implemented a -I
option to choose the network interface.
After looking into the source code of ping it seemed stright forword (just one setsockopt
).
https://github.com/iputils/iputils/blob/master/ping/ping.c#L618
A few problems still need to be addressed:
- The
<sys/socket.h>
include wont work with windows. In which of the#ifdef
should that be added? - What is with the CLI argument on windows? should that be hidden, since it is currently a "linux only" feature?
- This HTTP-Ping ignores the device selection. Is that a problem? Is it useful to have a interface selection on HTTP-Ping?
Test with a wireguard VPN and normal ethernet interface:
Nice, it seems now is cnping time again since I'm currently looking into IPv6 support :tada:
Would it be possible to implement it for Windows without too much effort? Otherwise I'd say we just print an error in case someone tries to use it on Windows. I don't expect much Windows users tbh.
Hint on the include for windows: c++ - Where does one get the "sys/socket.h" header/source file? - Stack Overflow
In general, I don't think we have conventions on the ifdefs, just pick whatever you think is best.
Regarding HTTP-Ping: Same as Windows, if possible it would be nice to have, otherwise print an error and that's it. A use case would be testing a VPN vs direct connection.
These are just my opinions, if cnlohr sees things differently his opinions will count.
The CI seems to have difficulties with the new import, I'll have to look into that. Did you need to install any extra packages for those headers?
Would it be possible to implement it for Windows without too much effort?
I have no idea how the Windows API for that looks like. I don't want to implement it anyways. As you said: Who uses cnping with windows anyways?
Regarding HTTP-Ping: Same as Windows, if possible it would be nice to have
I will look into that. It might be pretty simple too.
The CI seems to have difficulties with the new import, I'll have to look into that. Did you need to install any extra packages for those headers?
No,<sys/socket.h>
is a default include. I think the CI failed with compiling the windows build. Fixing the include for windows (as mentioned in my first message) should fix the CI-Pipline aswell.
Nitpick: Git commit messages should always be in present tense, i.e. Add instead of Added.
I just had a quick test and it works great so far, thank you!
Thats a green CI, I'll call it a day. Do you want to give http a go or should we just error out?
I just did a short test and it does work to bind HTTP to an interface. I am going to implement it completely tomorrow.
Thank you, all tests on Linux work as expected, will give it a try on Windows and then merge it. For my own testing: cnping.zip
I just run your test cnping.zip on windows10 and it looks fine to me. (First one worked, other two returned the error)
Only -I
without a second argument print the usage.