예제 #1
0
    def _hashgrey_ok(self, address):
        if '#' in address:
            address, solution = address.split('##', 1)
        else:
            solution = None

        want_bits = self.HASHCASH_WANT_BITS
        addrpair = '%s, %s' % (self.__mailfrom, address)
        if solution and addrpair in self.want_hashcash:
            if sha512_512kCheck(self.want_hashcash[addrpair], want_bits,
                                solution):
                return address
            else:
                self.push('550 Hashcash is null and void')
                self.close_when_done()
                return None
        else:
            ch = self.want_hashcash[addrpair] = self._challenge()
            self.push(
                str(SMTORP_HASHCASH_RCODE) + ' ' + SMTORP_HASHCASH_FORMAT % {
                    'bits': want_bits,
                    'challenge': ch,
                    'url': self.HASHCASH_URL
                })
            return None
예제 #2
0
    def _hashgrey_ok(self, address):
        if '#' in address:
            address, solution = address.split('##', 1)
        else:
            solution = None

        want_bits = self.HASHCASH_WANT_BITS
        addrpair = '{0!s}, {1!s}'.format(self.__mailfrom, address)
        if solution and addrpair in self.want_hashcash:
            if sha512_512kCheck(self.want_hashcash[addrpair],
                               want_bits, solution):
                return address
            else:
                self.push('550 Hashcash is null and void')
                self.close_when_done()
                return None
        else:
            ch = self.want_hashcash[addrpair] = self._challenge()
            self.push(str(SMTORP_HASHCASH_RCODE) + ' ' +
                      SMTORP_HASHCASH_FORMAT
                      % {'bits': want_bits,
                         'challenge': ch,
                         'url': self.HASHCASH_URL})
            return None