This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Need help advise with modifying a custom tcl script

Old posts that have not been replied to for several years.
Locked
G
Guest

Post by Guest »

The following is a Script we use for obtaining IP's on a mode +x IRCD
Having had a few problems with some users misusing the IP's posted to channel. We was looking to modify it to work on say. wfc<nick> <<--<nick>being the nick of the other player.And it would be via notice And also a notice to Chanops, so they can ensure
the IP has resolved correctly.
Any ideas help in this would be most appreciated.

# wfc is a means by which non-technical users can advertise their host and IP
# addresses in channel. This script generates the same output as the original
# wfc used by #ScrabbleOn and its siblings. However, this script will reveal
# information for +x users, which the original version could not do.
#
# Note that this version will run slightly slower than the original, as it
# waits for a /whois reply before processing the nslookup.
#
# Requirements for the bot running this script:
# * A shell with nslookup available (this was an existing requirement).
# * At least local IRCOp privileges (to reveal information on +x users).
# * A network running the Unreal ircd (see the notes on RAW 378).
###############################################################################

bind pubm -|- "% wfc" do_wfc
bind raw - 378 wfc:whois_reply
bind raw - 318 wfc:whois_reply

###############################################################################
# This procedure is triggered by a user's request to reveal his or her
# information. If the user is -x his/her address is already available, but
# without reading their flags we don't know if it's legitimate or masked.
# So, we always issue a /whois to see what response we get.
#
# We save the user's channel and (supposed) host address to global arrays
# keyed off of the user's nick, so we can retrieve them in the /whois
# handler. Since they're global (and therefore "sticky") and not cleared
# here, we set timers to unset them in case the /whois doesn't go through;
# this prevents us from generating useless variables that don't expire.
#
# Note that, since the nick becomes part of a variable name, we have to
# strip out any special characters before creating the variable. This will
# only cause a problem if two people whose nicks resolve to the same result
# (e.g., Me[away] and Me{away}) both did a wfc at approximately the same time.
###############################################################################

proc do_wfc {ni uh ha ch text} {

global chan host

regsub -all {|} $ni "" nick
regsub -all {[|]} $nick "" nick
regsub -all {\} $nick "" nick
set chan($nick) $ch
set host($nick) $uh
utimer 30 "unset chan($nick)"
utimer 30 "unset host($nick)"
putserv "WHOIS $ni"
}

###############################################################################
# This procedure handles raw numerics 378 and 318 returned from a /whois.
#
# * 318 is a standard "End of /whois" message.
# * 378 includes the full unmasked host address of the target.
#
# (Note that a 378 is only sent if the target is +x AND the bot is an IRCOp.
# Note also that a 378 and its format are specific to the Unreal ircd; for
# example, PTLink uses a differently-formatted raw 616 for this function.)
#
# If a 378 is received, parse out the user's host address and store it over
# top of the one that was originally retrieved (since the latter is now
# known to be masked).
#
# When a 318 is received, grab the user's host address and pass it to
# nslookup, then process the results and display them in channel.
#
# Note that the array "addr" is set global only so that data stored in it
# will be "sticky" and be retained from the 378 to the 318... in other words,
# the equivalent of C's "static."
###############################################################################

proc wfc:whois_reply {from keyword args} {

global chan host addr

regsub -all {|} $args "" nick
regsub -all {[|]} $nick "" nick
regsub -all {\} $nick "" nick
set nick [lindex [split $nick] 1]

if {![info exists chan($nick)]} {
return 0
}

if {$keyword == 378} {
set addr($nick) [string trimright [lindex [split $args "@"] 1] }]
utimer 30 "unset addr($nick)"
}
if {$keyword == 318} {
if {![info exists addr($nick)]} {
set addr($nick) [lindex [split $host($nick) "@"] 1]
}

set address $addr($nick)
catch {exec nslookup $address} dns
set dns [lrange $dns 5 end]
set ip [lindex $dns [expr [lsearch $dns "Address:"] + 1]]

set ni [lindex [split $args] 1]
regsub -all {\\} $ni "/" ni
regsub -all {\} $ni "" ni
regsub -all "/" $ni {\} ni

putserv "PRIVMSG $chan($nick) :$ni's u@h is $addr($nick)"
putserv "PRIVMSG $chan($nick) :$ni's IP address is $ip"
unset addr($nick)
unset host($nick)
unset chan($nick)
}
return 0
}


Locked