Changeset 234 for trollforge/jmax
- Timestamp:
- 07/06/06 00:35:01 (7 years ago)
- File:
-
- 1 edited
-
trollforge/jmax/asian.pl (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trollforge/jmax/asian.pl
r233 r234 33 33 34 34 # TODO: 35 # 18:47:34 <@Rucas> jmax, keep proxies in a list and remove them if they do not connect, and keep a list for each server and as they are banned for each server remove from list36 # file flooding with adjustments for nick-length37 # fix warnings38 # connect to a network other than the control channel39 # add to help msg40 # dictionary for nick ?41 # make username and nick different35 # X 18:47:34 <@Rucas> jmax, keep proxies in a list and remove them if they do not connect, and keep a list for each server and as they are banned for each server remove from list 36 # file flooding with adjustments for nick-length 37 # X fix warnings 38 # X connect to a network other than the control channel 39 # X add to help msg 40 # dictionary for nick ? 41 # make username and nick different 42 42 43 43 use warnings; … … 54 54 $VERSION = "2.0-beta2"; 55 55 56 print " Please run using the --help argument\n" and exit 666 unless $ARGV[0];56 print "!!! please run using the --help argument\n" and exit 666 unless $ARGV[0]; 57 57 my ($server, $port, $channel); 58 58 if ($ARGV[0] eq '--help') { … … 60 60 "\n". 61 61 "\n". 62 " Invocation:\n".62 " Invocation:\n". 63 63 " perl ".__FILE__." server[:port] \"#channel\"\n". 64 64 "\n". … … 70 70 "\n". 71 71 "\n". 72 " Usage:\n".72 " Usage:\n". 73 73 " all <raw IRC command> [space-delimited arguments] :[arguments with spaces]\n". 74 74 " all connect <server>\n". … … 78 78 " Simply privmsg your command to the control channel, and the respective bots will follow.\n". 79 79 "\n". 80 " Examples:\n".80 " Examples:\n". 81 81 " <~supers> all join #gnaa gnaa\n". 82 82 " All bots will join #gnaa using the key 'gnaa'\n". … … 95 95 exit 0; 96 96 } else { 97 print " Please run using the --help argument\n" and exit 666 unless $ARGV[1];97 print "!!!! please run using the --help argument\n" and exit 666 unless $ARGV[1]; 98 98 if ($ARGV[0] =~ /(.+):(\d+)/) { 99 99 $server = $1; … … 105 105 $channel = $ARGV[1]; 106 106 } 107 my (undef, undef, undef, undef, @servers) = gethostbyname($server); 108 unless (@servers) { 109 print "Cannot resolve server $ARGV[0]: $?\n"; 110 exit 666; 111 } 112 my @servers_ip; 113 foreach my $server (@servers) { 114 my ($a, $b, $c, $d) = unpack('C4', $server); 115 my $server_ip = "$a.$b.$c.$d"; 116 push (@servers_ip, $server_ip); 117 } 107 108 my @servers = resolve($server); 118 109 my %proxies = load_socks(); 119 110 my @proxylist; 120 foreach my $key (keys %proxies) { 121 push(@proxylist, $key);122 } 111 sub clean_proxylist { push(@proxylist, $key) foreach my $key (keys %proxies); } 112 clean_proxylist(); 113 123 114 for ($forkcount = 0; $forkcount < $maxfork; $forkcount++) { # $forkcount must _not_ be local to here 124 115 sleep 1; # so we don't overload ourselves … … 129 120 my $proxy_ip = $proxylist[int rand @proxylist]; 130 121 my $proxy_port = $proxies{$proxy_ip}; 131 spawn_bot($proxy_ip, $proxy_port, $servers _ip[int rand @servers_ip], $port)132 or delete $proxies{$proxy_ip};122 spawn_bot($proxy_ip, $proxy_port, $servers[int rand @servers], $port) 123 or delete $proxies{$proxy_ip} and clean_proxylist; 133 124 sleep 1; 134 125 } … … 169 160 }; 170 161 if ($@) { 171 warn "!!!! unkown error: $@" unless $@ eq "alarm\n"; # propagate unexpected errors172 warn "TIMEOUT / CONNECTION REFUSED, SOCKS == SHIT (probably); DELETING AND LOADING NEW;";162 warn "!!!! unkown error: $@" unless $@ eq "alarm\n"; # propagate unexpected errors 163 print "!!!! TIMEOUT / CONNECTION REFUSED; SOCKS == SHIT; DELETING AND LOADING NEW;"; 173 164 return 0; 174 165 } … … 201 192 print $sock "$cmd\r\n"; 202 193 print STDOUT "<<<< $nick] $cmd\r\n"; 203 } elsif ($line =~ /PRIVMSG $channel :\S*$nick\S* (.*)$/ ) {194 } elsif ($line =~ /PRIVMSG $channel :\S*$nick\S* (.*)$/i) { 204 195 my $cmd = $1; 205 196 if ($cmd =~ /nick (\S*)/i) { 206 197 $nick = $1; 207 } 198 } 208 199 print $sock "$cmd\r\n"; 209 200 print STDOUT "<<<< $nick] $cmd\r\n"; 201 } elsif ($line =~ /PRIVMSG $channel :all connect (.*)$/i) { 202 my $net = $1; 203 if ($net =~ /(.+):(\d+)/) { 204 my $remote_server = $1; 205 my $remote_port = $2; 206 } 207 my @remote_ips = resolve($remote_server); 208 my $altsock = connect_to_socks_proxy($socks_ip, $socks_port, $remote_ips[int rand @remote_ips], $remote_port); 209 print STDOUT "<<<< $nick] connecting to $net\r\n"; 210 } elsif ($line =~ /PRIVMSG $channel :\S*$nick\S* connect (.*)$/i) { 211 my $net = $1; 212 if ($net =~ /(.+):(\d+)/) { 213 my $remote_server = $1; 214 my $remote_port = $2; 215 } 216 my @remote_ips = resolve($remote_server); 217 my $altsock = connect_to_socks_proxy($socks_ip, $socks_port, $remote_ips[int rand @remote_ips], $remote_port); 218 print STDOUT "<<<< $nick] connecting to $net\r\n"; 219 } elsif ($line =~ /PRIVMSG $channel :all:(\S*) (.*)$/i) { 220 my $net = $1; 221 my $cmd = $2; 222 print $altsock "$2\r\n"; 223 print STDOUT "<<<< $nick] $cmd\r\n"; 224 } elsif ($line =~ /PRIVMSG $channel :\S*$nick\S*:(\S*) connect (.*)$/i) { 225 my $net = $1; 226 my $cmd = $2; 227 print $altsock "$2\r\n"; 228 print STDOUT "<<<< $nick] $cmd\r\n"; 210 229 } else { 211 230 print STDOUT "<<<< $line\n"; … … 245 264 return $str; 246 265 } 266 267 sub resolve { 268 my $host = shift; 269 my (undef, undef, undef, undef, @servers) = gethostbyname($server); 270 unless (@servers) { 271 print "!!!! cannot resolve server $ARGV[0]: $?\n"; 272 return 0; 273 } 274 my @servers_ip; 275 foreach my $server (@servers) { 276 my ($a, $b, $c, $d) = unpack('C4', $server); 277 my $server_ip = "$a.$b.$c.$d"; 278 push (@servers_ip, $server_ip); 279 } 280 return @servers_ip; 281 } 282
Note: See TracChangeset
for help on using the changeset viewer.
