2 # Wingate.pl: Wingate checker.
4 # Version: v0.3 (20000526).
6 # NOTE: based on wingate.pl by fooz.
12 my $select = IO::Select->new;
15 my $file = "$::infobot_base_dir/$::param{'ircUser'}.wingate";
21 next if (/\*$/); # wingate. or forget about it?
27 next if ( grep /^$_$/, @hosts );
29 &::DEBUG("W: _ => '$_'.");
37 my $sock = IO::Socket::INET->new(
39 PeerPort => 'telnet(23)',
41 ### Timeout => 10, # enough :)
44 if ( !defined $sock ) {
45 &::status("Wingate: connection refused to $host");
54 foreach $luser ( $select->can_read(1) ) {
57 if ( !defined( $len = sysread( $luser, $buf, 512 ) ) ) {
58 &::status("Wingate: connection lost to $luser/$host.");
59 $select->remove($luser);
65 $len = sysread( $luser, $buf, 512 );
69 $wingate++ if ( $buf =~ /^WinGate\>/ );
71 if ( $buf =~ /^Too many connected users - try again later$/ );
74 &::status("Wingate: RUNNING ON $host BY $::who.");
76 if ( &::IsChanConf('wingateBan') > 0 ) {
77 &::ban( "*!*\@$host", '' );
80 my $reason = &::getChanConf('wingateKick');
82 &::kick( $::who, '', $reason );
85 push( @::wingateBad, "$host\*" );
86 &::wingateWriteFile();
89 ### &::DEBUG("no wingate.");
92 ### TODO: close telnet connection correctly!
93 $select->remove($luser);
102 # vim:ts=4:sw=4:expandtab:tw=80