diff options
| author | 2024-08-09 19:04:10 +0000 | |
|---|---|---|
| committer | 2024-10-23 00:39:49 -0600 | |
| commit | 985dcb2901d2527b79976df787035425294200b9 (patch) | |
| tree | d49caf539627b062c3e8406854ffbc214804661c /cmd_resolve.tcl | |
init
Diffstat (limited to 'cmd_resolve.tcl')
| -rw-r--r-- | cmd_resolve.tcl | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/cmd_resolve.tcl b/cmd_resolve.tcl new file mode 100644 index 0000000..a41f3a7 --- /dev/null +++ b/cmd_resolve.tcl @@ -0,0 +1,46 @@ +# +# cmd_resolve.tcl +# written by Jeff Fisher (guppy@eggheads.org) +# +# This script adds the commands '.resolve' and '.dns' which can be used to +# lookup hostnames or ip addresses in the partyline without causing the bot +# to block while doing so thanks to the dns module. +# +# updates +# ------- +# 15Apr2003: fixed a logging bug and stop using regexp incorrectly +# 05Nov2000: fixed a nasty security hole, .resolve [die] <grin> +# 04Nov2000: first version + +bind dcc -|- resolve resolve_cmd +bind dcc -|- dns resolve_cmd + +proc resolve_cmd {hand idx arg} { + global lastbind + if {[scan $arg "%s" hostip] != 1} { + putidx $idx "Usage: $lastbind <host or ip>" + } else { + putidx $idx "Looking up $hostip ..." + set hostip [split $hostip] + dnslookup $hostip resolve_callback $idx $hostip $lastbind + } + return 0 +} + +proc resolve_callback {ip host status idx hostip cmd} { + if {![valididx $idx]} { + return 0 + } elseif {!$status} { + putidx $idx "Unable to resolve $hostip" + } elseif {[string tolower $ip] == [string tolower $hostip]} { + putidx $idx "Resolved $ip to $host" + } else { + putidx $idx "Resolved $host to $ip" + } + putcmdlog "#[idx2hand $idx]# $cmd $hostip" + return 0 +} + +loadhelp cmd_resolve.help + +putlog "Loaded cmd_resolve.tcl successfully." |
