Esempio n. 1
0
 def afterGetID(res):
     if len(res) == 0:
         _ws = WorldServer(
             name=self.settings["main"]["server-name"]
         )
         return self.db.runQuery(*_ws.sql()).addCallback(getIDFromLastRow)
     else:
         return res[0]["id"]
Esempio n. 2
0
    def loadID(self):
        def storeID(id):
            self.id = id

        def getIDFromLastRow(res):
            return res.lastrowid

        def afterGetID(res):
            if len(res) == 0:
                _ws = WorldServer(
                    name=self.settings["main"]["server-name"]
                )
                return self.db.runQuery(*_ws.sql()).addCallback(getIDFromLastRow)
            else:
                return res[0]["id"]

        return self.db.runQuery(
            *WorldServer.select().where(WorldServer.name == self.settings["main"]["server-name"]).sql()
        ).addCallback(afterGetID).addCallback(storeID)
Esempio n. 3
0
    def handleData(self, packetData, requestID=None):
        super(HubHandshakePacketHandler, self).handleData(packetData, 0)
        if packetData[1] == common.SERVER_TYPES["WorldServer"]:
            # See if they are on our allowed list
            if self.parent.transport.getPeer().host not in self.parent.factory.settings["main"]["allowed-ips"]:
                self.parent.sendError("IP not in allowed list. Check config?")

            # Get the worldServerID from the database
            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

            self.parent.db.runQuery(
                *WorldServer.select().where(WorldServer.name == packetData[0]).sql()
            ).addBoth(afterGetWSID)