Index: mythplugins/mythweb/classes/MythBackend.php =================================================================== --- mythplugins/mythweb/classes/MythBackend.php (revision 26146) +++ mythplugins/mythweb/classes/MythBackend.php (working copy) @@ -15,7 +15,8 @@ // MYTH_PROTO_VERSION is defined in libmyth in mythtv/libs/libmyth/mythcontext.h // and should be the current MythTV protocol version. - static $protocol_version = '61'; + static $protocol_version = '62'; + static $protocol_token = '78B5631E'; // The character string used by the backend to separate records static $backend_separator = '[]:[]'; @@ -88,7 +89,7 @@ && $_SESSION['backend'][$this->host]['proto_version']['last_check_version'] == MythBackend::$protocol_version ) return true; - $response = $this->sendCommand('MYTH_PROTO_VERSION '.MythBackend::$protocol_version); + $response = $this->sendCommand('MYTH_PROTO_VERSION '.MythBackend::$protocol_version.' '.MythBackend::$protocol_token); $_SESSION['backend'][$this->host]['proto_version']['last_check_version'] = @$response[1]; if ($response[0] == 'ACCEPT') { Index: mythtv/libs/libmythdb/mythcorecontext.cpp =================================================================== --- mythtv/libs/libmythdb/mythcorecontext.cpp (revision 26146) +++ mythtv/libs/libmythdb/mythcorecontext.cpp (working copy) @@ -918,8 +918,8 @@ if (!socket) return false; - QStringList strlist(QString("MYTH_PROTO_VERSION %1") - .arg(MYTH_PROTO_VERSION)); + QStringList strlist(QString("MYTH_PROTO_VERSION %1 %2") + .arg(MYTH_PROTO_VERSION).arg(MYTH_PROTO_TOKEN)); socket->writeStringList(strlist); if (!socket->readStringList(strlist, timeout_ms) || strlist.empty()) Index: mythtv/libs/libmythdb/mythversion.h =================================================================== --- mythtv/libs/libmythdb/mythversion.h (revision 26146) +++ mythtv/libs/libmythdb/mythversion.h (working copy) @@ -30,7 +30,8 @@ * mythtv/bindings/python/MythTV/static.py (version number) * mythtv/bindings/python/MythTV/mythproto.py (layout) */ -#define MYTH_PROTO_VERSION "61" +#define MYTH_PROTO_VERSION "62" +#define MYTH_PROTO_TOKEN "78B5631E" MPUBLIC const char *GetMythSourceVersion(); Index: mythtv/programs/mythbackend/mainserver.cpp =================================================================== --- mythtv/programs/mythbackend/mainserver.cpp (revision 26146) +++ mythtv/programs/mythbackend/mainserver.cpp (working copy) @@ -329,7 +329,7 @@ if (tokens.size() < 2) VERBOSE(VB_IMPORTANT, "Bad MYTH_PROTO_VERSION command"); else - HandleVersion(sock,tokens[1]); + HandleVersion(sock, tokens); return; } else if (command == "ANN") @@ -1159,15 +1159,16 @@ /** * \addtogroup myth_network_protocol - * \par MYTH_PROTO_VERSION \e version - * Checks that \e version matches the backend's version. + * \par MYTH_PROTO_VERSION \e version \e token + * Checks that \e version and \e token match the backend's version. * If it matches, the stringlist of "ACCEPT" \e "version" is returned. * If it does not, "REJECT" \e "version" is returned, * and the socket is closed (for this client) */ -void MainServer::HandleVersion(MythSocket *socket, QString version) +void MainServer::HandleVersion(MythSocket *socket, QStringList slist) { QStringList retlist; + QString version = slist[1]; if (version != MYTH_PROTO_VERSION) { VERBOSE(VB_GENERAL, @@ -1179,6 +1180,29 @@ return; } + if (slist.size() < 3) + { + VERBOSE(VB_GENERAL, + "MainServer::HandleVersion - Client did not pass protocol " + "token. Refusing connection." + '!'); + retlist << "REJECT" << MYTH_PROTO_VERSION; + socket->writeStringList(retlist); + HandleDone(socket); + return; + } + + QString token = slist[2]; + if (token != MYTH_PROTO_TOKEN) + { + VERBOSE(VB_GENERAL, + "MainServer::HandleVersion - Client sent incorrect protocol" + " token for protocol version. Refusing connection." + '!'); + retlist << "REJECT" << MYTH_PROTO_VERSION; + socket->writeStringList(retlist); + HandleDone(socket); + return; + } + retlist << "ACCEPT" << MYTH_PROTO_VERSION; socket->writeStringList(retlist); } Index: mythtv/bindings/python/MythTV/connections.py =================================================================== --- mythtv/bindings/python/MythTV/connections.py (revision 26146) +++ mythtv/bindings/python/MythTV/connections.py (working copy) @@ -3,7 +3,7 @@ from __future__ import with_statement -from static import SCHEMA_VERSION, PROTO_VERSION, BACKEND_SEP +from static import SCHEMA_VERSION, PROTO_VERSION, PROTO_TOKEN, BACKEND_SEP from msearch import MSearch from logging import MythLog from exceptions import * @@ -358,8 +358,8 @@ self.hostname = self.backendCommand('QUERY_HOSTNAME') def check_version(self): - res = self.backendCommand('MYTH_PROTO_VERSION %s' \ - % PROTO_VERSION).split(BACKEND_SEP) + res = self.backendCommand('MYTH_PROTO_VERSION %s %s' \ + % (PROTO_VERSION, PROTO_TOKEN)).split(BACKEND_SEP) if res[0] == 'REJECT': self.log(MythLog.IMPORTANT|MythLog.NETWORK, "Backend has version %s, and we speak %s" %\ Index: mythtv/bindings/python/MythTV/static.py =================================================================== --- mythtv/bindings/python/MythTV/static.py (revision 26146) +++ mythtv/bindings/python/MythTV/static.py (working copy) @@ -9,7 +9,8 @@ MVSCHEMA_VERSION = 1037 NVSCHEMA_VERSION = 1007 MUSICSCHEMA_VERSION = 1017 -PROTO_VERSION = '61' +PROTO_VERSION = '62' +PROTO_TOKEN = '78B5631E' BACKEND_SEP = '[]:[]' class MARKUP( object ): Index: mythtv/bindings/perl/MythTV.pm =================================================================== --- mythtv/bindings/perl/MythTV.pm (revision 26146) +++ mythtv/bindings/perl/MythTV.pm (working copy) @@ -106,7 +106,8 @@ # Note: as of July 21, 2010, this is actually a string, to account for proto # versions of the form "58a". This will get used if protocol versions are # changed on a fixes branch ongoing. - our $PROTO_VERSION = "61"; + our $PROTO_VERSION = "62"; + our $PROTO_TOKEN = "78B5631E"; # NUMPROGRAMLINES is defined in mythtv/libs/libmythtv/programinfo.h and is # the number of items in a ProgramInfo QStringList group used by @@ -645,7 +646,7 @@ return $proto_cache{$host}{$port}; } # Query the version - my $response = $self->backend_command('MYTH_PROTO_VERSION '.$PROTO_VERSION, + my $response = $self->backend_command('MYTH_PROTO_VERSION '.$PROTO_VERSION.' '.$PROTO_TOKEN, $host, $port); my ($code, $vers) = split($BACKEND_SEP_rx, $response); # Deal with the response