Exemplo n.º 1
0
    def analyseEchoes(self, echoes, value, timestamp):
        validEchoes = []
        for (server_id, data_signature) in echoes:
            if Signature.verifySign(Signature.getPublicKey(server_id, -1, self.CERT_PATH), data_signature, value + str(timestamp)):
                validEchoes.append((server_id, data_signature))

        return validEchoes
Exemplo n.º 2
0
    def analyseResponse(self, responses):
        array = []

        for (rValue, rTimestamp, data_sign, server_id, server) in responses:
            if rTimestamp == -1:
                #nao ha dado escrito no servidor
                self.OUT_DATED_SERVERS.append(server)
            else:
                if Signature.verifySign(Signature.getPublicKey(server_id, -1, self.CERT_PATH), data_sign, rValue + str(rTimestamp)):
                    self.addResponseToArrayWithRepeatTimes(array, rValue, rTimestamp, data_sign, server_id, server)
                else:
                    # assinatura invalida
                    self.OUT_DATED_SERVERS.append(server)

        return self.getValidResponse(array)
Exemplo n.º 3
0
    def isEchoValid(self, echoes, value, timestamp, type):
        validEchoes = 0
        for (server_id, data_signature) in echoes:
            try:
                if Signature.verifySign(
                        Signature.getPublicKey(server_id, -1, self.CERT_PATH),
                        data_signature, value + str(timestamp)):
                    validEchoes = validEchoes + 1

            except Exception as msg:
                if self.VERBOSE > 0:
                    print('Error on isEchoValid, ' + 'Error code: ' +
                          str(msg[0]) + ', Error message: ' + str(msg[1]))

        if type == Define.write:
            return validEchoes >= self.QUORUM
        else:  #write_back
            return validEchoes >= self.FAULTS + 1
Exemplo n.º 4
0
Arquivo: client.py Projeto: Cayke/TCC
    def analyseResponse(self, responses):
        value = ''
        timestamp = -1
        repeatTimes = 0
        auxServers = []
        data_signature = ''
        client_id = -1

        for (rValue, rTimestamp, data_sign, r_client_id, server) in responses:
            if rTimestamp == -1 or r_client_id == -1:
                #nao ha dado escrito no servidor
                self.OUT_DATED_SERVERS.append(server)

            else:
                if Signature.verifySign(
                        Signature.getPublicKey(-1, r_client_id,
                                               self.CERT_PATH), data_sign,
                        rValue + str(rTimestamp)):
                    if (rTimestamp == timestamp):
                        repeatTimes = repeatTimes + 1
                        auxServers.append(server)

                    elif (rTimestamp > timestamp):
                        timestamp = rTimestamp
                        repeatTimes = 1
                        value = rValue
                        data_signature = data_sign
                        client_id = r_client_id
                        self.transferObjects(auxServers,
                                             self.OUT_DATED_SERVERS)
                        auxServers.append(server)

                    else:
                        self.OUT_DATED_SERVERS.append(server)

                else:
                    # assinatura invalida
                    self.OUT_DATED_SERVERS.append(server)

        return (value, timestamp, data_signature, client_id)