Exemple #1
0

@handlers.boot
async def igloos_load(server):
    server.igloos = await IglooCollection.get_collection()
    server.furniture = await FurnitureCollection.get_collection()
    server.locations = await LocationCollection.get_collection()
    server.flooring = await FlooringCollection.get_collection()

    server.logger.info(f'Loaded {len(server.igloos)} igloos')
    server.logger.info(f'Loaded {len(server.furniture)} furniture items')
    server.logger.info(f'Loaded {len(server.locations)} igloo locations')
    server.logger.info(f'Loaded {len(server.flooring)} igloo flooring')


@handlers.handler(XMLPacket('login'), priority=Priority.Low)
@handlers.allow_once
async def load_igloo_inventory(p):
    p.igloos = await PenguinIglooCollection.get_collection(p.id)
    p.igloo_rooms = await PenguinIglooRoomCollection.get_collection(p.id)
    p.furniture = await PenguinFurnitureCollection.get_collection(p.id)
    p.flooring = await PenguinFlooringCollection.get_collection(p.id)
    p.locations = await PenguinLocationCollection.get_collection(p.id)

    default_igloos = p.server.igloos.legacy_inventory if p.is_legacy_client else \
        p.server.igloos.vanilla_inventory
    for default_item in default_igloos:
        if default_item.id not in p.igloos:
            await p.igloos.insert(igloo_id=default_item.id)

    default_locations = p.server.locations.legacy_inventory if p.is_legacy_client else \
Exemple #2
0
from houdini import handlers
from houdini.constants import ClientType
from houdini.converters import VersionChkConverter
from houdini.data.buddy import BuddyList
from houdini.handlers import XMLPacket


@handlers.handler(XMLPacket('verChk'))
@handlers.allow_once
async def handle_version_check(p, version: VersionChkConverter):
    if not p.server.config.single_client_mode:
        if p.server.config.legacy_version == version:
            p.client_type = ClientType.Legacy
        elif p.server.config.vanilla_version == version:
            p.client_type = ClientType.Vanilla
    elif p.server.config.default_version == version:
        p.client_type = p.server.config.default_client

    if p.client_type is None:
        await p.send_xml({'body': {'action': 'apiKO', 'r': '0'}})
        await p.close()
    else:
        await p.send_xml({'body': {'action': 'apiOK', 'r': '0'}})


@handlers.handler(XMLPacket('rndK'))
@handlers.allow_once
async def handle_random_key(p, _):
    await p.send_xml({
        'body': {
            'action': 'rndK',
Exemple #3
0
        return await p.close()

    active_ban = await Ban.query.where((Ban.penguin_id == data.id) & (
        Ban.expires >= datetime.now())).gino.scalar()
    if active_ban is not None:
        return await p.close()

    if data.id in p.server.penguins_by_id:
        await p.server.penguins_by_id[data.id].close()

    p.logger.info(f'{data.username} logged in successfully')
    p.update(**data.to_dict())
    await p.send_xt('l')


@handlers.handler(XMLPacket('login'), client=ClientType.Vanilla)
@handlers.allow_once
@handlers.depends_on_packet(XMLPacket('verChk'), XMLPacket('rndK'))
async def handle_login(p, credentials: WorldCredentials):
    async with p.server.redis.pipeline(transaction=True) as tr:
        tr.get(f'{credentials.username}.lkey')
        tr.get(f'{credentials.username}.ckey')
        tr.delete(f'{credentials.username}.lkey',
                  f'{credentials.username}.ckey')
        login_key, confirmation_hash, _ = await tr.execute()

    if login_key is None or confirmation_hash is None:
        return await p.close()

    login_key = login_key.decode()
    login_hash = Crypto.encrypt_password(login_key +
Exemple #4
0
import bcrypt
from sqlalchemy import func

from houdini import handlers
from houdini.constants import ClientType
from houdini.converters import Credentials
from houdini.crypto import Crypto
from houdini.data.moderator import Ban
from houdini.data.penguin import Penguin
from houdini.handlers import XMLPacket
from houdini.handlers.login import get_server_presence
from houdini.handlers.play.navigation import get_minutes_played_today


@handlers.handler(XMLPacket('login'))
@handlers.allow_once
@handlers.depends_on_packet(XMLPacket('verChk'), XMLPacket('rndK'))
async def handle_login(p, credentials: Credentials):
    loop = asyncio.get_event_loop()

    username, password = credentials.username, credentials.password
    p.logger.info(f'{username} is logging in!')

    data = await Penguin.query.where(func.lower(Penguin.username) == username
                                     ).gino.first()

    if data is None:
        p.logger.info(f'{username} failed to login: penguin does not exist')
        return await p.send_error_and_disconnect(100)