mirror of
https://github.com/solero/houdini.git
synced 2024-11-21 21:17:21 +00:00
commit
6b12be1c15
@ -45,10 +45,12 @@ async def get_server_presence(p, pdata):
|
|||||||
if await p.server.redis.scard(server_key):
|
if await p.server.redis.scard(server_key):
|
||||||
async with p.server.db.transaction():
|
async with p.server.db.transaction():
|
||||||
buddies = BuddyList.select('buddy_id').where(BuddyList.penguin_id == pdata.id).gino.iterate()
|
buddies = BuddyList.select('buddy_id').where(BuddyList.penguin_id == pdata.id).gino.iterate()
|
||||||
tr = p.server.redis.multi_exec()
|
|
||||||
|
async with p.server.redis.pipeline(transaction=True) as tr:
|
||||||
async for buddy_id, in buddies:
|
async for buddy_id, in buddies:
|
||||||
tr.sismember(server_key, buddy_id)
|
tr.sismember(server_key, buddy_id)
|
||||||
online_buddies = await tr.execute()
|
online_buddies = await tr.execute()
|
||||||
|
|
||||||
if any(online_buddies):
|
if any(online_buddies):
|
||||||
buddy_worlds.append(str(int(server_id)))
|
buddy_worlds.append(str(int(server_id)))
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ async def handle_login(p, credentials: Credentials):
|
|||||||
p.logger.info(f'{username} failed to login: incorrect password')
|
p.logger.info(f'{username} failed to login: incorrect password')
|
||||||
|
|
||||||
if await p.server.redis.exists(flood_key):
|
if await p.server.redis.exists(flood_key):
|
||||||
tr = p.server.redis.multi_exec()
|
async with p.server.redis.pipeline(transaction=True) as tr:
|
||||||
tr.incr(flood_key)
|
tr.incr(flood_key)
|
||||||
tr.expire(flood_key, p.server.config.login_failure_timer)
|
tr.expire(flood_key, p.server.config.login_failure_timer)
|
||||||
failure_count, _ = await tr.execute()
|
failure_count, _ = await tr.execute()
|
||||||
@ -100,7 +100,8 @@ async def handle_login(p, credentials: Credentials):
|
|||||||
login_key = Crypto.hash(random_key[::-1])
|
login_key = Crypto.hash(random_key[::-1])
|
||||||
confirmation_hash = Crypto.hash(os.urandom(24))
|
confirmation_hash = Crypto.hash(os.urandom(24))
|
||||||
|
|
||||||
tr = p.server.redis.multi_exec()
|
|
||||||
|
async with p.server.redis.pipeline(transaction=True) as tr:
|
||||||
tr.setex(f'{data.username}.lkey', p.server.config.auth_ttl, login_key)
|
tr.setex(f'{data.username}.lkey', p.server.config.auth_ttl, login_key)
|
||||||
tr.setex(f'{data.username}.ckey', p.server.config.auth_ttl, confirmation_hash)
|
tr.setex(f'{data.username}.ckey', p.server.config.auth_ttl, confirmation_hash)
|
||||||
await tr.execute()
|
await tr.execute()
|
||||||
|
@ -41,7 +41,7 @@ async def world_login(p, data):
|
|||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
@handlers.depends_on_packet(XMLPacket('verChk'), XMLPacket('rndK'))
|
@handlers.depends_on_packet(XMLPacket('verChk'), XMLPacket('rndK'))
|
||||||
async def handle_login(p, credentials: WorldCredentials):
|
async def handle_login(p, credentials: WorldCredentials):
|
||||||
tr = p.server.redis.multi_exec()
|
async with p.server.redis.pipeline(transaction=True) as tr:
|
||||||
tr.get(f'{credentials.username}.lkey')
|
tr.get(f'{credentials.username}.lkey')
|
||||||
tr.get(f'{credentials.username}.ckey')
|
tr.get(f'{credentials.username}.ckey')
|
||||||
tr.delete(f'{credentials.username}.lkey', f'{credentials.username}.ckey')
|
tr.delete(f'{credentials.username}.lkey', f'{credentials.username}.ckey')
|
||||||
@ -69,7 +69,7 @@ async def handle_login(p, credentials: WorldCredentials):
|
|||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
@handlers.depends_on_packet(XMLPacket('verChk'), XMLPacket('rndK'))
|
@handlers.depends_on_packet(XMLPacket('verChk'), XMLPacket('rndK'))
|
||||||
async def handle_legacy_login(p, credentials: Credentials):
|
async def handle_legacy_login(p, credentials: Credentials):
|
||||||
tr = p.server.redis.multi_exec()
|
async with p.server.redis.pipeline(transaction=True) as tr:
|
||||||
tr.get(f'{credentials.username}.lkey')
|
tr.get(f'{credentials.username}.lkey')
|
||||||
tr.delete(f'{credentials.username}.lkey', f'{credentials.username}.ckey')
|
tr.delete(f'{credentials.username}.lkey', f'{credentials.username}.ckey')
|
||||||
login_key, _ = await tr.execute()
|
login_key, _ = await tr.execute()
|
||||||
|
@ -12,7 +12,7 @@ async def handle_join_redemption_server_vanilla(p, credentials: str, confirmatio
|
|||||||
if login_key != p.login_key:
|
if login_key != p.login_key:
|
||||||
return await p.close()
|
return await p.close()
|
||||||
|
|
||||||
tr = p.server.redis.multi_exec()
|
async with p.server.redis.pipeline(transaction=True) as tr:
|
||||||
tr.setex(f'{username}.lkey', p.server.config.auth_ttl, login_key)
|
tr.setex(f'{username}.lkey', p.server.config.auth_ttl, login_key)
|
||||||
tr.setex(f'{username}.ckey', p.server.config.auth_ttl, confirmation_hash)
|
tr.setex(f'{username}.ckey', p.server.config.auth_ttl, confirmation_hash)
|
||||||
await tr.execute()
|
await tr.execute()
|
||||||
@ -28,7 +28,7 @@ async def handle_join_redemption_server_legacy(p, _, login_key: str):
|
|||||||
if login_key != p.login_key:
|
if login_key != p.login_key:
|
||||||
return await p.close()
|
return await p.close()
|
||||||
|
|
||||||
tr = p.server.redis.multi_exec()
|
async with p.server.redis.pipeline(transaction=True) as tr:
|
||||||
tr.setex(f'{p.username}.lkey', p.server.config.auth_ttl, login_key)
|
tr.setex(f'{p.username}.lkey', p.server.config.auth_ttl, login_key)
|
||||||
await tr.execute()
|
await tr.execute()
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ async def handle_send_book_answer(p, book: int, question_id: int, answer: str):
|
|||||||
redemption_attempts_key = f'{p.id}.redemption_attempts'
|
redemption_attempts_key = f'{p.id}.redemption_attempts'
|
||||||
|
|
||||||
if await p.server.redis.exists(redemption_attempts_key):
|
if await p.server.redis.exists(redemption_attempts_key):
|
||||||
tr = p.server.redis.multi_exec()
|
async with p.server.redis.pipeline(transaction=True) as tr:
|
||||||
tr.incr(redemption_attempts_key)
|
tr.incr(redemption_attempts_key)
|
||||||
tr.expire(redemption_attempts_key, p.server.config.login_failure_timer)
|
tr.expire(redemption_attempts_key, p.server.config.login_failure_timer)
|
||||||
failure_count, _ = await tr.execute()
|
failure_count, _ = await tr.execute()
|
||||||
|
Loading…
Reference in New Issue
Block a user