Difference for utils/metaserver.pl.in from version 1.1 to 1.2


version 1.1 version 1.2
Line 1
 
Line 1
 #!@PERL@  #!@PERL@
 # $Id: metaserver.pl.in,v 1.1 2001/02/15 09:05:35 tanner Exp $  # $Id: metaserver.pl.in,v 1.2 2005/04/14 06:49:35 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).
Line 18
 
Line 18
 $CACHE_FILE="/var/tmp/meta_xfire.cache";  $CACHE_FILE="/var/tmp/meta_xfire.cache";
   
 # We remove a server after $REMOVE_SERVER number of seconds of no updates.  # We remove a server after $REMOVE_SERVER number of seconds of no updates.
 # 86400 is 1 day - maybe a bit long, but at current time I would like to get  # 600 is 10 minutes - if we haven't gotten an update that fast, the server
 # a more accurate of number of servers out there.  Also, I can see an  # is almost certainly gone/not available.  This reduces congestion when
 # established server being down for a while, but I think it is still nice  # someone on a dhcp connection keeps running a server and it fills
 # to have that in the listing.  # up a bunch of the slots.
 $REMOVE_SERVER=86400;  $REMOVE_SERVER=600;
   
 # 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;
   
   # For gathering some anonymous statistics. You probably want to use
   # MRTG/RRDTOOL for generating statistics from the file.
   # -- Heikki Hokkanen, 2005-03-26
   my $STATS_FILE="/var/tmp/meta_xfire.stats";
   my $stats_updatehits = 0; # COUNTER
   my $stats_requesthits = 0; # COUNTER
   my $stats_totalplayers = 0; # GAUGE
   my $stats_totalservers = 0; # GAUGE
   
 socket(SOCKET, PF_INET, SOCK_DGRAM, getprotobyname("udp")) ||   socket(SOCKET, PF_INET, SOCK_DGRAM, getprotobyname("udp")) ||
  die("$0: can not open udp socket: $OS_ERROR\n");   die("$0: can not open udp socket: $OS_ERROR\n");
 bind(SOCKET, sockaddr_in(13326, INADDR_ANY)) ||  bind(SOCKET, sockaddr_in(13326, INADDR_ANY)) ||
Line 71
 
Line 80
      ($name, $rest) = split /\|/, $data;       ($name, $rest) = split /\|/, $data;
      if ($name ne "put.your.hostname.here") {       if ($name ne "put.your.hostname.here") {
  $data{$host} = "$host|$cur_time|$data";   $data{$host} = "$host|$cur_time|$data";
    $stats_updatehits++;
      }       }
  }   }
  if (vec($rout, fileno(SOCKET1),1)) {   if (vec($rout, fileno(SOCKET1),1)) {
Line 89
 
Line 99
      print NEWSOCKET "$ip|$newtime|$rest\n";       print NEWSOCKET "$ip|$newtime|$rest\n";
  }   }
  close(NEWSOCKET);   close(NEWSOCKET);
    $stats_requesthits++;
      }       }
  }   }
     }      }
Line 110
 
Line 121
 </tr>  </tr>
 ';  ';
   
    $stats_totalplayers = 0;
    $stats_totalservers = 0;
  foreach $i (keys %data) {   foreach $i (keys %data) {
    $stats_totalservers++;
      ($ip, $time, @rest) = split /\|/, $data{$i};       ($ip, $time, @rest) = split /\|/, $data{$i};
      if ($time+$REMOVE_SERVER<$cur_time) {        if ($time+$REMOVE_SERVER<$cur_time) {
  delete $data{$i};    delete $data{$i};
Line 120
 
Line 134
  $gmtime = gmtime($time);   $gmtime = gmtime($time);
  print HTML "<tr><td>$i</td><td>$gmtime</td><td>$elapsed</td>";   print HTML "<tr><td>$i</td><td>$gmtime</td><td>$elapsed</td>";
  print HTML "<td>$rest[0]</td><td>$rest[1]</td><td>$rest[2]</td><td>$rest[3]</td></tr>\n";   print HTML "<td>$rest[0]</td><td>$rest[1]</td><td>$rest[2]</td><td>$rest[3]</td></tr>\n";
    $stats_totalplayers += int($rest[2]);
      }       }
  }   }
  $gmtime = gmtime($cur_time);   $gmtime = gmtime($cur_time);
Line 134
 
Line 149
 <font size=-2>Last Updated: $gmtime<font size=+2><p>";  <font size=-2>Last Updated: $gmtime<font size=+2><p>";
  close(HTML);   close(HTML);
  close(CACHE);   close(CACHE);
   
    open(STATS,">$STATS_FILE");
    print STATS "$stats_updatehits:$stats_requesthits:$stats_totalservers:$stats_totalplayers\n";
    close(STATS);
   
     }      }
 }  }


Legend:
line(s) removed in v.1.1 
line(s) changed
 line(s) added in v.1.2

File made using version 1.98 of cvs2html by leaf at 2011-07-21 17:03