def generate_session_key(self, min_size):
        session_key = utils.generate_random_number_str(min_size)

        q = "SELECT session FROM sessions WHERE session = ?"
        q2 = q.replace("?", "%s") % (session_key)
        logger.log(SQL_LOGLEVEL, q2)

        c = self.conn.cursor()
        for r in c.execute(q, [session_key]):
            session_key = utils.generate_random_number_str(min_size)

        return session_key
    def generate_session_key(self, min_size):
        session_key = utils.generate_random_number_str(min_size)

        q = "SELECT session FROM sessions WHERE session = ?"
        q2 = q.replace("?", "%s") % (session_key)
        logger.log(-1, q2)

        c = self.conn.cursor()
        for r in c.execute(q, [session_key]):
            session_key = utils.generate_random_number_str(min_size)

        return session_key
 def generate_session_key(self, min_size):
     # TODO: There's probably a better way to do this.
     # The point is preventing duplicate session keys.
     while True:
         with Transaction(self.conn) as tx:
             session_key = utils.generate_random_number_str(min_size)
             row = tx.queryone("SELECT COUNT(*) FROM sessions WHERE session = ?", (session_key,))
             count = int(row[0])
             if count == 0:
                 return session_key
 def generate_session_key(self, min_size):
     # TODO: There's probably a better way to do this.
     # The point is preventing duplicate session keys.
     while True:
         with Transaction(self.conn) as tx:
             session_key = utils.generate_random_number_str(min_size)
             row = tx.queryone(
                 "SELECT COUNT(*) FROM sessions WHERE session = ?",
                 (session_key, ))
             count = int(row[0])
             if count == 0:
                 return session_key
Пример #5
0
	def perform_auth(self, data_parsed):
		self.log(logging.DEBUG, "Parsing 'auth'...")

		if "gamename" in data_parsed:
			self.gameid = data_parsed['gamename']

		self.session = utils.generate_random_number_str(10)

		msg = gs_query.create_gamespy_message([('__cmd__', "lc"),
			('__cmd_val__', "2"),
			('sesskey', self.session),
			('proof', 0),
			('id', "1"),])

		self.log(logging.DEBUG, "SENDING: '%s'..." % msg)

		msg = self.crypt(msg)
		self.transport.write(bytes(msg))
    def perform_auth(self, data_parsed):
        self.log(logging.DEBUG, "%s", "Parsing 'auth'...")

        if "gamename" in data_parsed:
            self.gameid = data_parsed['gamename']

        self.session = utils.generate_random_number_str(10)

        msg = gs_query.create_gamespy_message([
            ('__cmd__', "lc"),
            ('__cmd_val__', "2"),
            ('sesskey', self.session),
            ('proof', 0),
            ('id', "1"),
        ])

        self.log(logging.DEBUG, "SENDING: '%s'...", msg)

        msg = self.crypt(msg)
        self.transport.write(bytes(msg))