eggheads / eggdrop

The Eggdrop IRC Bot
GNU General Public License v2.0
508 stars 84 forks source link

Add a tcl ping command #1693

Closed crazycatdevs closed 1 month ago

crazycatdevs commented 1 month ago

Hello,

This is a feature request, not an issue. I'd like to have a tcl ping command which just send one packet and returns the time or false (if host is not reachable).

Invoke: ping <host/ip> [timeout]

Returns: a list containing host and time or false

Or if it can be as a module, it could be great too.

michaelortmann commented 1 month ago

We discussed some tcl and some C/mod code in IRC:

tcl async version: https://pastebin.com/Urn3AitX

tcl sync version: https://pastebin.com/zm82fGBp

C sync version: https://pastebin.com/P727Jdmx

Could be enough to solve your Issue.

But now with two thumbs up, it looks like it could be an often wished for functionality, so we should discuss shipping such functionality with eggdrop core with a small tcl or as an example in some doc.

michaelortmann commented 1 month ago

If we ship such functionality, it should be non blocking or with a very tight timeout, or limited to +m/+n, for no +o should not be able to block the bot with any tcl command.

thommey commented 1 month ago

Coroutine version (looks synchronous but is asynchronous): https://pastebin.com/cDYYpMpR

In general adding this functionality to Eggdrop as universally useful is not possible, because you'd have to write various parsers for the various ping-implementations, so we can't ship a generic version. And all it does is execute ping because you have no other choice if you don't have special privileges on the host system to create ICMP packets.