Ejemplo n.º 1
0
 def afterGetWSID(res):
     hasFailed(res)
     if not res:
         raise
     self.parent.factory.worldServers[res[0]["id"]] = self.parent
     self.parent.sendHandshake(res[0]["id"])
     self.parent.id = res[0]["id"]
     self.parent.connectionEstablished = True
Ejemplo n.º 2
0
 def afterGetBans(res, lookupEntity):
     hasFailed(res)
     if not res:
         return {}
     elif len(res) > 1:
         # More than one record...
         self.logger.warn("Multiple global ban detected for lookup entity {}.", lookupEntity)
     return res[0]
Ejemplo n.º 3
0
 def gotWorldServer(res):
     hasFailed(res)
     if not res:
         raise NoResultsException
     ws = res[0]["worldServerID"]
     if ws not in self.getFactory("WorldServerCommServerFactory").worldServers:
         raise WorldServerLinkNotEstablishedException
     wsProto = self.getFactory("WorldServerCommServerFactory").worldServers[ws]
     return wsProto.protoDoJoinServer(proto, world).addCallback(noArgs(afterAddedNewClient), wsProto)
Ejemplo n.º 4
0
 def afterGetDefaultWorld(res):
     hasFailed(res)
     if not res:
         raise
     wsf = self.factory.getFactory("WorldServerCommServerFactory")
     # Get world server link
     if res[0]["worldServerID"] not in wsf.worldServers:
         # WorldServer down, raise hell
         self.logger.debug(str(res[0]))
         raise WorldServerLinkException(200, "World server link not established")
     # Send the player over
     wsf.worldServers[res[0]["worldServerID"]].protoDoJoinServer(self, res[0]["id"]) # TODO World name or ID?
Ejemplo n.º 5
0
 def checkTablesCallabck(self, res):
     hasFailed(res)
     if isinstance(res, Failure):
         self.stop()
     elif not res:
         self.logger.critical("Database validation check failed: databaseVersion row not found in cb_global_metadata.")
         self.logger.critical("Maybe the database is corrupt?")
         self.stop()
     elif int(res[0]["value"]) != VERSION_NUMBER:
         self.logger.critical("Database validation check failed: Database version and software version mismatch.")
         self.logger.critical("Software version: {softwareVersion}, Database version: {dbVersion}".format(softwareVersion=VERSION_NUMBER, dbVersion=res[0]["value"]))
         self.stop()
     else:
         self.logger.info("Database API ready.")
         pub.sendMessage("cloudbox.common.service.databaseAPIReady")
Ejemplo n.º 6
0
        def populateData(res):
            failed = hasFailed(res)

            def actuallyPopulateData(theRes):
                if hasFailed(theRes):
                    self.parent.sendError("The server is currently not available. Please try again later.")
                    raise DatabaseServerLinkException(ERRORS["data_corrupt"])
                for key, value in u:
                    self.parent.player["key"] = value

            if not res:
                # User not found, populate with default variables
                u = User.create(
                    id=uuid.uuid5(UUID["cloudbox.users"], self.parent.player["username"]),
                    username=self.parent.player["username"],
                    firstseen=time.time(),
                    lastseen=time.time(),
                )

                def step2(theRes):
                    if hasFailed(theRes):
                        self.parent.sendError("The server is currently not available. Please try again later.")
                        raise DatabaseServerLinkException(ERRORS["data_corrupt"])
                    self.parent.db.runQuery(*UserServiceAssoc.create(
                        id=theRes,
                        service=1,  # Right now force ClassiCube
                        verified=1,  # Of course we're verified
                    ).sql()).addCallback(actuallyPopulateData)

                self.parent.db.runQuery(*u.sql()).addBoth(step2)
            else:
                # User found. Populate
                self.parent.db.runQuery(*User.select().where(User.id == res).sql()).addBoth(actuallyPopulateData)
Ejemplo n.º 7
0
 def step2(theRes):
     if hasFailed(theRes):
         self.parent.sendError("The server is currently not available. Please try again later.")
         raise DatabaseServerLinkException(ERRORS["data_corrupt"])
     self.parent.db.runQuery(*UserServiceAssoc.create(
         id=theRes,
         service=1,  # Right now force ClassiCube
         verified=1,  # Of course we're verified
     ).sql()).addCallback(actuallyPopulateData)
Ejemplo n.º 8
0
 def actuallyPopulateData(theRes):
     if hasFailed(theRes):
         self.parent.sendError("The server is currently not available. Please try again later.")
         raise DatabaseServerLinkException(ERRORS["data_corrupt"])
     for key, value in u:
         self.parent.player["key"] = value
Ejemplo n.º 9
0
 def afterGetIP(res):
     hasFailed(res)
     if not res:  # First time visitor
         return []
     return self.db.runQuery(*Bans.select().where(Bans.type == BAN_TYPES["globalIPBan"] & Bans.recordID == res[0]["id"])).addBoth(afterGetBans, str(ip))
Ejemplo n.º 10
0
 def afterGetUser(res):
     hasFailed(res)
     if not res:  # First time user
         return []
     return self.db.runQuery(*Bans.select().where(Bans.type == BAN_TYPES["globalBan"] & Bans.username == res[0]["username"]).sql()).addBoth(afterGetBans, username)