Exemplo n.º 1
0
    def process_new_users(self, nameop=None, spam_protection=False):
        """
            Process new registrations coming in on the webapp
        """

        counter = 0
        self.registrar_server.reset_flag()

        for new_user in self.registrations.find(no_cursor_timeout=True):

            user = get_db_user_from_id(new_user, self.users)

            if not self.validUser(user, new_user):
                continue

            fqu = user['username'] + "." + DEFAULT_NAMESPACE
            transfer_address = nmc_to_btc_address(user['namecoin_address'])
            profile = user['profile']

            log.debug("Processing: %s" % fqu)

            if registrationComplete(fqu, profile, transfer_address):
                log.debug("Registration complete %s. Removing." % fqu)
                self.registrations.remove({"user_id": new_user['user_id']})

                refresh_resolver(user['username'])
            else:
                try:
                    self.registrar_server.process_nameop(fqu, profile,
                                                         transfer_address,
                                                         nameop=nameop)
                except Exception as e:
                    log.debug(e)
    def update_users(self, spam_protection=False, reprocess_username=None):
        """
            Process new profile updates from the webapp
        """

        counter = 0
        self.registrar_server.reset_flag()

        for new_user in self.updates.find(no_cursor_timeout=True):

            user = get_db_user_from_id(new_user, self.users)

            if user is None:
                continue

            # for spam protection
            if check_banned_email(user['email']):
                if spam_protection:
                    log.debug("Deleting spam: %s, %s" % (user['email'], user['username']))
                    self.updates.remove({"user_id": new_user['user_id']})
                else:
                    log.debug("Need to delete %s, %s" % (user['email'], user['username']))
                continue

            # mode for reprocessing a single user, ignore others
            if reprocess_username is not None:
                if user['username'] != reprocess_username:
                    #log.debug("Ignoring: %s" % user['username'])
                    continue

            fqu = user['username'] + "." + DEFAULT_NAMESPACE
            btc_address = nmc_to_btc_address(user['namecoin_address'])

            data_value = convert_profile_format(user)

            encrypted_privkey = new_user['encrypted_private_key']
            hex_privkey = bip38_decrypt(str(encrypted_privkey), WALLET_SECRET)

            if nameRegistered(fqu):

                if profilePublished(fqu, data_value):
                    log.debug("Profile match, removing: %s" % fqu)
                    self.updates.remove({"user_id": new_user['user_id']})

                    refresh_resolver(user['username'])
                else:
                    log.debug("Processing: %s, %s" % (fqu, user['email']))
                    try:
                        self.registrar_server.process_subsidized_nameop(fqu,
                                                                owner_privkey=hex_privkey,
                                                                profile=data_value,
                                                                nameop='update')
                    except Exception as e:
                        log.debug(e)
            else:

                log.debug("Not registered: %s" % fqu)
Exemplo n.º 3
0
    def release_username(self, username, new_owner):

        user = self.users.find_one({"username": new_owner})

        fqu = username + "." + DEFAULT_NAMESPACE
        transfer_address = nmc_to_btc_address(user['namecoin_address'])
        profile = user['profile']

        self.registrar_server.release_username(fqu, profile, transfer_address)
Exemplo n.º 4
0
    def release_username(self, username, new_owner):

        user = self.users.find_one({"username": new_owner})

        fqu = username + "." + DEFAULT_NAMESPACE
        transfer_address = nmc_to_btc_address(user['namecoin_address'])
        profile = user['profile']

        self.registrar_server.release_username(fqu, profile,
                                               transfer_address)
Exemplo n.º 5
0
    def process_new_users(self, nameop=None, spam_protection=False):
        """
            Process new registrations coming in on the webapp
        """

        counter = 0
        self.registrar_server.reset_flag()

        for new_user in self.registrations.find(no_cursor_timeout=True):

            user = get_db_user_from_id(new_user, self.users)

            if user is None:
                log.debug("No such user, need to remove: %s" % new_user['_id'])
                self.registrations.remove({'_id': new_user['_id']})
                continue

            # for spam protection
            if check_banned_email(user['email']):

                if spam_protection:
                    log.debug("Deleting spam %s, %s" % (user['email'], user['username']))
                    self.users.remove({"email": user['email']})
                else:
                    log.debug("Need to delete %s, %s" % (user['email'], user['username']))
                continue

            # test for minimum name length
            if len(user['username']) < MINIMUM_LENGTH_NAME:
                log.debug("Expensive name %s. Skipping." % user['username'])
                continue

            # test for ignoring names starting with certain patterns
            if ignoreRegistration(user['username'], IGNORE_NAMES_STARTING_WITH):
                log.debug("Ignoring: %s" % user['username'])
                continue

            fqu = user['username'] + "." + DEFAULT_NAMESPACE
            transfer_address = nmc_to_btc_address(user['namecoin_address'])
            profile = user['profile']

            log.debug("Processing: %s" % fqu)

            if registrationComplete(fqu, profile, transfer_address):
                log.debug("Registration complete %s. Removing." % fqu)
                self.registrations.remove({"user_id": new_user['user_id']})

                refresh_resolver(user['username'])
            else:
                try:
                    self.registrar_server.process_nameop(fqu, profile,
                                                         transfer_address,
                                                         nameop=nameop)
                except Exception as e:
                    log.debug(e)
Exemplo n.º 6
0
    def reprocess_user(self, username, nameop=None):

        user = self.users.find_one({"username": username})
        fqu = user['username'] + "." + DEFAULT_NAMESPACE
        transfer_address = nmc_to_btc_address(user['namecoin_address'])
        profile = user['profile']

        log.debug("Reprocessing user: %s" % fqu)
        self.registrar_server.process_nameop(fqu, profile,
                                             transfer_address,
                                             nameop=nameop)
Exemplo n.º 7
0
    def reprocess_user(self, username, nameop=None):

        user = self.users.find_one({"username": username})
        fqu = user['username'] + "." + DEFAULT_NAMESPACE
        transfer_address = nmc_to_btc_address(user['namecoin_address'])
        profile = user['profile']

        log.debug("Reprocessing user: %s" % fqu)
        self.registrar_server.process_nameop(fqu,
                                             profile,
                                             transfer_address,
                                             nameop=nameop)
Exemplo n.º 8
0
    def update_users(self, spam_protection=False):
        """
            Process new profile updates from the webapp
        """

        counter = 0
        self.registrar_server.reset_flag()

        for new_user in self.updates.find(no_cursor_timeout=True):

            user = get_db_user_from_id(new_user, self.users)

            if user is None:
                continue

            # for spam protection
            if check_banned_email(user['email']):
                if spam_protection:
                    log.debug("Deleting spam: %s, %s" %
                              (user['email'], user['username']))
                    self.updates.remove({"user_id": new_user['user_id']})
                else:
                    log.debug("Need to delete %s, %s" %
                              (user['email'], user['username']))
                continue

            fqu = user['username'] + "." + DEFAULT_NAMESPACE
            btc_address = nmc_to_btc_address(user['namecoin_address'])
            profile = user['profile']
            encrypted_privkey = new_user['encrypted_private_key']
            hex_privkey = bip38_decrypt(str(encrypted_privkey), WALLET_SECRET)

            if nameRegistered(fqu):

                if profilePublished(fqu, profile):
                    log.debug("Profile match, removing: %s" % fqu)
                    self.updates.remove({"user_id": new_user['user_id']})

                    refresh_resolver(user['username'])
                else:
                    log.debug("Processing: %s, %s" % (fqu, user['email']))
                    try:
                        self.registrar_server.subsidized_nameop(
                            fqu,
                            profile,
                            hex_privkey=hex_privkey,
                            nameop='update')
                    except Exception as e:
                        log.debug(e)
            else:

                log.debug("Not registered: %s" % fqu)
Exemplo n.º 9
0
    def process_new_users(self,
                          nameop=None,
                          spam_protection=False,
                          live_delete=False):
        """
            Process new registrations coming in on the webapp
        """

        counter = 0
        self.registrar_server.reset_flag()

        self.populate_email_list()

        for new_user in self.registrations.find(no_cursor_timeout=True):

            user = get_db_user_from_id(new_user, self.users)

            if not self.validUser(user, new_user):

                live_delete = False
                if live_delete:
                    log.debug("Removing %s" % user['username'])
                    self.registrations.remove({"user_id": new_user['user_id']})
                continue

            if whiteListedUser(user['email'], user['profile']):
                log.debug("White-listed: %s" % user['email'])
            else:
                log.debug("Not registering: %s" % user['email'])
                #continue

            fqu = user['username'] + "." + DEFAULT_NAMESPACE
            transfer_address = nmc_to_btc_address(user['namecoin_address'])

            data_value = convert_profile_format(user)

            log.debug("Processing: %s" % fqu)

            if registrationComplete(fqu, data_value, transfer_address):
                log.debug("Registration complete %s. Removing." % fqu)
                self.registrations.remove({"user_id": new_user['user_id']})
                refresh_resolver(user['username'])
            else:
                try:
                    self.registrar_server.process_nameop(fqu,
                                                         data_value,
                                                         transfer_address,
                                                         nameop=nameop)
                except:
                    log.debug(traceback.print_exc())
    def process_new_users(self, nameop=None, spam_protection=False,
                          live_delete=False):
        """
            Process new registrations coming in on the webapp
        """

        counter = 0
        self.registrar_server.reset_flag()

        self.populate_email_list()

        for new_user in self.registrations.find(no_cursor_timeout=True):

            user = get_db_user_from_id(new_user, self.users)

            if not self.validUser(user, new_user):

                live_delete = False
                if live_delete:
                    log.debug("Removing %s" % user['username'])
                    self.registrations.remove({"user_id": new_user['user_id']})
                continue

            if whiteListedUser(user['email'], user['profile']):
                log.debug("White-listed: %s" % user['email'])
            else:
                log.debug("Not registering: %s" % user['email'])
                #continue

            fqu = user['username'] + "." + DEFAULT_NAMESPACE
            transfer_address = nmc_to_btc_address(user['namecoin_address'])

            data_value = convert_profile_format(user)

            log.debug("Processing: %s" % fqu)

            if registrationComplete(fqu, data_value, transfer_address):
                log.debug("Registration complete %s. Removing." % fqu)
                self.registrations.remove({"user_id": new_user['user_id']})
                refresh_resolver(user['username'])
            else:
                try:
                    self.registrar_server.process_nameop(fqu, data_value,
                                                         transfer_address,
                                                         nameop=nameop)
                except:
                    log.debug(traceback.print_exc())
Exemplo n.º 11
0
    def display_current_states(self):
        """
            Display current states of all pending registrations
        """

        counter_register = 0
        counter_update = 0
        counter_dht = 0
        counter_transfer = 0

        for new_user in self.registrations.find(no_cursor_timeout=True):

            user = get_db_user_from_id(new_user, self.users)

            if not self.validUser(user, new_user):
                continue

            fqu = user['username'] + "." + DEFAULT_NAMESPACE
            transfer_address = nmc_to_btc_address(user['namecoin_address'])
            profile = user['profile']

            if not nameRegistered(fqu):
                counter_register += 1

            elif not profileonBlockchain(fqu, profile):
                counter_update += 1

            elif not profileonDHT(fqu, profile):
                counter_dht += 1

            elif not ownerName(fqu, transfer_address):
                counter_transfer += 1

        log.debug("Pending registrations: %s" % counter_register)
        log.debug("Pending updates: %s" % counter_update)
        log.debug("Pending DHT writes: %s" % counter_dht)
        log.debug("Pending transfers: %s" % counter_transfer)
Exemplo n.º 12
0
    def display_current_states(self):
        """
            Display current states of all pending registrations
        """

        counter_register = 0
        counter_update = 0
        counter_dht = 0
        counter_transfer = 0

        for new_user in self.registrations.find(no_cursor_timeout=True):

            user = get_db_user_from_id(new_user, self.users)

            if not self.validUser(user, new_user):
                continue

            fqu = user['username'] + "." + DEFAULT_NAMESPACE
            transfer_address = nmc_to_btc_address(user['namecoin_address'])
            profile = user['profile']

            if not nameRegistered(fqu):
                counter_register += 1

            elif not profileonBlockchain(fqu, profile):
                counter_update += 1

            elif not profileonDHT(fqu, profile):
                counter_dht += 1

            elif not ownerName(fqu, transfer_address):
                counter_transfer += 1

        log.debug("Pending registrations: %s" % counter_register)
        log.debug("Pending updates: %s" % counter_update)
        log.debug("Pending DHT writes: %s" % counter_dht)
        log.debug("Pending transfers: %s" % counter_transfer)
    def reprocess_user(self, username, nameop=None):

        user = self.users.find_one({"username": username})

        if not self.validUser(user, None):
            log.debug("Need to remove: %s" % username)
            return

        if whiteListedUser(user['email'], user['profile']):
            log.debug("White-listed: %s" % user['email'])
        else:
            log.debug("Not registering: %s" % user['email'])
            #return

        fqu = user['username'] + "." + DEFAULT_NAMESPACE
        transfer_address = nmc_to_btc_address(user['namecoin_address'])

        data_value = convert_profile_format(user)

        log.debug("Reprocessing user: %s" % fqu)

        self.registrar_server.process_nameop(fqu, data_value,
                                             transfer_address,
                                             nameop=nameop)