]> git.sesse.net Git - nms/commitdiff
Various MBD survey changes.
authorroot <root@sysrq>
Wed, 4 Apr 2007 12:48:11 +0000 (14:48 +0200)
committerroot <root@sysrq>
Wed, 4 Apr 2007 12:48:11 +0000 (14:48 +0200)
mbd/access_list.pl
mbd/mbd.pl
mbd/survey.pl

index 137f173e05445b40f5b5842c4813a0c68d3d7cd7..c3d129d4066c6ceadee81232da1d87b3ad7472ab 100644 (file)
@@ -4,6 +4,7 @@ package Config;
 our @access_list = (
        # half-life - untested (packet dump only)
        {
+               name => 'Half-Life',
                ports => [ 27015 ],
                sizes => [ 16 ]
        },
@@ -11,18 +12,21 @@ our @access_list = (
        # cs 1.6 - verified
        # (funker muligens for _alle_ source-spill inkl. hl2/cs:s)
        {
+               name => 'CS 1.6, other Source games',
                ports => [ 4242, "26900..26905", "27015..27020" ],
                sizes => [ 25 ]
        },
 
        # doom 3 - verified
        {
+               name => 'Doom 3',
                ports => [ "27666..27673" ],
                sizes => [ 14 ]
        },
 
        # quake 1 - verified
        {
+               name => 'Quake 1',
                ports => [ 26000 ],
                sizes => [ 12 ]
        },
@@ -30,6 +34,7 @@ our @access_list = (
        # q3a - tested with demo only
        # rtcw: enemy territory - untested (packet dump only)
        {
+               name => 'Quake 3 Arena, RTCW: ET',
                ports => [ "27960..27969" ],
                sizes => [ 15 ]
        },
@@ -37,30 +42,35 @@ our @access_list = (
        # bf2 - tested with demo only
        # bf2142 reportedly uses same engine
        {
+               name => 'BF2/BF2142',
                ports => [ "29900..29950" ],
                sizes => [ 8 ]
        },
 
        # bf1942 - unverified (packet dump only)
        {
+               name => 'BF1942',
                ports => [ "22000..22010" ],
                sizes => [ 8 ]
        },
        
        # quake 4 - tested with demo only, MUST select "internet"
        {
+               name => 'Quake 4',
                ports => [ 27950, 28004 ],
                sizes => [ 14 ]
        },
 
        # quake 2 - untested (packet dump only)
        {
+               name => 'Quake 2',
                ports => [ 27910 ],
                sizes => [ 11 ]
        },
 
        # warcraft 3 - untested (packet dump only)
        {
+               name => 'Warcraft 3',
                ports => [ "6112..6119" ],
                sizes => [ 16, 48 ],
                filter => sub { return (ord(substr(shift, 1, 1)) == 0x2f); }
@@ -68,40 +78,45 @@ our @access_list = (
 
        # ut2003/ut2004 - untested (packet dump only)
        {
+               name => 'UT2003/UT2004',
                ports => [ 10777 ],
                sizes => [ 5 ]
        },
 
        # soldat - untested (packet dump only)
        {
+               name => 'Soldat',
                ports => [ 23073 ],
                sizes => [ 8 ]
        },
 
        # starcraft - untested (packet dump only)
        {
+               name => 'Starcraft',
                ports => [ 6111, 6112 ],
                sizes => [ 8, 20 ]
        },
 
        # trackmania nations - untested (packet dump only)
        {
+               name => 'Trackmania Nations',
                ports => [ "2350..2370" ],
                sizes => [ 42 ]
        },
 
        # company of heroes - untested (packet dump only)
        {
+               name => 'Company of Heroes',
                ports => [ 9100 ],
                sizes => [ 39 ]
        },
 
        # command & conquer 3 - untested (packet dump only, reported to have some kind
        # of chat functionality)
-       {
-               ports => [ "8086..8093" ],
-               sizes => [ 476 ]
-       },
+#      {
+#              ports => [ "8086..8093" ],
+#              sizes => [ 476 ]
+#      },
 
        # unreal tournament, port 9777?
 )
index 4843b0bb60cfea9a62388340e854749a8a3b3d4a..6a7b767ca184053cec8f58ae0cecebc1855957ce 100644 (file)
@@ -77,8 +77,8 @@ while (1) {
        for my $sport (keys %active_surveys) {
                my $age = Time::HiRes::tv_interval($active_surveys{$sport}{start}, $now);
                if ($age > $Config::survey_time && $active_surveys{$sport}{active}) {
-                       print "Survey for port " . $active_surveys{$sport}{dport} . ": " .
-                               $active_surveys{$sport}{num} . " active servers.\n";
+                       print "Survey for '" . $Config::access_list[$active_surveys{$sport}{entry}]->{name} . "'/" .
+                               $active_surveys{$sport}{dport} . ": " .  $active_surveys{$sport}{num} . " active servers.\n";
                        $active_surveys{$sport}{active} = 0;
                }
                if ($age > $Config::survey_time * 3.0) {
@@ -124,7 +124,10 @@ while (1) {
                # We don't get the packet's destination address, but I guess this should do...
                # Check against the ACL.
                my $pass = 0;
+               my $entry = -1;
                for my $rule (@Config::access_list) {
+                       ++$entry;
+
                        next unless (mbd::match_ranges($dport, $rule->{'ports'}));
                        next unless (mbd::match_ranges($size, $rule->{'sizes'}));
 
@@ -148,8 +151,8 @@ while (1) {
                # The packet is OK! Do we already have a recent enough survey
                # for this port, or should we use this packet?
                my $survey = 1;
-               if (exists($last_survey{$dport})) {
-                       my $age = Time::HiRes::tv_interval($last_survey{$dport}, $now);
+               if (exists($last_survey{$entry . "/" . $dport})) {
+                       my $age = Time::HiRes::tv_interval($last_survey{$entry . "/" . $dport}, $now);
                        if ($age < $Config::survey_freq) {
                                $survey = 0;
                        }
@@ -157,25 +160,28 @@ while (1) {
 
                # New survey; find an unused port
                my $survey_sport;
-               for my $port ($Config::survey_port_low..$Config::survey_port_high) {
-                       if (!exists($active_surveys{$port})) {
-                               $survey_sport = $port;
-
-                               $active_surveys{$port} = {
-                                       start => $now,
-                                       active => 1,
-                                       dport => $dport,
-                                       num => 0
-                               };
-                               $last_survey{$dport} = $now;
-
-                               last;
+               if ($survey) {
+                       for my $port ($Config::survey_port_low..$Config::survey_port_high) {
+                               if (!exists($active_surveys{$port})) {
+                                       $survey_sport = $port;
+
+                                       $active_surveys{$port} = {
+                                               start => $now,
+                                               active => 1,
+                                               dport => $dport,
+                                               entry => $entry,
+                                               num => 0
+                                       };
+                                       $last_survey{$entry . "/" . $dport} = $now;
+
+                                       last;
+                               }
                        }
-               }
 
-               if (!defined($survey_sport)) {
-                       print "WARNING: no free survey source ports, not surveying.\n";
-                       $survey = 0;
+                       if (!defined($survey_sport)) {
+                               print "WARNING: no free survey source ports, not surveying.\n";
+                               $survey = 0;
+                       }
                }
 
                my $num_nets = 0;
index b73a27989c1da351657d7ec7a7ca46db31e0cb80..01b7b723ae3424f97d81e2f0e73e0604f061a344 100644 (file)
@@ -1,10 +1,10 @@
 package Config;
 
 our $survey_ip = "87.76.254.2";
-our $survey_port_low = 60000;
-our $survey_port_high = 60500;
+our $survey_port_low = 60100;
+our $survey_port_high = 60600;
 our $survey_freq = 60.0;
-our $survey_time = 3.0;
+our $survey_time = 10.0;
 
 1;