version 1.2 | | version 1.3 |
---|
| | |
#!@PERL@ | | #!/usr/bin/perl |
# $Id: metaserver.pl.in,v 1.2 2005/04/14 06:49:35 mwedel Exp $ | | # $Id: metaserver.pl.in,v 1.3 2005/07/08 23:48:59 mwedel Exp $ |
| | |
# Copyright 2000 by Mark Wedel. | | # Copyright 2000 by Mark Wedel. |
# This script follows the same license as crossfire (GPL). | | # This script follows the same license as crossfire (GPL). |
| | |
# UPDATE_SYNC determines how often we update the HTML_FILE and CACHE_FILE. | | # UPDATE_SYNC determines how often we update the HTML_FILE and CACHE_FILE. |
$UPDATE_SYNC=300; | | $UPDATE_SYNC=300; |
| | |
| | # IP_INTERVAL is how often (in seconds) same IP can request metaserver |
| | # info. This is to prevent DOS attacks. |
| | |
| | $IP_INTERVAL=5; |
| | |
# For gathering some anonymous statistics. You probably want to use | | # For gathering some anonymous statistics. You probably want to use |
# MRTG/RRDTOOL for generating statistics from the file. | | # MRTG/RRDTOOL for generating statistics from the file. |
# -- Heikki Hokkanen, 2005-03-26 | | # -- Heikki Hokkanen, 2005-03-26 |
| | |
# ourselves up to someone intentionally designing something | | # ourselves up to someone intentionally designing something |
# that causes these to block, and then have us fork a huge | | # that causes these to block, and then have us fork a huge |
# number of process potentially filling up our proc table. | | # number of process potentially filling up our proc table. |
if (accept NEWSOCKET, SOCKET1) { | | if ($ipaddr=accept NEWSOCKET, SOCKET1) { |
| | ($port, $ip ) = sockaddr_in( $ipaddr ); |
| | $dq = join('.',unpack('C4', $ip)); |
| | if ($ip_times{$dq} > time) { |
| | close(NEWSOCKET); |
| | } else { |
| | $ip_times{$dq} = time + $IP_INTERVAL; |
foreach $i (keys %data) { | | foreach $i (keys %data) { |
# Report idle time to client, and not last update | | # Report idle time to client, and not last update |
# as we received in seconds since epoch. | | # as we received in seconds since epoch. |
| | |
} | | } |
} | | } |
} | | } |
| | } |
| | |
# Need to generate some files. This is also where we remove outdated | | # Need to generate some files. This is also where we remove outdated |
# hosts. | | # hosts. |