Exemplo n.º 1
0
    def __init__(self, c, ipbans):
        self.log = Logging()
        client = c
        # We send the first package (HC + KEY + empty byte)
        client.write('HC' + client.get_key())

        # We are waiting for the client version
        data = client.get_io_session().recv(2048)
        msg = data.decode()
        if not (msg == '1.30.9\n\x00' or msg == '1.29.1\n\x00'
                or msg == '1.30.0\n\x00' or msg == '1.31.2\n\x00'):
            self.log.debug('[' + str(client.get_address()[0]) + ':' +
                           str(client.get_address()[1]) + '][' +
                           str(client.get_status().name) +
                           '] The client has the wrong version - ' + '(' +
                           str(msg.split('\n')[0]) + ')')
            # TODO wrong text window is displayed "Invalid login or password."
            client.write('AlEf')
            sys.exit(0)
        for i in ipbans:
            if client.get_address()[0] == i['ip']:
                self.log.debug('[' + str(client.get_address()[0]) + ':' +
                               str(client.get_address()[1]) + ']' + '[' +
                               str(client.get_status().name) + '] ' +
                               'This IP is banned')
                client.write('AlEb')
                client.kick()
        self.log.debug('[' + str(client.get_address()[0]) + ':' +
                       str(client.get_address()[1]) + '][' +
                       str(client.get_status().name) + '] Version accepted ' +
                       '(' + str(msg.split('\n')[0]) + ')')
        return
Exemplo n.º 2
0
 def __init__(self, gameClient):
     self.log = Logging()
     self.nameGenerator = NameGenerator()  # "world.join()" should quake it
     self.gameClient = gameClient
     self.account = None
     self.accId = None
     self.player = None
Exemplo n.º 3
0
    def __init__(self, ip, port, gameClientDic, accountDataDic, hostList,
                 ipBans):
        self.log = Logging()
        self.logoniIP = ip
        self.logonPort = port
        self.gameClientDic = gameClientDic
        self.accountDataDic = accountDataDic
        self.hostList = hostList
        self.ipBans = ipBans

        self.start()
Exemplo n.º 4
0
 def __init__(self, socket, addr):
     self.log = Logging()
     self.session = socket
     self.addr = addr
     # self.account = account
     # self.actions =
     self.timeLastChatMsg = 0
     self.timeLastIncarnamMsg = 0
     self.timeLastAlignMsg = 0
     self.timeLastRecrutmentMsg = 0
     self.timeLastTradeMsg = 0
     self.walk = False
Exemplo n.º 5
0
    def __init__(self, socket, addr, exchangeTransferList, world):
        self.log = Logging()
        self.world = world
        self.gameClient = GameClient(socket, addr)
        self.exchangeTransferList = exchangeTransferList
        self.socketManager = SocketManager(self.gameClient)

        self.accId = None
        self.account = None

        self.socketManager.GAME_SEND_HELLOGAME_PACKET()
        self.loop()
Exemplo n.º 6
0
    def __init__(self, soecket, addr, gameClientDic, accountDataDic, hostList,
                 ipbans):
        self.log = Logging()
        self.gameClientDic = gameClientDic
        self.accountDataDic = accountDataDic
        self.hostList = hostList

        self.client = LoginClient(self.gameClientDic, self.accountDataDic)
        self.client.set_key(self.generate_key())
        self.client.set_address(addr)
        self.client.set_status(Status(0))
        self.client.set_io_session(soecket)

        self.log.debug('[' + str(addr[0]) + ':' + str(addr[1]) + '][' +
                       str(self.client.get_status().name) +
                       '] Client created - ' + self.client.get_key())

        # the object is save in the global dictionary
        dict_str = addr[0] + ':' + str(addr[1])
        self.gameClientDic[dict_str] = self.client

        HelloConnection(self.client, ipbans)
        self.recv_loop()
Exemplo n.º 7
0
 def __init__(self):
     self.log = Logging()
Exemplo n.º 8
0
 def __init__(self):
     self.log = Logging()
     self.Datasource = []
Exemplo n.º 9
0
 def __init__(self):
     self.log = Logging()
     self.connection = dataSource.Database().get_connection()
     self.cursor = self.connection.cursor()
Exemplo n.º 10
0
    def __init__(self, mapId, date, width, heigth, key, places, mapData, cells,
                 monsters, mapPos, numGroup, fixSize, minSize, maxSize, cases,
                 forbidden):

        self.log = Logging()

        self.id = mapId
        self.data = date
        self.width = width
        self.heigth = heigth
        self.key = key
        self.places = places
        self.mapData = mapData
        self.cells = cells
        self.monsters = monsters
        self.numGroup = numGroup
        self.fixSize = fixSize
        self.minSize = minSize
        self.maxSize = maxSize
        self.forbiddenCellSpawn = cases
        # -----------------------------------------
        # if (!places.equalsIgnoreCase("") && !places.equalsIgnoreCase("|")) {
        #     final String[] split = places.split("\\|");
        #     this.maxTeam0 = split[0].length() / 2;
        #     this.maxTeam1 = split[1].length() / 2;
        # }
        # -----------------------------------------
        try:
            mapPos.split(',')
            self.X = mapPos[0]
            self.Y = mapPos[1]
            del mapPos
        except Exception as Error:
            self.log.warning('[MAP {}] Map.__init__ - (mapPos) - {}'.format(
                self.id, Error))
        # -----------------------------------------
        # subArea
        # -----------------------------------------
        try:
            split = forbidden.split(';')
            self.noTrader = split[0] in '1'
            self.noCollector = split[1] in '1'
            self.noPrism = split[2] in '1'
            self.noTP = split[3] in '1'
            self.noDefie = split[4] in '1'
            self.noAgro = split[5] in '1'
            self.noChannel = split[6] in '1'
            del forbidden, split
        except Exception as Error:
            self.log.warning('[MAP {}] Map.__init__ - (forbidden) - {}'.format(
                self.id, Error))
        # -----------------------------------------
        try:
            cryptManager = CryptManager()
            self.cases = cryptManager.decompile_map_data(self, self.mapData)
            del cryptManager, self.mapData
        except Exception as Error:
            self.log.warning(
                '[MAP {}] Map.__init__ - (decompile_map_data) - {}'.format(
                    self.id, Error))

        # if
        #     this.cases = CryptManager.decompileMapData(this, dData)
        # else:
        #     final String[] cellsDataArray = cellsData.split("\\|");

# 	String[] array;
# 	for (int length = (array = cellsDataArray).length, j = 0; j < length; ++j) {
# 		final String o = array[j];
# 		boolean Walkable = true;
#         ...
#         ...
#         ...
# -----------------------------------------
# String[] split2;
# for (int length2 = (split2 = monsters.split("\\|")).length, k = 0; k < length2; ++k) {
# 	final String mob = split2[k];
# -----------------------------------------
# if (!cases.isEmpty()) {
#             for (final Case c : this.cases.values()) {
#                 c.setWalkableInFight(false);
#             }
#             try {
#                 String[] split3;
#                 ....
#                 ....
#                 ....
# -----------------------------------------
Exemplo n.º 11
0
 def __init__(self):
     self.log = Logging()
     self.log.debug('Database instance has been created')
Exemplo n.º 12
0
 def __init__(self, game_client_dic, accountDataDic):
     self.game_client_dic = game_client_dic
     self.accountDataDic = accountDataDic
     self.log = Logging()
Exemplo n.º 13
0
 def __init__(self):
     self.log = Logging()
     self.config = Config()
     self.console = Console()
     self.console.clear()
Exemplo n.º 14
0
def main():
    #  ======================================================
    #  start message

    log = Logging()
    console = Console()
    console.clear()

    def wel():
        welmsg = [
            58 * '─', '|  0.01  |' + 12 * ' ' + 'pyCestra - Logon Server' +
            12 * ' ' + '|', 58 * "─"
        ]
        for x in welmsg:
            print(bcolors.blue + x + bcolors.cend)

    wel()

    # ======================================================
    # preload data

    config = Config()
    config.initialize()

    log.info('Connection Test...')
    database = dataSource.Database()
    if database.get_connection():
        log.info('Connection Successfully')
    else:
        log.warning('Connection ERROR')
        sys.exit(0)

    hostList = dataSource.ServerData()
    hostList.load()
    hostList = hostList.get_server_data()
    log.info('ServerData were loaded')

    accountData = dataSource.AccountData()
    accountData.load()
    accountDataDic = accountData.get_account_data()
    log.info('AccountData were loaded')

    ipbans = dataSource.IpBans().load()
    log.info('IP Bans were loaded')

    dataSource.DatabaseUpdateService().start(accountDataDic,
                                             config.get_update_time())

    # ======================================================
    # socket tests

    print(58 * '-')

    game_client_dic = {}

    LoginServer(config.get_login_ip(), config.get_login_port(),
                game_client_dic, accountDataDic, hostList, ipbans)

    ExchangeServer().start(config.get_exchange_ip(),
                           config.get_exchange_port(), hostList)

    while True:
        time.sleep(15)
        if game_client_dic:
            log.warning('---- game_client_dic ----')
            for x in game_client_dic:
                log.warning(str(x))
            log.warning('-------------------------')
Exemplo n.º 15
0
    def __init__(self, client, packet, accountDataDic, hostList):
        self.log = Logging()
        account = client.get_account()
        packet = packet.replace('\n\x00', '')
        packet = int(packet)
        server = None

        def get_free_server(hostList):
            msg = 'AXEf'
            for s in hostList:
                try:
                    fp = s.get_free_places()
                except AttributeError:
                    fp = 0
                if s.get_sub() != 0 or fp > 0:
                    continue
                msg += str(s.get_id()) + '|'
                return msg

        try:
            # server is searched from the host list
            for i in hostList:
                if i.get_id() == packet:
                    server = i
            self.log.debug('[{}:{}][{}] Server {} has been selected'.format(
                str(client.get_address()[0]), str(client.get_address()[1]),
                str(client.get_status().name), packet))
            # client is kicked if this server id does not exist
            if server is None:
                self.log.debug(
                    '[{}:{}][{}] The selected server does not exist for the account'
                    .format(str(client.get_address()[0]),
                            str(client.get_address()[1]),
                            str(client.get_status().name)))
                # clinet msg: You are not allowed to connect to this server.
                client.write('AXEr')
                return
            # the selected server is not in the correct status for the account
            if server.get_status() != 1:
                self.log.debug(
                    '[{}:{}][{}] The status of the selected server is unavailable for the account'
                    .format(str(client.get_address()[0]),
                            str(client.get_address()[1]),
                            str(client.get_status().name)))
                # clinet msg: The server you selected is unavailable at this time.
                client.write('AXEd')
                return
            # the selected server is only available to subscribers
            if account.is_subscribes() == 0 and server.get_sub() == 1:
                self.log.debug(
                    '[{}:{}][{}] The selected server is full or you must be subscribed for the account'
                    .format(str(client.get_address()[0]),
                            str(client.get_address()[1]),
                            str(client.get_status().name)))
                # clinet msg: Server:FULL Maximum number of players reached.
                #             To get priority access, please becomme a full member by subscribing..
                client.write(get_free_server(hostList))
                ServerList().get_list(client)
                return
            account.set_server(server.get_id())
            # all important account data are sent to the game server
            for __i in accountDataDic:
                if __i['id'] == account.get_id():
                    lastConnectionDate = __i['lastConnectionDate']
                    lastIP = __i['lastIP']
            server.get_ex_client().send('WA#{}#{}#{}#{}#{}#{}#{}'.format(
                str(account.get_id()), account.get_nickname(),
                account.get_question(), account.get_reponse(),
                account.get_subscribe(), lastConnectionDate, lastIP))
            # the address of the world server is sent to the client
            client.write('AYK{}:{};{}'.format(str(server.get_ip()),
                                              str(server.get_port()),
                                              str(account.get_id())))
            # set client status to WAIT_VERSION
            account.set_state(0)
            self.log.info(
                '[{}:{}][{}] Client connects to World-Server:{}'.format(
                    str(client.get_address()[0]), str(client.get_address()[1]),
                    str(client.get_status().name), str(server.get_id())))
        except Exception as e:
            self.log.warning(
                '[{}:{}][{}] The server selection failed\n{}'.format(
                    str(client.get_address()[0]), str(client.get_address()[1]),
                    str(client.get_status().name), e))
            client.write('AXEr')
            client.kick()
            return
Exemplo n.º 16
0
 def __init__(self):
     self.log = Logging()
     self.constant = Constant()
     self.maps = {}  # ID(int), MAP(object)