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 = "$::blootbot_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 :)
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\>/);
70 $wingate++ if ($buf =~ /^Too many connected users - try again later$/);
73 &::status("Wingate: RUNNING ON $host BY $::who.");
75 if (&::IsChanConf("wingateBan") > 0) {
76 &::ban("*!*\@$host", "");
79 my $reason = &::getChanConf("wingateKick");
81 &::kick($::who, "", $reason);
84 push(@::wingateBad, "$host\*");
85 &::wingateWriteFile();
87 ### &::DEBUG("no wingate.");
90 ### TODO: close telnet connection correctly!
91 $select->remove($luser);