示例#1
0
	def pull_db_all_user(self):
		import json
		rows = None

		config_path = get_config().MUDB_FILE
		with open(config_path, 'rb+') as f:
			rows = json.loads(f.read().decode('utf8'))
			for row in rows:
				try:
					if 'forbidden_ip' in row:
						row['forbidden_ip'] = common.IPNetwork(row['forbidden_ip'])
				except Exception as e:
					logging.error(e)
				try:
					if 'forbidden_port' in row:
						row['forbidden_port'] = common.PortRange(row['forbidden_port'])
				except Exception as e:
					logging.error(e)
				try:
					if 'disconnect_ip' in row:
						row['disconnect_ip'] = common.IPNetwork(row['disconnect_ip'])
				except Exception as e:
					logging.error(e)

		return rows
示例#2
0
    def pull_db_all_user(self):
        import json
        rows = None

        config_path = config["MUDB_FILE"]
        with open(config_path, 'rb+') as f:
            rows = json.loads(f.read().decode('utf8'))
            for row in rows:
                try:
                    if 'forbidden_ip' in row:
                        row['forbidden_ip'] = common.IPNetwork(
                            row['forbidden_ip'])
                except Exception as e:
                    logging.error(e)
                try:
                    if 'forbidden_port' in row:
                        row['forbidden_port'] = common.PortRange(
                            row['forbidden_port'])
                except Exception as e:
                    logging.error(e)

        if not rows:
            logging.warn('no user in json file')
        return rows