Ejemplo n.º 1
0
    def connectionLost(self, reason):
        print ConsoleColor(
            'Info'
        ) + '[TheaterServer] Lost connection to ' + self.ip + ':' + str(
            self.port) + ConsoleColor('End')

        return
Ejemplo n.º 2
0
    def dataReceived(self, data):
        try:
            Command = PacketDecoder.decode(data).GetCommand()
            self.PacketID += 1
        except:
            Command = 'null'

        if Command == 'CONN':
            CONN.ReceiveComponent(self, data)
        elif Command == 'USER':
            USER.ReceiveComponent(self, data)
        elif Command == 'CGAM':
            CGAM.ReceiveComponent(self, data)
        elif Command == 'UBRA':
            UBRA.ReceiveComponent(self, data)
        elif Command == 'UGAM':
            UGAM.ReceiveComponent(self, data)
        elif Command == 'EGRS':
            EGRS.ReceiveComponent(self, data)
        elif Command == 'PLVT':
            PLVT.ReceiveComponent(self, data)
        else:
            print ConsoleColor(
                'Warning'
            ) + '[TheaterServer] Warning! Got unknown command (' + Command + ']!' + ConsoleColor(
                'End')
Ejemplo n.º 3
0
 def readConnectionLost(self):
     print ConsoleColor(
         'Info'
     ) + '[TheaterServer] Lost connection to ' + self.ip + ':' + str(
         self.port) + ConsoleColor('End')
     self.transport.loseConnection()
     return
Ejemplo n.º 4
0
 def connectionMade(self):
     self.ip, self.port = self.transport.client
     print ConsoleColor(
         'Info'
     ) + '[FESLServer] Got connection from ' + self.ip + ':' + str(
         self.port) + ConsoleColor('End')
     return
Ejemplo n.º 5
0
 def writeConnectionLost(self):
     print ConsoleColor(
         'Warning'
     ) + '[FESLServer] Closed connection to ' + self.ip + ':' + str(
         self.port) + ConsoleColor('End')
     self.transport.loseConnection()
     return
Ejemplo n.º 6
0
def ReceiveComponent(self, data):
    # Remove player from server
    print ConsoleColor(
        'Info'
    ) + '[TheaterServer][PLVT] Client has been kicked from game!' + ConsoleColor(
        'End')

    KICKPacket = PacketEncoder.SetVar('PID', 1)  # TODO: Make it non-static
    KICKPacket += PacketEncoder.SetVar('LID', 1)  # LobbyID
    KICKPacket += PacketEncoder.SetVar('GID', self.GAMEOBJ.GameID, True)
    KICKPacket = PacketEncoder.encode('KICK', KICKPacket, 0x0, 0)
    self.transport.getHandle().sendall(KICKPacket)

    PLVTPacket = PacketEncoder.SetVar('TID', self.PacketID, True)
    PLVTPacket = PacketEncoder.encode('PLVT', PLVTPacket, 0x0, 0)
    self.transport.getHandle().sendall(PLVTPacket)
Ejemplo n.º 7
0
    def dataReceived(self, data):
        # Check if packet are correct, if not set command and txn to null
        try:
            Command = PacketDecoder.decode(data).GetCommand()
            TXN = PacketDecoder.decode(data).GetTXN()
        except:
            Command = 'null'
            TXN = 'null'

        if Command == 'fsys':
            fsys.ReceiveComponent(self, TXN)
        elif Command == 'acct':
            self.PacketID += 1
            acct.ReceiveComponent(self, data, TXN)
        elif Command == 'rank':
            self.PacketID += 1
            rank.ReceiveComponent(self, data, TXN)
        elif Command == 'pnow':
            self.PacketID += 1
            pnow.ReceiveComponent(self, data, TXN)
        else:
            print ConsoleColor(
                'Warning'
            ) + '[FESLClient] Warning! Got unknown command (' + Command + '] and unknown TXN (' + TXN + ')!' + ConsoleColor(
                'End')
Ejemplo n.º 8
0
def ReceiveComponent(self, data):
    print ConsoleColor('Info') + '[TheaterManager][ECNL] Client disconnected from server....' + ConsoleColor('End')
    ECHLPacket = PacketEncoder.SetVar('LID', PacketDecoder.decode(data).GetVar('LID'))
    ECHLPacket += PacketEncoder.SetVar('GID', PacketDecoder.decode(data).GetVar('GID'))
    ECHLPacket += PacketEncoder.SetVar('TID', self.PacketID, True)
    ECHLPacket = PacketEncoder.encode('ECHL', ECHLPacket, 0x0, 0)
    self.transport.getHandle().sendall(ECHLPacket)
Ejemplo n.º 9
0
class HANDLER_UDP(DatagramProtocol):
    def __init__(self):
        self.PacketID = 0

    def datagramReceived(self, data, (host, port)):
        try:
            Command = PacketDecoder.decode(data).GetCommand()
            self.PacketID += 1
        except:
            Command = 'null'

        if Command == 'ECHO':
            ECHO.ReceiveComponent(self, data, (host, port))
        else:
            print ConsoleColor(
                'Warning'
            ) + '[TheaterServer] Warning! Got unknown command (' + Command + ']!' + ConsoleColor(
                'End')
Ejemplo n.º 10
0
def ReceiveComponent(self, txn):
    if txn == 'Hello':
        MemCheckPacket = PacketEncoder.SetVar('TXN', 'MemCheck')
        MemCheckPacket += PacketEncoder.SetVar('memcheck.[]', 0)
        MemCheckPacket += PacketEncoder.SetVar('salt', 5, True)

        MemCheckPacket = PacketEncoder.encode('fsys', MemCheckPacket,
                                              0xC0000000, self.PacketID)

        self.PacketID += 1
        CurrentTime = strftime('%b-%d-%Y %H:%M:%S UTC')
        HelloPacket = PacketEncoder.SetVar('curTime', CurrentTime)
        HelloPacket += PacketEncoder.SetVar('messengerIp', Globals.ServerIP)
        HelloPacket += PacketEncoder.SetVar('messengerPort', 13505)
        HelloPacket += PacketEncoder.SetVar('TXN', 'Hello')
        HelloPacket += PacketEncoder.SetVar('domainPartition.subDomain',
                                            'bfwest-server')
        HelloPacket += PacketEncoder.SetVar('theaterIp', Globals.ServerIP)
        HelloPacket += PacketEncoder.SetVar('theaterPort', TheaterServerPort)
        HelloPacket += PacketEncoder.SetVar('domainPartition.domain',
                                            'eagames')
        HelloPacket += PacketEncoder.SetVar('activityTimeoutSecs', 3600, True)
        HelloPacket = PacketEncoder.encode('fsys', HelloPacket, 0xC0000000,
                                           self.PacketID)

        self.transport.getHandle().sendall(MemCheckPacket)
        self.transport.getHandle().sendall(HelloPacket)

    elif txn == 'MemCheck':
        # Unneeded
        pass

    elif txn == 'Goodbye':
        # Unneeded
        pass

    else:
        print ConsoleColor(
            'Warning'
        ) + '[FESLServer][fsys] Got unknown TXN (' + txn + ')' + ConsoleColor(
            'End')
Ejemplo n.º 11
0
def ReceiveComponent(self, data):
    # Update server info

    if data.find('UBRA@') != -1:
        data = data.split('UBRA@')[0]
        UBRAPacket = PacketEncoder.SetVar('TID', self.PacketID)
        UBRAPacket = PacketEncoder.encode('UBRA', UBRAPacket, 0x0, 0)
        self.transport.getHandle().sendall(UBRAPacket)

    NewData = data.replace('UGAM', '')[8:]
    NewData = NewData.replace('\x00', '').split('\n')

    NewValues = len(NewData) - 1

    loop = 0
    NewKeysNames = []
    NewKeysValues = []
    while loop != NewValues:
        NewKeysNames.append(NewData[loop].split('=')[0])
        NewKeysValues.append(NewData[loop].split('=')[1])
        loop += 1

    loop = 0

    while loop != len(NewKeysNames):
        if NewKeysNames[loop] in self.GAMEOBJ.AttrNames:
            AttrId = self.GAMEOBJ.AttrNames.index(NewKeysNames[loop])
            self.GAMEOBJ.AttrData[AttrId] = NewKeysValues[loop]
        else:
            self.GAMEOBJ.AttrNames.append(NewKeysNames[loop])
            self.GAMEOBJ.AttrData.append(NewKeysValues[loop])
        loop += 1

    print ConsoleColor(
        'Success'
    ) + '[TheaterServer][UGAM] Successfully updated game info!' + ConsoleColor(
        'End')
    def dataReceived(self, data):
        try:
            Command = PacketDecoder.decode(data).GetCommand()
            self.PacketID += 1
        except:
            Command = 'null'

        if Command == 'CONN':
            CONN.ReceiveComponent(self, data)
        elif Command == 'USER':
            USER.ReceiveComponent(self, data)
        elif Command == 'GDAT':
            GDAT.ReceiveComponent(self, data)
        elif Command == 'ECNL':
            ECNL.ReceiveComponent(self, data)
        elif Command == 'EGAM':
            EGAM.ReceiveComponent(self, data)
        else:
            print ConsoleColor(
                'Warning') + '[TheaterClient] Warning! Got unknown command (' + Command + ']!' + ConsoleColor(
                'End')
Ejemplo n.º 13
0
def ReceiveComponent(self, data):
    # Create game

    # Get all game data
    NewData = data.replace('UGAM', '')[12:]
    NewData = NewData.replace('\x00', '').split('\n')
    NewValues = len(NewData) - 1

    loop = 0

    while loop != NewValues:
        self.GAMEOBJ.AttrNames.append(NewData[loop].split('=')[0])
        self.GAMEOBJ.AttrData.append(NewData[loop].split('=')[1])
        loop += 1

    # Get Required data
    self.GAMEOBJ.EXTPort = self.GAMEOBJ.GetData('PORT')
    self.GAMEOBJ.INTPort = self.GAMEOBJ.GetData('INT-PORT')
    self.GAMEOBJ.INTIP = self.GAMEOBJ.GetData('INT-IP')

    GameID = Globals.CurrentGameID
    self.GAMEOBJ.GameID = GameID
    CGAMPacket = PacketEncoder.SetVar('TID', self.PacketID)
    CGAMPacket += PacketEncoder.SetVar('LID', 1)
    CGAMPacket += PacketEncoder.SetVar('UGID', PacketDecoder.decode(data).GetVar('UGID'))
    CGAMPacket += PacketEncoder.SetVar('MAX-PLAYERS', PacketDecoder.decode(data).GetVar('MAX-PLAYERS'))
    CGAMPacket += PacketEncoder.SetVar('EKEY', 'O65zZ2D2A58mNrZw1hmuJw%3d%3d') # TODO: Generate this
    CGAMPacket += PacketEncoder.SetVar('SECRET', 2587913) # TODO: Generate this
    CGAMPacket += PacketEncoder.SetVar('JOIN', PacketDecoder.decode(data).GetVar('JOIN'))
    CGAMPacket += PacketEncoder.SetVar('J', PacketDecoder.decode(data).GetVar('JOIN'))
    CGAMPacket += PacketEncoder.SetVar('GID', GameID, True)
    Globals.CurrentGameID += 1
    CGAMPacket = PacketEncoder.encode('CGAM', CGAMPacket, 0x0, 0)
    self.transport.getHandle().sendall(CGAMPacket)

    print ConsoleColor('Success') + '[TheaterServer][CGAM] Successfully created new game!' + ConsoleColor('End')
Ejemplo n.º 14
0
def ReceiveComponent(self, data, txn):
    if txn == 'Start':
        print ConsoleColor(
            'Info'
        ) + '[FESLClient][Matchmatching] Started matchmatching...' + ConsoleColor(
            'End')

        StartPacket = PacketEncoder.SetVar('TXN', 'Start')
        StartPacket += PacketEncoder.SetVar('id.id', 1)
        StartPacket += PacketEncoder.SetVar('id.partition',
                                            '/eagames/bfwest-dedicated', True)
        StartPacket = PacketEncoder.encode('pnow', StartPacket, 0xC0000000,
                                           self.PacketID)
        self.transport.getHandle().sendall(StartPacket)

        StatusPacket = PacketEncoder.SetVar('TXN', 'Status')
        StatusPacket += PacketEncoder.SetVar('id.id', 1)
        StatusPacket += PacketEncoder.SetVar('id.partition',
                                             '/eagames/bfwest-dedicated')
        StatusPacket += PacketEncoder.SetVar('sessionState', 'COMPLETE')
        StatusPacket += PacketEncoder.SetVar('props.{}.[]', 2)
        StatusPacket += PacketEncoder.SetVar('props.{resultType}', 'JOIN')

        if len(Globals.Servers) != 0:
            # Return latest server #TODO: Do it better
            print ConsoleColor(
                'Success'
            ) + '[FESLClient][Matchmatching] Game found!' + ConsoleColor('End')
            StatusPacket += PacketEncoder.SetVar('props.{games}.0.lid', 1)
            StatusPacket += PacketEncoder.SetVar('props.{games}.0.fit', 1001)
            StatusPacket += PacketEncoder.SetVar('props.{games}.0.gid',
                                                 Globals.CurrentGameID - 1)
            StatusPacket += PacketEncoder.SetVar('props.{games}.[]', 1)
        else:
            print ConsoleColor(
                'Warning'
            ) + '[FESLClient][Matchmatching] No games found!' + ConsoleColor(
                'End')
            StatusPacket += PacketEncoder.SetVar('props.{games}.[]', 0)

        StatusPacket = PacketEncoder.encode('pnow', StatusPacket, 0x80000000,
                                            0)
        self.transport.getHandle().sendall(StatusPacket)
Ejemplo n.º 15
0
def ReceiveComponent(self, txn):
    if txn == 'Hello':
        MemCheckPacket = PacketEncoder.SetVar('TXN', 'MemCheck')
        MemCheckPacket += PacketEncoder.SetVar('memcheck.[]', 0)
        MemCheckPacket += PacketEncoder.SetVar('salt', 5, True)

        MemCheckPacket = PacketEncoder.encode('fsys', MemCheckPacket,
                                              0xC0000000, self.PacketID)

        GetSessionIdPacket = PacketEncoder.SetVar('TXN', 'GetSessionId', True)
        GetSessionIdPacket = PacketEncoder.encode('gsum', GetSessionIdPacket,
                                                  0x0, 0)

        self.PacketID += 1
        CurrentTime = strftime('%b-%d-%Y %H:%M:%S UTC')
        HelloPacket = PacketEncoder.SetVar('curTime', CurrentTime)
        HelloPacket += PacketEncoder.SetVar('messengerIp', Globals.ServerIP)
        HelloPacket += PacketEncoder.SetVar('messengerPort', 13505)
        HelloPacket += PacketEncoder.SetVar('TXN', 'Hello')
        HelloPacket += PacketEncoder.SetVar('domainPartition.subDomain',
                                            'bfwest-dedicated')
        HelloPacket += PacketEncoder.SetVar('theaterIp', Globals.ServerIP)
        HelloPacket += PacketEncoder.SetVar('theaterPort', TheaterClientPort)
        HelloPacket += PacketEncoder.SetVar('domainPartition.domain',
                                            'eagames')
        HelloPacket += PacketEncoder.SetVar('activityTimeoutSecs', 3600, True)
        HelloPacket = PacketEncoder.encode('fsys', HelloPacket, 0xC0000000,
                                           self.PacketID)

        self.transport.getHandle().sendall(MemCheckPacket)
        self.transport.getHandle().sendall(GetSessionIdPacket)
        self.transport.getHandle().sendall(HelloPacket)

    elif txn == 'MemCheck':
        # Unneeded
        pass

    elif txn == 'Goodbye':
        # Unneeded
        pass

    elif txn == 'GetPingSites':
        self.PacketID += 1
        GetPingSitesPacket = PacketEncoder.SetVar('TXN', 'GetPingSites')
        GetPingSitesPacket += PacketEncoder.SetVar('minPingSitesToPing', 2)
        GetPingSitesPacket += PacketEncoder.SetVar('pingSites.[]', 2)
        GetPingSitesPacket += PacketEncoder.SetVar('pingSites.0.addr',
                                                   Globals.ServerIP)
        GetPingSitesPacket += PacketEncoder.SetVar('pingSites.0.name', 'gva')
        GetPingSitesPacket += PacketEncoder.SetVar('pingSites.0.type', 0)
        GetPingSitesPacket += PacketEncoder.SetVar('pingSites.1.addr',
                                                   Globals.ServerIP)
        GetPingSitesPacket += PacketEncoder.SetVar('pingSites.1.name', 'nrt')
        GetPingSitesPacket += PacketEncoder.SetVar('pingSites.1.type', 0)
        GetPingSitesPacket += PacketEncoder.encode('fsys', GetPingSitesPacket,
                                                   0xC0000000, self.PacketID)
    else:
        print ConsoleColor(
            'Warning'
        ) + '[FESLClient][fsys] Got unknown TXN (' + txn + ')' + ConsoleColor(
            'End')
Ejemplo n.º 16
0
    def render_POST(self, request):
        print '[WebServer][Post] ' + request.uri
        session = request.getSession()

        if request.uri == '/api/register':
            request.setHeader('content-type', 'application/json')
            data = request.content.getvalue()

            entries = len(TempData)
            loop = 0

            while loop != entries:
                Session = TempData[loop]
                if Session.keys()[0] == session.uid:
                    data2 = Session[session.uid]
                loop += 1

            if hasattr(session, 'username'):
                return '{ "status": "err", "code": "username", "message": "You have already an account!", "data": "null" }'

            try:
                username = data.split('username='******'&')[0]
                if len(username) == 0:
                    raise Exception
            except:
                return '{ "status": "err", "code": "username", "message": "' + "You must enter username!" + '", "data": "null" }'

            try:
                email = data.split('email=')[1].split('&')[0]
                if len(email) == 0:
                    raise Exception
            except:
                return '{ "status": "err", "code": "username", "message": "' + "You must enter email!" + '", "data": "null" }'

            try:
                password1 = data.split('password='******'&')[0]
                password2 = data.split('password2=')[1].split('&')[0]

                if len(password1) == 0:
                    raise Exception
                if len(password2) == 0:
                    raise Exception
            except:
                request.setHeader('content-type', 'application/json')
                return '{ "status": "err", "code": "password1", "message": "' + "You must enter both passwords!" + '", "data": "null" }'

            if password1 != password2:
                request.setHeader('content-type', 'application/json')
                return '{ "status": "err", "code": "password2", "message": "' + "Passwords you typed doesn't match!" + '", "data": "null" }'

            try:
                birthday = data.split('birthday=')[1]

                if len(birthday) == 0:
                    raise Exception
            except:
                return '{ "status": "err", "code": "birthday", "message": "' + "You didn't specified correct birthday date!" + '", "data": "null" }'

            try:
                RegisterUser(username, email, password1, birthday)
            except:
                return '{ "status": "err", "code": "username", "message": "' + "This username or email are already registered!" + '", "data": "null" }'

            AccountID = GetAccountID(username)

            try:
                pass
            except:
                print ConsoleColor(
                    'Warning'
                ) + "[WebServer][Register] Cannot register new hero!" + ConsoleColor(
                    'End')
            baseMSGFactionStats = data2.split('baseMSGFactionStats=')[1].split(
                '&')[0]
            baseMSGPersonaClassStats = data2.split(
                'baseMSGPersonaClassStats=')[1].split('&')[0]
            baseMSGAppearanceSkinToneStats = data2.split(
                'baseMSGAppearanceSkinToneStats=')[1].split('&')[0]
            haircolor_ui_name = data2.split('haircolor_ui_name=')[1].split(
                '&')[0]
            baseMSGAppearanceHairStyleStats = data2.split(
                'baseMSGAppearanceHairStyleStats=')[1].split('&')[0]
            facial_ui_name = data2.split('facial_ui_name=')[1].split('&')[0]
            nameCharacterText = data2.split('nameCharacterText=')[1]
            RegisterHero(AccountID, baseMSGFactionStats,
                         baseMSGPersonaClassStats,
                         baseMSGAppearanceSkinToneStats, haircolor_ui_name,
                         baseMSGAppearanceHairStyleStats, facial_ui_name,
                         nameCharacterText)
            TempData.remove(Session)
            print ConsoleColor(
                'Success'
            ) + '[WebServer] Successfully registered new user! (' + username + ')' + ConsoleColor(
                'End')
            session.username = username
            return '{ "status": "ok", "data": {"redirect": "/api/GetSession?username='******'&password='******'"}, "message": "' + "Hello" + username + "!" + '" }'

        if request.uri == '/api/login':
            request.setHeader('content-type', 'application/json')
            data = request.content.getvalue()

            if hasattr(session, 'username'):
                return '{ "status": "err", "code": "username", "message": "You are already loggedom!", "data": "null" }'

            try:
                if len(data.split('&')[0].split('username='******'&')[0].split('username='******'content-type', 'application/json')
                return '{ "status": "err", "code": "username", "message": "' + "You must enter username!" + '", "data": "null" }'

            try:
                if len(data.split('&')[1].split('password='******'&')[1].split('password='******'content-type', 'application/json')
                return '{ "status": "err", "code": "password", "message": "' + "You must enter password!" + '", "data": "null" }'

            account = LoginUser(username)

            if account == None:
                return '{ "status": "err", "code": "username", "message": "' + "User not found!" + '", "data": "null" }'

            if account[1] == username and account[3] == password:
                print ConsoleColor(
                    'Success'
                ) + '[WebServer] User ' + username + ' successfully logged in!' + ConsoleColor(
                    'End')
                session.username = username
                return '{ "status": "ok", "data": {"redirect": "/api/GetSession?username='******'&password='******'"}, "message": "' + "Hello" + username + "!" + '" }'

        if request.uri == '/Register':
            file_handler = open('Web/Register.html', 'rb')
            response = file_handler.read()
            TempData.append({session.uid: request.content.getvalue()})
            file_handler.close()
            return response
Ejemplo n.º 17
0
 def timeoutConnection(self):
     print ConsoleColor(
         'Warning'
     ) + '[FESLServer] Closed connection to ' + self.ip + ':' + str(
         self.port) + ' Reason: Connection Timeout' + ConsoleColor('End')
 def timeoutConnection(self):
     print ConsoleColor('Warning') + '[TheaterClient] Closed connection to ' + self.ip + ':' + str(
         self.port) + ' Reason: Connection Timeout' + ConsoleColor('End')
Ejemplo n.º 19
0
def ReceiveComponent(self, data, txn):
    if txn == 'GetStats':
        # Get Account Stats (info)

        OwnerID = PacketDecoder.decode(data).GetVar('owner')
        OwnerType = PacketDecoder.decode(data).GetVar('ownerType')

        GetStatsPacket = PacketEncoder.SetVar('TXN', 'GetStats')
        GetStatsPacket += PacketEncoder.SetVar('ownerId', OwnerID)
        GetStatsPacket += PacketEncoder.SetVar('ownerType', OwnerType)

        RequestedKeysNumber = int(PacketDecoder.decode(data).GetVar('keys.[]'))

        # Get all requested keys names

        loop = 0
        RequestedKeysNames = []

        while loop != RequestedKeysNumber:
            RequestedKeyName = PacketDecoder.decode(data).GetVar('keys.' + str(loop))
            RequestedKeysNames.append(RequestedKeyName)
            loop += 1

        loop = 0

        # Get and return requested keys values

        while loop != RequestedKeysNumber:
            # For now everything is static
            GetStatsPacket += PacketEncoder.SetVar('stats.' + str(loop) + '.key', RequestedKeysNames[loop])
            GetStatsPacket += PacketEncoder.SetVar('stats.' + str(loop) + '.value', GetStat(OwnerID, RequestedKeysNames[loop]))
            GetStatsPacket += PacketEncoder.SetVar('stats.' + str(loop) + '.text', GetText(OwnerID, RequestedKeysNames[loop]))
            loop += 1

        GetStatsPacket += PacketEncoder.SetVar('stats.[]', RequestedKeysNumber)

        GetStatsPacket = PacketEncoder.encode('acct', GetStatsPacket, 0xC0000000, self.PacketID)
        self.transport.getHandle().sendall(GetStatsPacket)

    elif txn == 'GetStatsForOwners':
        # Get Soldier Stats
        # Requested soldiers
        Owners = int(PacketDecoder.decode(data).GetVar('owners.[]'))

        OwnerIDs = []
        OwnerTypes = []

        loop = 0

        while loop != Owners:
            OwnerID = PacketDecoder.decode(data).GetVar('owners.' + str(loop) + '.ownerId')
            OwnerType = PacketDecoder.decode(data).GetVar('owners.' + str(loop) + '.ownerType')

            OwnerIDs.append(OwnerID)
            OwnerTypes.append(OwnerType)

            loop += 1

        GetStatsForOwnersPacket = PacketEncoder.SetVar('TXN', 'GetStats')

        # Get all requested keys names
        RequestedKeysNumber = int(PacketDecoder.decode(data).GetVar('keys.[]'))
        loop = 0
        RequestedKeysNames = []

        while loop != RequestedKeysNumber:
            RequestedKeyName = PacketDecoder.decode(data).GetVar('keys.' + str(loop))
            RequestedKeysNames.append(RequestedKeyName)
            loop += 1

        loop = 0

        while loop != Owners:
            GetStatsForOwnersPacket += PacketEncoder.SetVar('stats.' + str(loop) + '.ownerId', OwnerIDs[loop])
            GetStatsForOwnersPacket += PacketEncoder.SetVar('stats.' + str(loop) + '.ownerType', OwnerTypes[loop])

            key = 0
            while key != RequestedKeysNumber:
                GetStatsForOwnersPacket += PacketEncoder.SetVar('stats.' + str(loop) + '.stats.' + str(key) + '.key', RequestedKeysNames[key])
                GetStatsForOwnersPacket += PacketEncoder.SetVar('stats.' + str(loop) + '.stats.' + str(key) + '.value', GetStat(OwnerIDs[loop], RequestedKeysNames[key]))
                GetStatsForOwnersPacket += PacketEncoder.SetVar('stats.' + str(loop) + '.stats.' + str(key) + '.text', GetText(OwnerIDs[loop], RequestedKeysNames[key]))
                key += 1

            GetStatsForOwnersPacket += PacketEncoder.SetVar('stats.' + str(loop) + '.stats.[]', RequestedKeysNumber)

            loop += 1

        GetStatsForOwnersPacket += PacketEncoder.SetVar('stats.[]', Owners)

        GetStatsForOwnersPacket = PacketEncoder.encode('acct', GetStatsForOwnersPacket, 0xC0000000, self.PacketID)
        self.transport.getHandle().sendall(GetStatsForOwnersPacket)

    elif txn == 'UpdateStats':
        UpdateUsers = int(PacketDecoder.decode(data).GetVar('u.[]'))
        loop = 0

        while loop != UpdateUsers:
            UpdateKeys = int(PacketDecoder.decode(data).GetVar('u.' + str(loop) + '.s.[]'))

            loop_in_loop = 0
            while loop_in_loop != UpdateKeys:
                HeroID = PacketDecoder.decode(data).GetVar('u.' + str(loop) + '.o')
                KeyName = PacketDecoder.decode(data).GetVar('u.' + str(loop) + '.s.' + str(loop_in_loop) + '.k')
                KeyValue = PacketDecoder.decode(data).GetVar('u.' + str(loop) + '.s.' + str(loop_in_loop) + '.v')
                KeyText = PacketDecoder.decode(data).GetVar('u.' + str(loop) + '.s.' + str(loop_in_loop) + '.t')

                UpdateStat(HeroID, KeyName, KeyValue, KeyText)
                loop_in_loop += 1

            loop += 1
        UpdateStatsPacket = PacketEncoder.encode('rank', PacketEncoder.SetVar('TXN', 'UpdateStats'), 0xC0000000, self.PacketID)
        self.transport.getHandle().sendall(UpdateStatsPacket)
    else:
        print ConsoleColor('Warning') + '[FESLClient][rank] Got unknown TXN (' + txn + ')' + ConsoleColor('End')
Ejemplo n.º 20
0
def ReceiveComponent(self, data):
    RequestedGID = PacketDecoder.decode(data).GetVar('GID')

    loop = 0
    ServersOnline = len(Globals.Servers)

    while loop != ServersOnline:

        if Globals.Servers[loop].GameID == int(RequestedGID):
            completed = True
            break
        else:
            completed = False
            loop += 1
            continue

    if completed == True:
        self.ServerGAMEOBJ = Globals.Servers[loop]


        GDATPacket = PacketEncoder.SetVar('TID', self.PacketID)

        # Basic stuff
        GDATPacket += PacketEncoder.SetVar('IP', self.ServerGAMEOBJ.EXTIP)
        GDATPacket += PacketEncoder.SetVar('PORT', self.ServerGAMEOBJ.GetData('PORT'))
        GDATPacket += PacketEncoder.SetVar('INT-IP', self.ServerGAMEOBJ.GetData('INT-IP'))
        GDATPacket += PacketEncoder.SetVar('INT-PORT', self.ServerGAMEOBJ.GetData('INT-PORT'))
        GDATPacket += PacketEncoder.SetVar('LID', self.ServerGAMEOBJ.GetData('LID')) # LobbyID
        GDATPacket += PacketEncoder.SetVar('GID', self.ServerGAMEOBJ.GetData('GID')) # GameID
        GDATPacket += PacketEncoder.SetVar('UGID', self.ServerGAMEOBJ.GetData('UGID'))
        GDATPacket += PacketEncoder.SetVar('MAX-PLAYERS', self.ServerGAMEOBJ.GetData('MAX-PLAYERS'))
        GDATPacket += PacketEncoder.SetVar('AP', 0) # Active Players. #TODO: Count it
        GDATPacket += PacketEncoder.SetVar('NAME', self.ServerGAMEOBJ.GetData('NAME').replace('"', '')) # Server Name
        GDATPacket += PacketEncoder.SetVar('SECRET', self.ServerGAMEOBJ.GetData('SECRET'))
        GDATPacket += PacketEncoder.SetVar('QLEN', self.ServerGAMEOBJ.GetData('QLEN')) # Queue Length
        GDATPacket += PacketEncoder.SetVar('QUEUE-LENGTH', 0) # TODO: Check diffirence between that and QLEN
        GDATPacket += PacketEncoder.SetVar('DISABLE-AUTO-DEQUEUE', self.ServerGAMEOBJ.GetData('DISABLE-AUTO-DEQUEUE'))

        # Server info
        GDATPacket += PacketEncoder.SetVar('B-maxObservers', self.ServerGAMEOBJ.GetData('B-maxObservers'))
        GDATPacket += PacketEncoder.SetVar('B-numObservers', self.ServerGAMEOBJ.GetData('B-numObservers'))
        GDATPacket += PacketEncoder.SetVar('B-version', self.ServerGAMEOBJ.GetData('B-version'))

        GDATPacket += PacketEncoder.SetVar('B-U-alwaysQueue', self.ServerGAMEOBJ.GetData('B-U-alwaysQueue'))
        GDATPacket += PacketEncoder.SetVar('B-U-army_balance', self.ServerGAMEOBJ.GetData('B-U-army_balance'))
        GDATPacket += PacketEncoder.SetVar('B-U-army_distribution', self.ServerGAMEOBJ.GetData('B-U-army_distribution').replace('"', ''))
        GDATPacket += PacketEncoder.SetVar('B-U-avail_slots_national', self.ServerGAMEOBJ.GetData('B-U-avail_slots_national'))
        GDATPacket += PacketEncoder.SetVar('B-U-avail_slots_royal', self.ServerGAMEOBJ.GetData('B-U-avail_slots_royal'))
        GDATPacket += PacketEncoder.SetVar('B-U-avail_vips_national', self.ServerGAMEOBJ.GetData('B-U-avail_vips_national'))
        GDATPacket += PacketEncoder.SetVar('B-U-avail_vips_royal', self.ServerGAMEOBJ.GetData('B-U-avail_vips_royal'))
        GDATPacket += PacketEncoder.SetVar('B-U-avg_ally_rank', self.ServerGAMEOBJ.GetData('B-U-avg_ally_rank'))
        GDATPacket += PacketEncoder.SetVar('B-U-avg_axis_rank', self.ServerGAMEOBJ.GetData('B-U-avg_axis_rank'))
        GDATPacket += PacketEncoder.SetVar('B-U-community_name', self.ServerGAMEOBJ.GetData('B-U-community_name'))
        GDATPacket += PacketEncoder.SetVar('B-U-data_center', self.ServerGAMEOBJ.GetData('B-U-data_center'))
        GDATPacket += PacketEncoder.SetVar('B-U-elo_rank', self.ServerGAMEOBJ.GetData('B-U-elo_rank'))
        GDATPacket += PacketEncoder.SetVar('B-U-easyzone', self.ServerGAMEOBJ.GetData('B-U-easyzone'))
        GDATPacket += PacketEncoder.SetVar('B-U-lvl_sdv', self.ServerGAMEOBJ.GetData('B-U-lvl_sdv'))
        GDATPacket += PacketEncoder.SetVar('B-U-lvl_avg', self.ServerGAMEOBJ.GetData('B-U-lvl_avg'))
        GDATPacket += PacketEncoder.SetVar('B-U-map', self.ServerGAMEOBJ.GetData('B-U-map'))
        GDATPacket += PacketEncoder.SetVar('B-U-map_name', self.ServerGAMEOBJ.GetData('B-U-map_name'))
        GDATPacket += PacketEncoder.SetVar('B-U-punkb', self.ServerGAMEOBJ.GetData('B-U-punkb'))
        GDATPacket += PacketEncoder.SetVar('B-U-percent_full', self.ServerGAMEOBJ.GetData('B-U-percent_full'))
        GDATPacket += PacketEncoder.SetVar('B-U-ranked', self.ServerGAMEOBJ.GetData('B-U-ranked'))
        GDATPacket += PacketEncoder.SetVar('B-U-server_ip', self.ServerGAMEOBJ.GetData('B-U-server_ip'))
        GDATPacket += PacketEncoder.SetVar('B-U-server_state', self.ServerGAMEOBJ.GetData('B-U-server_state'))
        GDATPacket += PacketEncoder.SetVar('B-U-server_port', self.ServerGAMEOBJ.GetData('B-U-server_port'))
        GDATPacket += PacketEncoder.SetVar('B-U-servertype', self.ServerGAMEOBJ.GetData('B-U-servertype'))

        # Unknown data
        GDATPacket += PacketEncoder.SetVar('HXFR', self.ServerGAMEOBJ.GetData('HXFR'))
        GDATPacket += PacketEncoder.SetVar('HTTYPE', self.ServerGAMEOBJ.GetData('HTTYPE'))
        GDATPacket += PacketEncoder.SetVar('JOIN', self.ServerGAMEOBJ.GetData('JOIN'))
        GDATPacket += PacketEncoder.SetVar('RESERVE-HOST', self.ServerGAMEOBJ.GetData('RESERVE-HOST'))
        GDATPacket += PacketEncoder.SetVar('RT', self.ServerGAMEOBJ.GetData('RT'))
        GDATPacket += PacketEncoder.SetVar('TYPE', self.ServerGAMEOBJ.GetData('TYPE'), True)

        GDATPacket = PacketEncoder.encode('GDAT', GDATPacket, 0x0, 0)
        self.transport.getHandle().sendall(GDATPacket)

        print ConsoleColor('Success') + '[TheaterClient][GDAT] Client joining to game... (' + str(RequestedGID) + ')' + ConsoleColor('End')
    else:
        self.ServerGAMEOBJ = None
        print ConsoleColor('Error') + '[TheaterClient][GDAT] Cannot find requested game!' + ConsoleColor('End')
Ejemplo n.º 21
0
    def connectionLost(self, reason):
        print ConsoleColor(
            'Info') + '[FESLClient] Lost connection to ' + self.ip + ':' + str(
                self.port) + ConsoleColor('End')

        return
Ejemplo n.º 22
0
def ReceiveComponent(self, data, txn):
    if txn == 'NuLogin':
        SessionID = PacketDecoder.decode(data).GetVar('encryptedInfo')

        # Basic login data retrieve system, (Get AccountID, username and email from Database), if that data are missing return error to game
        try:
            AccountID = str(GetWebSession(SessionID)[0])
            Username = GetUserName(AccountID)
            email = GetEmail(AccountID)
        except:
            AccountID = None
            Username = None
            email = None
        # Save client connection info
        if self.GAMEOBJ == None:
            self.GAMEOBJ = DataClass.BF2Client()
            self.GAMEOBJ.FESLNetworkInt = self.transport
            Globals.Clients.append(self.GAMEOBJ)

        self.GAMEOBJ.IsOnline = True

        self.GAMEOBJ.SessionID = SessionID
        self.GAMEOBJ.Username = Username
        self.GAMEOBJ.UserID = AccountID
        self.GAMEOBJ.EMail = email


        if AccountID == None or Username == None or email == None:
            print ConsoleColor('Warning') + '[FESLClient][acct] User tryed to login using dead or incorrect SessionID! Ignoring...' + ConsoleColor('End')
            LoginPacket = PacketEncoder.SetVar('TXN', 'NuLogin')
            LoginPacket += PacketEncoder.SetVar('localizedMessage', '"The user is not entitled to access this game"')
            LoginPacket += PacketEncoder.SetVar('errorContainer.[]', 0)
            LoginPacket += PacketEncoder.SetVar('errorCode', 120, True)
            LoginPacket = PacketEncoder.encode('acct', LoginPacket, 0xC0000000, self.PacketID)
            self.transport.getHandle().sendall(LoginPacket)
            self.transport.loseConnection()

        else:
            print ConsoleColor(
                'Success') + '[FESLClient][acct] User ' + Username + ' Successfully logged in!' + ConsoleColor(
                'End')
            self.GAMEOBJ.LoginKey = RandomStringGenerator.Generate(24)

            LoginPacket = PacketEncoder.SetVar('TXN', 'NuLogin')
            LoginPacket += PacketEncoder.SetVar('profileId', AccountID)
            LoginPacket += PacketEncoder.SetVar('userId', AccountID)
            LoginPacket += PacketEncoder.SetVar('nuid', Username)
            LoginPacket += PacketEncoder.SetVar('lkey', self.GAMEOBJ.LoginKey, True)
            LoginPacket = PacketEncoder.encode('acct', LoginPacket, 0xC0000000, self.PacketID)
            self.transport.getHandle().sendall(LoginPacket)

    elif txn == 'NuGetPersonas':
        # Get User Soldiers

        GetPersonasPacket = PacketEncoder.SetVar('TXN', 'NuGetPersonas')

        # For now I'm using static variables.
        HeroCount = len(GetHeroes(self.GAMEOBJ.UserID))
        Heroes = GetHeroes(self.GAMEOBJ.UserID)
        loop = 0

        while loop != HeroCount:
            CurrentHero = Heroes[loop]
            HeroName = CurrentHero[2]
            GetPersonasPacket += PacketEncoder.SetVar('personas.' + str(loop), HeroName)
            loop += 1
        GetPersonasPacket += PacketEncoder.SetVar('personas.[]', len(GetHeroes(self.GAMEOBJ.UserID)), True)
        GetPersonasPacket = PacketEncoder.encode('acct', GetPersonasPacket, 0xC0000000, self.PacketID)
        self.transport.getHandle().sendall(GetPersonasPacket)

    elif txn == 'NuGetAccount':
        # Get Account data

        GetAccountPacket = PacketEncoder.SetVar('TXN', 'NuGetAccount')

        GetAccountPacket += PacketEncoder.SetVar('heroName', self.GAMEOBJ.Username)
        GetAccountPacket += PacketEncoder.SetVar('nuid', self.GAMEOBJ.EMail)

        # Birthday date
        Birthday = GetBirthday(self.GAMEOBJ.UserID).split('-')
        GetAccountPacket += PacketEncoder.SetVar('DOBDay', Birthday[0])
        GetAccountPacket += PacketEncoder.SetVar('DOBMonth', Birthday[1])
        GetAccountPacket += PacketEncoder.SetVar('DOBYear', Birthday[2])

        GetAccountPacket += PacketEncoder.SetVar('userId', self.GAMEOBJ.UserID)

        # Not sure what is this
        GetAccountPacket += PacketEncoder.SetVar('globalOptin', 0)
        GetAccountPacket += PacketEncoder.SetVar('thidPartyOptin', 0)

        # Other required data
        GetAccountPacket += PacketEncoder.SetVar('language', 'enUS')
        GetAccountPacket += PacketEncoder.SetVar('country', 'US', True)
        GetAccountPacket = PacketEncoder.encode('acct', GetAccountPacket, 0xC0000000, self.PacketID)
        self.transport.getHandle().sendall(GetAccountPacket)

    elif txn == 'NuLookupUserInfo':
        # Load Soldiers info
        RequestedPersonas = int(PacketDecoder.decode(data).GetVar('userInfo.[]'))

        loop = 0

        LookupUserInfoPacket = PacketEncoder.SetVar('TXN', 'NuLookupUserInfo')

        while loop != RequestedPersonas:
            CurrentHero = PacketDecoder.decode(data).GetVar('userInfo.' + str(loop) + '.userName')
            HeroID = GetHeroIDByName(CurrentHero)
            if HeroID == False:
                HeroID = 0
            LookupUserInfoPacket += PacketEncoder.SetVar('userInfo.' + str(loop) + '.userName', CurrentHero)
            LookupUserInfoPacket += PacketEncoder.SetVar('userInfo.' + str(loop) + '.userId', HeroID)
            LookupUserInfoPacket += PacketEncoder.SetVar('userInfo.' + str(loop) + '.masterUserId', HeroID)
            LookupUserInfoPacket += PacketEncoder.SetVar('userInfo.' + str(loop) + '.namespace', 'MAIN')
            LookupUserInfoPacket += PacketEncoder.SetVar('userInfo.' + str(loop) + '.xuid', 24)
            loop += 1

        LookupUserInfoPacket += PacketEncoder.SetVar('userInfo.[]', RequestedPersonas, True)

        LookupUserInfoPacket = PacketEncoder.encode('acct', LookupUserInfoPacket, 0xC0000000, self.PacketID)
        self.transport.getHandle().sendall(LookupUserInfoPacket)

    elif txn == 'NuLoginPersona':
        # For now - Always login
        self.GAMEOBJ.LoginKey = RandomStringGenerator.Generate(24)
        LoginPersonaPacket = PacketEncoder.SetVar('TXN', 'NuLoginPersona')
        LoginPersonaPacket += PacketEncoder.SetVar('lkey', self.GAMEOBJ.LoginKey)
        LoginPersonaPacket += PacketEncoder.SetVar('profileId', self.GAMEOBJ.UserID)
        LoginPersonaPacket += PacketEncoder.SetVar('userId', self.GAMEOBJ.UserID)
        self.GAMEOBJ.Name = GetUserName(self.GAMEOBJ.UserID)

        LoginPersonaPacket = PacketEncoder.encode('acct', LoginPersonaPacket, 0xC0000000, self.PacketID)
        self.transport.getHandle().sendall(LoginPersonaPacket)
    else:
        print ConsoleColor('Warning') + '[FESLClient][acct] Got unknown TXN (' + txn + ')' + ConsoleColor('End')
Ejemplo n.º 23
0
def Prepare():
    if os.path.exists(DatabaseFileLocation):
        pass
    else:
        print ConsoleColor('Info') + '[Database] Creating database file...' + ConsoleColor('End')
        try:
            database = sqlite3.connect(DatabaseFileLocation)
        except Exception, e:
            raise Exception, e

        command = "CREATE TABLE `Accounts` 	(" \
                  "`AccountID`   INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, " \
                  "`Username`	TEXT NOT NULL UNIQUE," \
                  "`EMail`     TEXT NOT NULL UNIQUE," \
                  "`Password`   TEXT NOT NULL," \
                  "`Birthday`   TEXT NOT NULL" \
                  ");"

        cursor = database.cursor()
        cursor.execute(command)
        database.commit()

        command = "CREATE TABLE `Heroes` 	(" \
                  "`AccountID`   INTEGER NOT NULL, " \
                  "`HeroID`   INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, " \
                  "`HeroName`	TEXT NOT NULL UNIQUE" \
                  ");"

        cursor = database.cursor()
        cursor.execute(command)
        database.commit()

        command = "CREATE TABLE `HeroesStats` 	(" \
                  "`HeroID`     INTEGER NOT NULL," \
                  "`StatName`	TEXT NOT NULL," \
                  "`StatValue`  INTEGER DEFAULT 0," \
                  "`StatText`   TEXT" \
                  ");"

        cursor = database.cursor()
        cursor.execute(command)
        database.commit()

        command = "CREATE TABLE `Servers` 	(" \
                  "`ServerID`     INTEGER NOT NULL," \
                  "`OwnerName`    TEXT NOT NULL," \
                  "`ServerPassword`	TEXT NOT NULL UNIQUE," \
                  "`Key`   TEXT NOT NULL" \
                  ");"

        cursor = database.cursor()
        cursor.execute(command)
        database.commit()

        command = "CREATE TABLE `WebSessions` 	(" \
                  "`AccountID`   INTEGER NOT NULL, " \
                  "`SessionID`	TEXT NOT NULL UNIQUE" \
                  ");"

        cursor = database.cursor()
        cursor.execute(command)
        database.commit()
Ejemplo n.º 24
0
def ReceiveComponent(self, data, txn):
    if txn == 'NuLogin':
        try:
            ServerPassword = PacketDecoder.decode(data).GetVar('password')
        except:
            ServerPassword = None

        # Save client connection info
        if self.GAMEOBJ == None:
            self.GAMEOBJ = DataClass.BF2Server()
            self.GAMEOBJ.FESLNetworkInt = self.transport
            Globals.Servers.append(self.GAMEOBJ)

        if ServerPassword == None:
            print ConsoleColor(
                'Warning'
            ) + '[FESLServer][acct] Server didnt send password! Disconnecting...' + ConsoleColor(
                'End')
            LoginPacket = PacketEncoder.SetVar('TXN', 'NuLogin')
            LoginPacket += PacketEncoder.SetVar(
                'localizedMessage',
                '"The password the user specified is incorrect"')
            LoginPacket += PacketEncoder.SetVar('errorContainer.[]', 0)
            LoginPacket += PacketEncoder.SetVar('errorCode', 122, True)
            LoginPacket = PacketEncoder.encode('acct', LoginPacket, 0xC0000000,
                                               self.PacketID)
            self.transport.getHandle().sendall(LoginPacket)
            self.transport.loseConnection()

        if CheckServerPassword(ServerPassword) == True:
            print ConsoleColor(
                'Success'
            ) + '[FESLServer][acct] Server successfully logged in!' + ConsoleColor(
                'End')
            self.GAMEOBJ.LoginKey = RandomStringGenerator.Generate(24)
            self.GAMEOBJ.UserID = CheckServerPassword(ServerPassword)

            LoginPacket = PacketEncoder.SetVar('TXN', 'NuLogin')
            LoginPacket += PacketEncoder.SetVar('lkey', self.GAMEOBJ.LoginKey)
            LoginPacket += PacketEncoder.SetVar(
                'nuid',
                GetServerAuthData(self.GAMEOBJ.UserID)[1])
            LoginPacket += PacketEncoder.SetVar('profileId',
                                                self.GAMEOBJ.UserID)
            LoginPacket += PacketEncoder.SetVar('userId', self.GAMEOBJ.UserID)
            LoginPacket = PacketEncoder.encode('acct', LoginPacket, 0xC0000000,
                                               self.PacketID)
            self.transport.getHandle().sendall(LoginPacket)
        else:
            print ConsoleColor(
                'Warning'
            ) + '[FESLServer][acct] Server specified wrong password! Disconnecting...' + ConsoleColor(
                'End')
            LoginPacket = PacketEncoder.SetVar('TXN', 'NuLogin')
            LoginPacket += PacketEncoder.SetVar(
                'localizedMessage',
                '"The password the user specified is incorrect"')
            LoginPacket += PacketEncoder.SetVar('errorContainer.[]', 0)
            LoginPacket += PacketEncoder.SetVar('errorCode', 122, True)
            LoginPacket = PacketEncoder.encode('acct', LoginPacket, 0xC0000000,
                                               self.PacketID)
            self.transport.getHandle().sendall(LoginPacket)
            self.transport.loseConnection()

    elif txn == 'NuGetPersonas':
        PersonaPacket = PacketEncoder.SetVar('TXN', 'NuGetPersonas')
        PersonaPacket += PacketEncoder.SetVar('personas.[]', 0)
        PersonaPacket = PacketEncoder.encode('acct', PersonaPacket, 0xC0000000,
                                             self.PacketID)
        self.transport.getHandle().sendall(PersonaPacket)

    elif txn == 'NuGetAccount':
        AccountPacket = PacketEncoder.SetVar('TXN', 'NuGetAccount')
        AccountPacket += PacketEncoder.SetVar(
            'heroName',
            GetServerAuthData(self.GAMEOBJ.UserID)[1])
        AccountPacket += PacketEncoder.SetVar(
            'nuid',
            GetServerAuthData(self.GAMEOBJ.UserID)[1])
        AccountPacket += PacketEncoder.SetVar('DOBDay', 01)
        AccountPacket += PacketEncoder.SetVar('DOBMonth', 01)
        AccountPacket += PacketEncoder.SetVar('DOBYear', 1970)
        AccountPacket += PacketEncoder.SetVar('userId', self.GAMEOBJ.UserID)
        AccountPacket += PacketEncoder.SetVar('globalOptin', 0)
        AccountPacket += PacketEncoder.SetVar('thidPartyOptin', 0)
        AccountPacket += PacketEncoder.SetVar('language', 'enUS')
        AccountPacket += PacketEncoder.SetVar('country', 'US')
        AccountPacket = PacketEncoder.encode('acct', AccountPacket, 0xC0000000,
                                             self.PacketID)
        self.transport.getHandle().sendall(AccountPacket)

    elif txn == 'NuLoginPersona':
        LoginPacket = PacketEncoder.SetVar('TXN', 'NuLoginPersona')
        LoginPacket += PacketEncoder.SetVar('lkey', self.GAMEOBJ.LoginKey)
        LoginPacket += PacketEncoder.SetVar('profileId', self.GAMEOBJ.UserID)
        LoginPacket += PacketEncoder.SetVar('userId', self.GAMEOBJ.UserID)
        LoginPacket = PacketEncoder.encode('acct', LoginPacket, 0xC0000000,
                                           self.PacketID)
        self.transport.getHandle().sendall(LoginPacket)

    elif txn == 'NuLookupUserInfo':
        LookupPacket = PacketEncoder.SetVar('TXN', 'NuLookupUserInfo')
        LookupPacket += PacketEncoder.SetVar(
            'userInfo.0.userName',
            GetServerAuthData(self.GAMEOBJ.UserID)[1])
        LookupPacket += PacketEncoder.SetVar('userInfo.0.userId',
                                             self.GAMEOBJ.UserID)
        LookupPacket += PacketEncoder.SetVar('userInfo.0.masterUserId',
                                             self.GAMEOBJ.UserID)
        LookupPacket += PacketEncoder.SetVar('userInfo.0.namespace', 'MAIN')
        LookupPacket += PacketEncoder.SetVar('userInfo.0.xuid', 24)
        LookupPacket += PacketEncoder.SetVar('userInfo.0.cid',
                                             self.GAMEOBJ.UserID)
        LookupPacket += PacketEncoder.SetVar('userInfo.[]', 1)
        LookupPacket = PacketEncoder.encode('acct', LookupPacket, 0xC0000000,
                                            self.PacketID)
        self.transport.getHandle().sendall(LookupPacket)
    else:
        print ConsoleColor(
            'Warning'
        ) + '[FESLServer][acct] Got unknown TXN (' + txn + ')' + ConsoleColor(
            'End')