aboutsummaryrefslogtreecommitdiff
path: root/lib/MasterServer/UDP
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MasterServer/UDP')
-rwxr-xr-xlib/MasterServer/UDP/BeaconCatcher.pm2
-rwxr-xr-xlib/MasterServer/UDP/BeaconChecker.pm7
-rwxr-xr-xlib/MasterServer/UDP/BeaconProcessor.pm120
-rwxr-xr-xlib/MasterServer/UDP/DatagramProcessor.pm2
-rwxr-xr-xlib/MasterServer/UDP/UCCAppletQuery.pm7
5 files changed, 9 insertions, 129 deletions
diff --git a/lib/MasterServer/UDP/BeaconCatcher.pm b/lib/MasterServer/UDP/BeaconCatcher.pm
index 685c33b..0d5ce81 100755
--- a/lib/MasterServer/UDP/BeaconCatcher.pm
+++ b/lib/MasterServer/UDP/BeaconCatcher.pm
@@ -38,7 +38,7 @@ sub beacon_catcher {
}
################################################################################
-## Determine the concent of the received information and process it.
+## Determine the content of the received information and process it.
################################################################################
sub on_beacon_receive {
# $self, beacon address, handle, packed client address
diff --git a/lib/MasterServer/UDP/BeaconChecker.pm b/lib/MasterServer/UDP/BeaconChecker.pm
index 98ee1e2..a99be72 100755
--- a/lib/MasterServer/UDP/BeaconChecker.pm
+++ b/lib/MasterServer/UDP/BeaconChecker.pm
@@ -80,10 +80,9 @@ sub beacon_checker {
# At this point, we are out of server entries. When new servers are
# added, they are immediately queried on the next round.
- # From here on, just count down until the cycle is complete.
+ # From here on, just count down until the cycle is complete and handle
+ # new entries while they are added to the list.
- # debug (spams badly)
- $self->log("debug_spam", "Checker timer: t=".(time - $q{start_time}));
}
);
@@ -105,7 +104,7 @@ sub query_udp_server {
my $buf = "";
# debug spamming
- $self->log("debug_spam", "Query server $ip:$port");
+ $self->log("udp", "Query server $ip:$port");
# connect with UDP server
my $udp_client; $udp_client = AnyEvent::Handle::UDP->new(
diff --git a/lib/MasterServer/UDP/BeaconProcessor.pm b/lib/MasterServer/UDP/BeaconProcessor.pm
deleted file mode 100755
index a41905f..0000000
--- a/lib/MasterServer/UDP/BeaconProcessor.pm
+++ /dev/null
@@ -1,120 +0,0 @@
-
-package MasterServer::UDP::BeaconProcessor;
-
-use strict;
-use warnings;
-use Data::Dumper 'Dumper';
-use AnyEvent::Handle::UDP;
-use Exporter 'import';
-
-our @EXPORT = qw| process_udp_beacon process_udp_validate |;
-
-
-## process beacons that have a \heartbeat\ and \gamename\ format
-sub process_udp_beacon {
- # $self, handle, packed address, udp data, peer ip address, $port
- my ($self, $udp, $pa, $buf, $peer_addr, $port) = @_;
-
- # received heartbeat in $buf: \heartbeat\7778\gamename\ut\
- my %r;
- $buf =~ s/\\([^\\]+)\\([^\\]+)/$r{$1}=$2/eg;
-
- # check whether the beacon has a gamename that is supported in our list
- if (defined $r{gamename} && exists $self->{game}->{lc $r{gamename}}) {
- # log the beacon
- $self->log("beacon", "$peer_addr:$r{heartbeat} for $r{gamename}");
-
- # some games (like bcommander) have a default port and don't send a
- # heartbeat port.
- if ($r{heartbeat} == 0) {
- # assuming a default port exists
- if (exists $self->{game}->{lc $r{gamename}}->{port}) {
- $r{heartbeat} = $self->{game}->{lc $r{gamename}}->{port};
- }
- }
-
- #
- # verify valid server address (ip+port)
- if ($self->valid_address($peer_addr,$r{heartbeat})) {
-
- # generate a new secure string
- my $secure = $self->secure_string();
-
- # update beacon in serverlist if it already exists, otherwise update
- # or add to pending with new secure string.
- my $auth = $self->add_beacon($peer_addr, $port, $r{heartbeat}, $r{gamename}, $secure);
-
- # send secure string back
- if ($auth > 0) {
-
- # verify that this is a legitimate client by sending the "secure" query
- $udp->push_send("\\secure\\$secure\\final\\", $pa);
-
- # log this as a new beacon
- $self->log("secure", "challenged new beacon $peer_addr:$port with $secure.");
- }
- }
-
- # invalid ip+port combination, like \heartbeat\0\ or local IP
- else {
- # Log that beacon had incorrect information, such as port 0 or so. Spams log!
- $self->log("invalid","$peer_addr:$r{heartbeat} ($r{heartbeat}) had bad information");
- }
- }
-
- # gamename not valid or not found in supportedgames.pl
- else {
- # log
- $self->log("support", "received unknown beacon \"$r{gamename}\" from $peer_addr:$r{heartbeat}");
- }
-}
-
-
-## process the received validate query and determine whether the server is allowed in our database
-sub process_udp_validate {
- # $self, udp data, ip, port
- my ($self, $buf, $peer_addr, $port, $heartbeat) = @_;
-
- # received heartbeat in $b: \validate\string\queryid\99.9\
- my %r;
- $buf =~ s/\\([^\\]+)\\([^\\]+)/$r{$1}=$2/eg;
-
- # get our existing knowledge about this server from the database
- # if the heartbeat/queryport known? then use that instead as beacon ports --> may vary after server restarts!
- my $pending = (defined $heartbeat) ? $self->get_pending_info($peer_addr, $heartbeat) : $self->get_pending_beacon($peer_addr, $port);
-
- # if indeed in the pending list, check
- if (defined $pending) {
-
- #determine if it uses any enctype
- my $enc = (defined $r{enctype}) ? $r{enctype} : 0;
-
- # database may not contain the correct gamename (ucc applet, incomplete beacon, change of gameserver)
- $pending->[4] = (defined $r{gamename} && exists $self->{game}->{lc $r{gamename}}) ? $r{gamename} : $pending->[4];
-
- # verify challenge gamename secure enctype validate_response
- my $val = $self->validated_beacon($pending->[4], $pending->[5], $enc, $r{validate});
-
- # log challenge results
- $self->log("secure", "$peer_addr:$port validated with $val for $pending->[4]");
-
- # if validated, add to db
- if ($val > 0) {
-
- # successfully added? ip, query port, gamename
- my $sa = $self->add_to_serverlist($pending->[1], $pending->[3], $pending->[4]);
-
- # remove the entry from pending if successfully added
- $self->remove_pending($pending->[0]) if ( $sa >= 0);
-
- # and set as direct beacon
- $self->set_direct_beacon($pending->[1], $pending->[3]);
- }
- else {
- # else failed validation
- $self->log("error","beacon $peer_addr:$port failed validation for $pending->[4] (details: $pending->[5] sent, got $r{validate})");
- }
- }
-}
-
-1;
diff --git a/lib/MasterServer/UDP/DatagramProcessor.pm b/lib/MasterServer/UDP/DatagramProcessor.pm
index c658264..632435c 100755
--- a/lib/MasterServer/UDP/DatagramProcessor.pm
+++ b/lib/MasterServer/UDP/DatagramProcessor.pm
@@ -208,7 +208,7 @@ sub process_ucc_applet_query {
$c++;
# print address
- $self->log("debug_spam", "applet query added $ms->{game}\t$a\t$p");
+ $self->log("add", "applet query added $ms->{game}\t$a\t$p");
# add server
$self->add_pending($a, $p, $ms->{game}, $self->secure_string());
diff --git a/lib/MasterServer/UDP/UCCAppletQuery.pm b/lib/MasterServer/UDP/UCCAppletQuery.pm
index bd7bb73..f92c20c 100755
--- a/lib/MasterServer/UDP/UCCAppletQuery.pm
+++ b/lib/MasterServer/UDP/UCCAppletQuery.pm
@@ -10,7 +10,8 @@ use Exporter 'import';
our @EXPORT = qw| ucc_applet_query_scheduler query_applet |;
################################################################################
-## Query other UCC applets periodically to get a list of online servers.
+## Query Epic Games'-based UCC applets periodically to get an additional
+## list of online UT, Unreal (or other) game servers.
################################################################################
sub ucc_applet_query_scheduler {
my $self = shift;
@@ -44,7 +45,7 @@ sub query_applet {
my ($self, $ms) = @_;
# be nice to notify
- $self->log("applet","[TCP] > start querying $ms->{ip}:$ms->{port} for '$ms->{game}' games");
+ $self->log("query","start querying $ms->{ip}:$ms->{port} for '$ms->{game}' games");
# list to store all IPs in.
my $master_list = "";
@@ -68,7 +69,7 @@ sub query_applet {
# part 1: receive \basic\\secure\$key
if ($m =~ m/\\basic\\\\secure\\/) {
- # skip to part 3: also request the list \list\gamename\ut
+ # skip to part 3: also request the list \list\gamename\ut -- skipped in UCC applets
#$handle->push_write("\\list\\\\gamename\\$ms->{game}");
$handle->push_write("\\list\\");
}