summaryrefslogtreecommitdiffstats
path: root/cmd_resolve.tcl
diff options
context:
space:
mode:
authorStefan Ritter <xeno@thehappy.de>2011-08-16 10:51:41 +0200
committerStefan Ritter <xeno@thehappy.de>2011-08-16 10:51:41 +0200
commitba46c304bdffdce0b6019a47f6759ce6abbeef90 (patch)
tree40a5b204637cb65c5bb91bd4f26a248ea498e019 /cmd_resolve.tcl
Initial commit
Diffstat (limited to 'cmd_resolve.tcl')
-rw-r--r--cmd_resolve.tcl48
1 files changed, 48 insertions, 0 deletions
diff --git a/cmd_resolve.tcl b/cmd_resolve.tcl
new file mode 100644
index 0000000..36ccb4e
--- /dev/null
+++ b/cmd_resolve.tcl
@@ -0,0 +1,48 @@
+#
+# 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
+#
+# $Id: cmd_resolve.tcl,v 1.4 2003/04/16 01:03:04 guppy Exp $
+
+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."