PDA

View Full Version : [TCL] dnslookup for irccheck script


toki
04-16-2004, 09:35 AM
hi,

i started to do my own script wich parses nicknames on a channel and writes infos about them into a txt file (eggdrop part) and then itlc script for io checking this file if user has flag e.g. to permit or deny login. (ioitclpart)

my prob is that i have only getchanhost for ident@host and in tcl docu there is a dnslookup proc but without working example. finally i want a txt file with:

user ident dns ip

anyone a short idea how the dnslookup should look like? i tested several tcl scripts for dnslookup from egghelp.org but they didnt work and the dnslookup is there but always says smt about wrong # of argument etc.

thx in advance toki

code atm is about:

### This Script prevents user from login if they are not on an IRC channel! ###

### !CONFIGURATION!
set controlchan "#channelname"
set exemptusers "toki"
#set exemptgroups "admins"
set alloweduserfile "E:/User/ioFTPD/scripts/ioIRCCHECK/allowed.txt"

### CONFIGURATION END HERE!

bind time - "* * * * *" createlist:time

proc createlist:time { min hour day month year } {
createlist
}

proc createlist { } {
global controlchan exemptusers alloweduserfile
set file [open $alloweduserfile w]
set userlist [chanlist $controlchan]
foreach username $userlist {
set chanhost [getchanhost $username $controlchan]
set splitchanhost [split $chanhost \@]
set ident [lindex $splitchanhost 0]
set host [lindex $splitchanhost 1]
set outline ""
set resip ""
# [dnslookup $host do_dnslookup $resip]
if { [matchattr [nick2hand $username $controlchan] |+F $controlchan] } {
set outline "[nick2hand $username $controlchan] $ident $host"
puts $file $outline
}
}
close $file
}

proc do_dnslookup { ip hostname status resip } {
global resip
set resip $ip
}

putlog "*** ioirccheck.tcl for ioFTPD by toki <toki76@web.de> loaded!"

and tcl docu says:
dnslookup <ip-address/hostname> <proc> [[arg1] [arg2] ... [argN]]
Description: This issues an asynchronous dns lookup request. The
command will block if dns module is not loaded; otherwise it will
either return immediately or immediately call the specified proc
(e.g. if the lookup is already cached).

As soon as the request completes, the specified proc will be called
as follows:

<proc> <ipaddress> <hostname> <status> [[arg1] [arg2] ... [argN]]

status is 1 if the lookup was successful and 0 if it wasn't. All
additional parameters (called arg1, arg2 and argN above) get
appended to the proc's other parameters.
Returns: nothing
Module: core

Mouton
04-16-2004, 11:37 AM
What error do u get exactly ?

U don't need or should pass resip to your do_dnslookup proc, since you use global on it.

U're missing a global on resip in your createlist proc.

Once you got it working, u'll need to use a wait just after calling dnslookup to wait until the resip variable is changed to continue and be able to write it in your file.

toki
04-16-2004, 12:34 PM
ok works now thx mouton!!!

final is:
set resip [dnslookup $host do_dnslookup]in createlist proc and do_dnslookup is proc do_dnslookup { ip hostname status } {
global resip
set resip $ip
}

leaving do_dnslookup emty proc OR not doing "set resip [dnslookup $host do_dnslookup]" but only "[dnslookup $host do_dnslookup]" didnt work...

thx again :) greez toki

PS: if anyone is interested in something like that... tell me and ill share the script when it is complete. (and fits to all my needs)

toki
04-16-2004, 12:42 PM
Originally posted by Mouton
Once you got it working, u'll need to use a wait just after calling dnslookup to wait until the resip variable is changed to continue and be able to write it in your file.

just wait certain seconds? or really check until resip has changed?

Mouton
04-16-2004, 12:55 PM
until resip has changed.
there's a tcl function for exactly that...
wait or vwait... don't remember.

toki
04-20-2004, 02:46 AM
hmms
vwait resip

either in the do_dnslookup proc or right after the set line in the main proc causes the windrop not to repond to any further request... seems its waitung forever.

without vwait i get ips for several dns lookups but not for all.

im just trying
after 200 { set resip ... }
vwait resip

any further ideas?

darkone
04-26-2004, 07:57 PM
Howabout setting up timer, which checks change of variable?