tcldrop-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tcldrop/CVS] tcldrop/modules conn.tcl dcc.tcl idx.tcl


From: Philip Moore
Subject: [Tcldrop/CVS] tcldrop/modules conn.tcl dcc.tcl idx.tcl
Date: Sat, 06 Dec 2003 03:41:20 -0500

CVSROOT:        /cvsroot/tcldrop
Module name:    tcldrop
Branch:         
Changes by:     Philip Moore <address@hidden>   03/12/06 03:41:20

Modified files:
        modules        : conn.tcl dcc.tcl idx.tcl 

Log message:
        Fixed the bug in the conn.tcl that was killing the idx before it was 
time.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/tcldrop/tcldrop/modules/conn.tcl.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/tcldrop/tcldrop/modules/dcc.tcl.diff?tr1=1.34&tr2=1.35&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/tcldrop/tcldrop/modules/idx.tcl.diff?tr1=1.11&tr2=1.12&r1=text&r2=text

Patches:
Index: tcldrop/modules/conn.tcl
diff -u tcldrop/modules/conn.tcl:1.12 tcldrop/modules/conn.tcl:1.13
--- tcldrop/modules/conn.tcl:1.12       Sat Dec  6 02:45:19 2003
+++ tcldrop/modules/conn.tcl    Sat Dec  6 03:41:20 2003
@@ -3,7 +3,7 @@
 #              * The connect and control commands, used for all outgoing 
connections.
 #      Depends: idx.
 #
-# $Id: conn.tcl,v 1.12 2003/12/06 07:45:19 fireegl Exp $
+# $Id: conn.tcl,v 1.13 2003/12/06 08:41:20 fireegl Exp $
 #
 # Copyright (C) 2003 FireEgl (Philip Moore) <address@hidden>
 #
@@ -32,7 +32,7 @@
 namespace eval ::tcldrop::conn {
        variable version {0.7}
        package provide tcldrop::conn $version
-       variable rcsid {$Id: conn.tcl,v 1.12 2003/12/06 07:45:19 fireegl Exp $}
+       variable rcsid {$Id: conn.tcl,v 1.13 2003/12/06 08:41:20 fireegl Exp $}
        variable Defaults
        if {![info exists ::my-ip]} { set ::my-ip {} }
        set Defaults(global) [list {async} {1} {buffering} {line} {myaddr} 
${::my-ip} {blocking} {0} {timeout} {237}]
@@ -100,9 +100,9 @@
                array set options [Config - $args]
                fconfigure $sock -buffering $options(buffering) -blocking 
$options(blocking)
                set idx [::tcldrop::idx::Assign]
+               ::tcldrop::idx::Register $idx [concat [array get options] [list 
sock $sock idx $idx timestamp [unixtime] connecttimer [utimer $options(timeout) 
[list ::tcldrop::conn::ConnectTimeout $idx]]]]
                fileevent $sock writable [list ::tcldrop::conn::Write $idx]
                fileevent $sock readable [list ::tcldrop::conn::Read $idx]
-               ::tcldrop::idx::Register $idx [concat [array get options] [list 
sock $sock idx $idx timestamp [unixtime] connecttimer [utimer $options(timeout) 
[list ::tcldrop::conn::ConnectTimeout $idx]]]]
                return $idx
        } else {
                return -code error $sock
@@ -120,16 +120,16 @@
        if {[set error [fconfigure $idxinfo(sock) -error]] != {}} {
                putloglev d * "net: error!(connect) idx $idx  (${error})"
                catch { killutimer $idxinfo(connecttimer) }
+               if {[info exists idxinfo(errors)]} { $idxinfo(errors) $idx 
$error }
                killidx $idx
                # Send {} to the control proc and kill the sock/idx.  Note, A 
check on valididx (from the control proc) is one way to tell wether or not an 
EOF has actually been received.
-               $idxinfo(control) $idx {}
-               if {[info exists idxinfo(errors)]} { $idxinfo(errors) $idx 
$error }
+               if {[info exists idxinfo(control)]} { $idxinfo(control) $idx {} 
}
        } elseif {[eof $idxinfo(sock)]} {
                putloglev d * "net: eof!(read) idx $idx"
+               if {[info exists idxinfo(errors)]} { $idxinfo(errors) $idx 
{EOF} }
                killidx $idx
                # Send {} to the control proc and kill the sock/idx.  Note, A 
check on valididx (from the control proc) is one way to tell wether or not an 
EOF has actually been received.
-               $idxinfo(control) $idx {}
-               if {[info exists idxinfo(errors)]} { $idxinfo(errors) $idx 
{EOF} }
+               if {[info exists idxinfo(control)]} { $idxinfo(control) $idx {} 
}
        } elseif {[info exists idxinfo(control)]} {
                # For speed, we process all available lines.  (This is 
absolutely necessary when running inside an Eggdrop, because Eggdrop's event 
loops are 1 second apart)
                while {[gets $idxinfo(sock) line] >= 1} {
Index: tcldrop/modules/dcc.tcl
diff -u tcldrop/modules/dcc.tcl:1.34 tcldrop/modules/dcc.tcl:1.35
--- tcldrop/modules/dcc.tcl:1.34        Sat Dec  6 02:45:19 2003
+++ tcldrop/modules/dcc.tcl     Sat Dec  6 03:41:20 2003
@@ -1,6 +1,6 @@
 # dcc.tcl --
 #
-# $Id: dcc.tcl,v 1.34 2003/12/06 07:45:19 fireegl Exp $
+# $Id: dcc.tcl,v 1.35 2003/12/06 08:41:20 fireegl Exp $
 #
 # Copyright (C) 2003 FireEgl (Philip Moore) <address@hidden>
 #
@@ -32,7 +32,7 @@
        # Provide the users module:
        variable version {0.4}
        package provide tcldrop::dcc $version
-       variable rcsid {$Id: dcc.tcl,v 1.34 2003/12/06 07:45:19 fireegl Exp $}
+       variable rcsid {$Id: dcc.tcl,v 1.35 2003/12/06 08:41:20 fireegl Exp $}
        #checkmodule console
        # Export all the commands that should be available to 3rd-party 
scripters:
        namespace export dcclist listen putdcc getchan setchan console echo 
strip idx2hand hand2idx link bots islinked putbot putallbots sock2idx idx2sock
@@ -252,151 +252,151 @@
 }
 
 proc ::tcldrop::dcc::Read {idx line} {
-       set starttime [clock clicks]
-       foreach {a d} [::tcldrop::idx::Info $idx] { array set chatinfo $d }
-       switch -- $chatinfo(type) {
-               {TELNET_ID} {
-                       if {[string equal -nocase {new} $line]} {
-                               # They want to sign-in as a NEW user.
-                               if {${::open-telnets} || [countusers] == 0} {
-                                       # Let them.
-                                       putidx $idx {Enter the handle you would 
like to use.}
-                                       ::tcldrop::idx::ChInfo $idx [list type 
TELNET_NEW other {new  waited 2s} timestamp [unixtime] traffictype partyline]
+       # FixMe: This should do something useful when it receives a {} (meaning 
the sock is no longer connected).
+       if {$line == {}} { return }
+       foreach {a d} [::tcldrop::idx::Info $idx] {
+               array set chatinfo $d
+               switch -- $chatinfo(type) {
+                       {TELNET_ID} {
+                               if {[string equal -nocase {new} $line]} {
+                                       # They want to sign-in as a NEW user.
+                                       if {${::open-telnets} || [countusers] 
== 0} {
+                                               # Let them.
+                                               putidx $idx {Enter the handle 
you would like to use.}
+                                               ::tcldrop::idx::ChInfo $idx 
[list type TELNET_NEW other {new  waited 2s} timestamp [unixtime] traffictype 
partyline]
+                                       } else {
+                                               # Denied!
+                                               putidx $idx {You don't have 
access.  (not accepting 'new' users)}
+                                               killidx $idx
+                                       }
                                } else {
-                                       # Denied!
-                                       putidx $idx {You don't have access.  
(not accepting 'new' users)}
-                                       killidx $idx
+                                       if {[validuser $line] && ![passwdok 
$line -]} {
+                                               if {[matchattr $line b]} {
+                                                       putidx $idx {passreq}
+                                               } else {
+                                                       putidx $idx {Password.}
+                                               }
+                                               ::tcldrop::idx::ChInfo $idx 
[list handle $line type CHAT_PASS other {pass  waited 3s} timestamp [unixtime] 
traffictype partyline]
+                                       } else {
+                                               if {[matchattr $line b]} {
+                                                       # FixMe: putidx $idx 
{FixMe: Make sure bots without passwords can link the first time.}
+                                               } else {
+                                                       putidx $idx {You don't 
have access.}
+                                               }
+                                       }
                                }
-                       } else {
-                               if {[validuser $line] && ![passwdok $line -]} {
-                                       if {[matchattr $line b]} {
-                                               putidx $idx {passreq}
+                       }
+                       {CHAT_PASS} {
+                               # FixMe: For bots, this should send "*hello" 
and "version ",
+                               #        and change the type to "BOT".
+                               if {[passwdok $chatinfo(handle) $line]} {
+                                       if {[matchattr $chatinfo(handle) b]} {
+                                               ::tcldrop::idx::ChInfo $idx 
[list type BOT other {bot  flags: } timestamp [unixtime] traffictype botnet]
+                                               putidx $idx {*hello}
+                                               putidx $idx {version }
                                        } else {
-                                               putidx $idx {Password.}
+                                               ::tcldrop::idx::ChInfo $idx 
[list type CHAT other {chat  flags: ?/0} timestamp [unixtime] traffictype 
partyline]
+                                               putidx $idx {Welcome!}
+                                               # FixMe: Show the MOTD and 
whatnot here.
                                        }
-                                       ::tcldrop::idx::ChInfo $idx [list 
handle $line type CHAT_PASS other {pass  waited 3s} timestamp [unixtime] 
traffictype partyline]
                                } else {
-                                       if {[matchattr $line b]} {
-                                               # FixMe: putidx $idx {FixMe: 
Make sure bots without passwords can link the first time.}
+                                       if {[matchattr $chatinfo(handle) b]} {
+                                               putidx $idx {badpass}
                                        } else {
-                                               putidx $idx {You don't have 
access.}
+                                               putidx $idx {Bad password!}
                                        }
+                                       killidx $idx
                                }
                        }
-               }
-               {CHAT_PASS} {
-                       # FixMe: For bots, this should send "*hello" and 
"version ",
-                       #        and change the type to "BOT".
-                       if {[passwdok $chatinfo(handle) $line]} {
-                               if {[matchattr $chatinfo(handle) b]} {
-                                       ::tcldrop::idx::ChInfo $idx [list type 
BOT other {bot  flags: } timestamp [unixtime] traffictype botnet]
-                                       putidx $idx {*hello}
-                                       putidx $idx {version }
+                       {TELNET_NEW} {
+                               # Make sure the handle they want isn't already 
taken..
+                               if {[validuser $line]} {
+                                       putidx $idx {Sorry, that handle is 
taken already.}
+                                       putidx $idx {Try another one please: }
                                } else {
-                                       ::tcldrop::idx::ChInfo $idx [list type 
CHAT other {chat  flags: ?/0} timestamp [unixtime] traffictype partyline]
-                                       putidx $idx {Welcome!}
-                                       # FixMe: Show the MOTD and whatnot here.
+                                       putidx $idx {Okay, now choose and enter 
a password: }
+                                       adduser $line *!$chatinfo(remote)
+                                       ::tcldrop::idx::ChInfo $idx [list 
handle $line type TELNET_PW other {newp  waited 3s} timestamp [unixtime] 
traffictype partyline]
                                }
-                       } else {
-                               if {[matchattr $chatinfo(handle) b]} {
-                                       putidx $idx {badpass}
+                       }
+                       {TELNET_PW} {
+                               if {[string length $line] < 4} {
+                                       putidx $idx {Try to use at least 4 
characters in your password.}
+                                       putidx $idx {Choose and enter a 
password: }
+                                       ::tcldrop::idx::ChInfo $idx [list 
timestamp [unixtime] traffictype partyline]
                                } else {
-                                       putidx $idx {Bad password!}
+                                       setuser $chatinfo(handle) pass $line
+                                       putidx $idx {Remember that!  You'll 
need it next time you log in.}
+                                       putidx $idx "You now have an account"
+                                       chattr $chatinfo(handle) +pnmofvtxj
+                                       ::tcldrop::idx::ChInfo $idx [list type 
CHAT other {chat  flags: ?/0} timestamp [unixtime] traffictype partyline]
+                                       # FixMe: Show the MOTD or whatever here.
                                }
-                               killidx $idx
                        }
-               }
-               {TELNET_NEW} {
-                       # Make sure the handle they want isn't already taken..
-                       if {[validuser $line]} {
-                               putidx $idx {Sorry, that handle is taken 
already.}
-                               putidx $idx {Try another one please: }
-                       } else {
-                               putidx $idx {Okay, now choose and enter a 
password: }
-                               adduser $line *!$chatinfo(remote)
-                               ::tcldrop::idx::ChInfo $idx [list handle $line 
type TELNET_PW other {newp  waited 3s} timestamp [unixtime] traffictype 
partyline]
-                       }
-               }
-               {TELNET_PW} {
-                       if {[string length $line] < 4} {
-                               putidx $idx {Try to use at least 4 characters 
in your password.}
-                               putidx $idx {Choose and enter a password: }
-                               ::tcldrop::idx::ChInfo $idx [list timestamp 
[unixtime] traffictype partyline]
-                       } else {
-                               setuser $chatinfo(handle) pass $line
-                               putidx $idx {Remember that!  You'll need it 
next time you log in.}
-                               putidx $idx "You now have an account"
-                               chattr $chatinfo(handle) +pnmofvtxj
-                               ::tcldrop::idx::ChInfo $idx [list type CHAT 
other {chat  flags: ?/0} timestamp [unixtime] traffictype partyline]
-                               # FixMe: Show the MOTD or whatever here.
-                       }
-               }
-               {CHAT} {
-                       # Do the FILT binds:
-                       # Note, this is different from Eggdrop's FILT, because 
our FILT actually works, but I haven't tested it. =P
-                       foreach a [binds filt] {
-                               foreach {type flags mask count proc} $a {}
-                               if {$line == {}} { break }
-                               if {[string match -nocase $mask $line] && 
[matchattr $chatinfo(handle) $flags]} {
-                                       ::tcldrop::countbind $type $mask $proc
-                                       if {[catch { set line [$proc $idx 
$line] } err]} {
-                                               putlog "Error in script: $proc: 
$err"
-                                               puterrlog "$::errorInfo"
+                       {CHAT} {
+                               # Do the FILT binds:
+                               # Note, this is different from Eggdrop's FILT, 
because our FILT actually works, but I haven't tested it. =P
+                               foreach a [binds filt] {
+                                       foreach {type flags mask count proc} $a 
{}
+                                       if {$line == {}} { break }
+                                       if {[string match -nocase $mask $line] 
&& [matchattr $chatinfo(handle) $flags]} {
+                                               ::tcldrop::countbind $type 
$mask $proc
+                                               if {[catch { set line [$proc 
$idx $line] } err]} {
+                                                       putlog "Error in 
script: $proc: $err"
+                                                       puterrlog "$::errorInfo"
+                                               }
                                        }
                                }
+                               if {$line == {}} { return }
+                               # Wouldn't it be neat, if we supported other 
command characters
+                               # besides the ".", possibly "/" as a command 
character, and use
+                               # it to simulate an ircII client.  =D
+                               if {[string index $line 0] == {.}} {
+                                       # Do the DCC binds:
+                                       DCC $chatinfo(handle) $idx $line
+                               } else {
+                                       # FixMe: CHAT binds get called here:
+                                       #CHAT $chatinfo(handle) $channel $line
+                               }
+                               # Update the info for last idle:
+                               ::tcldrop::idx::ChInfo $idx [list timestamp 
[unixtime] traffictype partyline]
+                               # Update their laston info:
+                               catch { setlaston $chatinfo(handle) [unixtime] 
partyline }
+                               # FixMe: I'm not sure, but I think Eggdrop 
counts dcc commands as part of the partyline traffic.. So we'll do that here, 
unless it's found to be otherwise:
+                               traffic partyline in [string length $line]
                        }
-                       if {$line == {}} { return }
-                       # Wouldn't it be neat, if we supported other command 
characters
-                       # besides the ".", possibly "/" as a command character, 
and use
-                       # it to simulate an ircII client.  =D
-                       if {[string index $line 0] == {.}} {
-                               # Do the DCC binds:
-                               DCC $chatinfo(handle) $idx $line
-                       } else {
-                               # FixMe: CHAT binds get called here:
-                               #CHAT $chatinfo(handle) $channel $line
-                       }
-                       # Update the info for last idle:
-                       ::tcldrop::idx::ChInfo $idx [list timestamp [unixtime] 
traffictype partyline]
-                       # Update their laston info:
-                       catch { setlaston $chatinfo(handle) [unixtime] 
partyline }
-                       # FixMe: I'm not sure, but I think Eggdrop counts dcc 
commands as part of the partyline traffic.. So we'll do that here, unless it's 
found to be otherwise:
-                       traffic partyline in [string length $line]
-               }
-               {BOT_NEW} {
-                       if {$line != {}} {
+                       {BOT_NEW} {
                                # This is when the remote bot is asking what 
our handle is.
                                ::tcldrop::idx::ChInfo $idx [list type BOT_PASS 
other {bot_pass} traffictype botnet]
                                putidx $idx ${::botnet-nick}
                        }
-               }
-               {BOT_PASS} {
-                       # This is when the remote bot is asking what our 
password (or password hash) is.
-                       if {[string match -nocase {passreq*} $line]} {
-                               putidx $idx [getuser $chatinfo(handle) PASS]
-                               ::tcldrop::idx::ChInfo $idx [list type 
BOT_HELLO other {bot_hello} traffictype botnet]
-                       } else {
-                               # Abort since it's not a valid responce to our 
handle.
-                               killidx $idx
+                       {BOT_PASS} {
+                               # This is when the remote bot is asking what 
our password (or password hash) is.
+                               if {[string match -nocase {passreq*} $line]} {
+                                       putidx $idx [getuser $chatinfo(handle) 
PASS]
+                                       ::tcldrop::idx::ChInfo $idx [list type 
BOT_HELLO other {bot_hello} traffictype botnet]
+                               } else {
+                                       # Abort since it's not a valid responce 
to our handle.
+                                       killidx $idx
+                               }
                        }
-               }
-               {BOT_HELLO} {
-                       # This is after we've send our handle and password to 
the remote bot,
-                       # so now we send our version and whatever else needs to 
be sent to start with.
-                       if {[string match -nocase {version*} $line]} {
-                               # FixMe: Add proper version info here.
-                               putidx $idx "version "
-                               ::tcldrop::idx::ChInfo $idx [list type BOT 
other {bot  flags: } traffictype botnet]
+                       {BOT_HELLO} {
+                               # This is after we've send our handle and 
password to the remote bot,
+                               # so now we send our version and whatever else 
needs to be sent to start with.
+                               if {[string match -nocase {version*} $line]} {
+                                       # FixMe: Add proper version info here.
+                                       putidx $idx "version "
+                                       ::tcldrop::idx::ChInfo $idx [list type 
BOT other {bot  flags: } traffictype botnet]
+                               }
                        }
+                       {BOT} {
+                               # Similar to CHAT above, but this is for bot 
connections.
+                               RAWBOT $chatinfo(handle) $idx [string trim 
[lindex [split $line] 0]] [string trimleft [join [lrange $line 1 end]]]
+                               traffic botnet in [string length $line]
+                       }
+                       {default} { }
                }
-               {BOT} {
-                       # Similar to CHAT above, but this is for bot 
connections.
-                       RAWBOT $chatinfo(handle) $idx [string trim [lindex 
[split $line] 0]] [string trimleft [join [lrange $line 1 end]]]
-                       traffic botnet in [string length $line]
-               }
-               {default} { }
        }
-       putloglev d * "dcc: process time: [expr {[clock clicks] - $starttime}]"
 }
 
 proc ::tcldrop::dcc::BOTWrite {idx} {
Index: tcldrop/modules/idx.tcl
diff -u tcldrop/modules/idx.tcl:1.11 tcldrop/modules/idx.tcl:1.12
--- tcldrop/modules/idx.tcl:1.11        Tue Dec  2 04:27:14 2003
+++ tcldrop/modules/idx.tcl     Sat Dec  6 03:41:20 2003
@@ -1,6 +1,6 @@
 # idx.tcl --
 #
-# $Id: idx.tcl,v 1.11 2003/12/02 09:27:14 fireegl Exp $
+# $Id: idx.tcl,v 1.12 2003/12/06 08:41:20 fireegl Exp $
 #
 # Copyright (C) 2003 FireEgl (Philip Moore) <address@hidden>
 #
@@ -137,7 +137,7 @@
        }
 }
 
-proc ::tcldrop::idx::killidx {idx} {
+proc ::tcldrop::idx::killidx {idx args} {
        foreach {a d} [Info $idx] { array set idxinfo $d
                catch { fileevent $idxinfo(sock) writable {} }
                catch { fileevent $idxinfo(sock) readable {} }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]