From ba46c304bdffdce0b6019a47f6759ce6abbeef90 Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Tue, 16 Aug 2011 10:51:41 +0200 Subject: Initial commit --- cmd_resolve.tcl | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 cmd_resolve.tcl (limited to 'cmd_resolve.tcl') 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] +# 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 " + } 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." -- cgit v1.2.3