Ticket #8877: mythproto_vercheck.patch

File mythproto_vercheck.patch, 7.0 KB (added by Raymond Wagner, 10 years ago)
  • mythplugins/mythweb/classes/MythBackend.php

     
    1515
    1616// MYTH_PROTO_VERSION is defined in libmyth in mythtv/libs/libmyth/mythcontext.h
    1717// and should be the current MythTV protocol version.
    18     static $protocol_version        = '61';
     18    static $protocol_version        = '62';
     19    static $protocol_token          = '78B5631E';
    1920
    2021// The character string used by the backend to separate records
    2122    static $backend_separator       = '[]:[]';
     
    8889            && $_SESSION['backend'][$this->host]['proto_version']['last_check_version'] == MythBackend::$protocol_version )
    8990            return true;
    9091
    91         $response = $this->sendCommand('MYTH_PROTO_VERSION '.MythBackend::$protocol_version);
     92        $response = $this->sendCommand('MYTH_PROTO_VERSION '.MythBackend::$protocol_version.' '.MythBackend::$protocol_token);
    9293        $_SESSION['backend'][$this->host]['proto_version']['last_check_version'] = @$response[1];
    9394
    9495        if ($response[0] == 'ACCEPT') {
  • mythtv/libs/libmythdb/mythcorecontext.cpp

     
    918918    if (!socket)
    919919        return false;
    920920
    921     QStringList strlist(QString("MYTH_PROTO_VERSION %1")
    922                         .arg(MYTH_PROTO_VERSION));
     921    QStringList strlist(QString("MYTH_PROTO_VERSION %1 %2")
     922                        .arg(MYTH_PROTO_VERSION).arg(MYTH_PROTO_TOKEN));
    923923    socket->writeStringList(strlist);
    924924
    925925    if (!socket->readStringList(strlist, timeout_ms) || strlist.empty())
  • mythtv/libs/libmythdb/mythversion.h

     
    3030 *       mythtv/bindings/python/MythTV/static.py (version number)
    3131 *       mythtv/bindings/python/MythTV/mythproto.py (layout)
    3232 */
    33 #define MYTH_PROTO_VERSION "61"
     33#define MYTH_PROTO_VERSION "62"
     34#define MYTH_PROTO_TOKEN "78B5631E"
    3435
    3536MPUBLIC const char *GetMythSourceVersion();
    3637
  • mythtv/programs/mythbackend/mainserver.cpp

     
    329329        if (tokens.size() < 2)
    330330            VERBOSE(VB_IMPORTANT, "Bad MYTH_PROTO_VERSION command");
    331331        else
    332             HandleVersion(sock,tokens[1]);
     332            HandleVersion(sock, tokens);
    333333        return;
    334334    }
    335335    else if (command == "ANN")
     
    11591159
    11601160/**
    11611161 * \addtogroup myth_network_protocol
    1162  * \par        MYTH_PROTO_VERSION \e version
    1163  * Checks that \e version matches the backend's version.
     1162 * \par        MYTH_PROTO_VERSION \e version \e token
     1163 * Checks that \e version and \e token match the backend's version.
    11641164 * If it matches, the stringlist of "ACCEPT" \e "version" is returned.
    11651165 * If it does not, "REJECT" \e "version" is returned,
    11661166 * and the socket is closed (for this client)
    11671167 */
    1168 void MainServer::HandleVersion(MythSocket *socket, QString version)
     1168void MainServer::HandleVersion(MythSocket *socket, QStringList slist)
    11691169{
    11701170    QStringList retlist;
     1171    QString version = slist[1];
    11711172    if (version != MYTH_PROTO_VERSION)
    11721173    {
    11731174        VERBOSE(VB_GENERAL,
     
    11791180        return;
    11801181    }
    11811182
     1183    if (slist.size() < 3)
     1184    {
     1185        VERBOSE(VB_GENERAL,
     1186                "MainServer::HandleVersion - Client did not pass protocol "
     1187                "token. Refusing connection." + '!');
     1188        retlist << "REJECT" << MYTH_PROTO_VERSION;
     1189        socket->writeStringList(retlist);
     1190        HandleDone(socket);
     1191        return;
     1192    }
     1193
     1194    QString token = slist[2];
     1195    if (token != MYTH_PROTO_TOKEN)
     1196    {
     1197        VERBOSE(VB_GENERAL,
     1198                "MainServer::HandleVersion - Client sent incorrect protocol"
     1199                " token for protocol version. Refusing connection." + '!');
     1200        retlist << "REJECT" << MYTH_PROTO_VERSION;
     1201        socket->writeStringList(retlist);
     1202        HandleDone(socket);
     1203        return;
     1204    }
     1205
    11821206    retlist << "ACCEPT" << MYTH_PROTO_VERSION;
    11831207    socket->writeStringList(retlist);
    11841208}
  • mythtv/bindings/python/MythTV/connections.py

     
    33
    44from __future__ import with_statement
    55
    6 from static import SCHEMA_VERSION, PROTO_VERSION, BACKEND_SEP
     6from static import SCHEMA_VERSION, PROTO_VERSION, PROTO_TOKEN, BACKEND_SEP
    77from msearch import MSearch
    88from logging import MythLog
    99from exceptions import *
     
    358358        self.hostname = self.backendCommand('QUERY_HOSTNAME')
    359359
    360360    def check_version(self):
    361         res = self.backendCommand('MYTH_PROTO_VERSION %s' \
    362                     % PROTO_VERSION).split(BACKEND_SEP)
     361        res = self.backendCommand('MYTH_PROTO_VERSION %s %s' \
     362                    % (PROTO_VERSION, PROTO_TOKEN)).split(BACKEND_SEP)
    363363        if res[0] == 'REJECT':
    364364            self.log(MythLog.IMPORTANT|MythLog.NETWORK,
    365365                            "Backend has version %s, and we speak %s" %\
  • mythtv/bindings/python/MythTV/static.py

     
    99MVSCHEMA_VERSION = 1037
    1010NVSCHEMA_VERSION = 1007
    1111MUSICSCHEMA_VERSION = 1017
    12 PROTO_VERSION = '61'
     12PROTO_VERSION = '62'
     13PROTO_TOKEN = '78B5631E'
    1314BACKEND_SEP = '[]:[]'
    1415
    1516class MARKUP( object ):
  • mythtv/bindings/perl/MythTV.pm

     
    106106# Note: as of July 21, 2010, this is actually a string, to account for proto
    107107# versions of the form "58a".  This will get used if protocol versions are
    108108# changed on a fixes branch ongoing.
    109     our $PROTO_VERSION = "61";
     109    our $PROTO_VERSION = "62";
     110    our $PROTO_TOKEN = "78B5631E";
    110111
    111112# NUMPROGRAMLINES is defined in mythtv/libs/libmythtv/programinfo.h and is
    112113# the number of items in a ProgramInfo QStringList group used by
     
    645646            return $proto_cache{$host}{$port};
    646647        }
    647648    # Query the version
    648         my $response = $self->backend_command('MYTH_PROTO_VERSION '.$PROTO_VERSION,
     649        my $response = $self->backend_command('MYTH_PROTO_VERSION '.$PROTO_VERSION.' '.$PROTO_TOKEN,
    649650                                              $host, $port);
    650651        my ($code, $vers) = split($BACKEND_SEP_rx, $response);
    651652    # Deal with the response