Skip to content

Commit

Permalink
deploy: 5c92c84
Browse files Browse the repository at this point in the history
  • Loading branch information
Askaholic committed Oct 17, 2023
1 parent e1e6379 commit 8a29a01
Showing 1 changed file with 20 additions and 82 deletions.
102 changes: 20 additions & 82 deletions lobbyconnection.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,16 @@ <h1 class="title">Module <code>server.lobbyconnection</code></h1>
import asyncio
import contextlib
import json
import os
import random
import urllib.parse
import urllib.request
from binascii import hexlify
from datetime import datetime
from functools import wraps
from hashlib import md5
from typing import Optional

import aiohttp
from sqlalchemy import and_, func, select
from sqlalchemy.exc import DBAPIError, OperationalError, ProgrammingError
from sqlalchemy.exc import DBAPIError

import server.metrics as metrics
from server.db import FAFDatabase
Expand Down Expand Up @@ -540,14 +537,16 @@ <h1 class="title">Module <code>server.lobbyconnection</code></h1>

username = row.login

new_irc_password = hexlify(os.urandom(16)).decode()
# DEPRECATED: IRC passwords are handled outside of the lobby server.
# This message remains here for backwards compatibility, but the data
# sent is meaningless and can be ignored by clients.
await self.send({
&#34;command&#34;: &#34;irc_password&#34;,
&#34;password&#34;: new_irc_password
&#34;password&#34;: &#34;deprecated&#34;
})

await self.on_player_login(
player_id, username, new_irc_password, unique_id, auth_method
player_id, username, unique_id, auth_method
)

async def command_hello(self, message):
Expand All @@ -572,14 +571,13 @@ <h1 class="title">Module <code>server.lobbyconnection</code></h1>
)

await self.on_player_login(
player_id, username, password, unique_id, &#34;password&#34;
player_id, username, unique_id, &#34;password&#34;
)

async def on_player_login(
self,
player_id: int,
username: str,
password: str,
unique_id: str,
method: str
):
Expand Down Expand Up @@ -611,7 +609,6 @@ <h1 class="title">Module <code>server.lobbyconnection</code></h1>
last_login=func.now()
)
)
await self.update_irc_password(conn, username, password)

self.player = Player(
login=username,
Expand Down Expand Up @@ -708,22 +705,6 @@ <h1 class="title">Module <code>server.lobbyconnection</code></h1>

await self.send_game_list()

async def update_irc_password(self, conn, login, password):
# Since the password is hashed on the client, what we get at this point
# is really md5(md5(sha256(password))). This is entirely insane.
temp = md5(password.encode()).hexdigest()
irc_pass = &#34;md5:&#34; + md5(temp.encode()).hexdigest()

try:
await conn.execute(
&#34;UPDATE anope.anope_db_NickCore &#34;
&#34;SET pass = :passwd WHERE display = :display&#34;,
passwd=irc_pass,
display=login
)
except (OperationalError, ProgrammingError):
self._logger.error(&#34;Failure updating NickServ password for %s&#34;, login)

async def command_restore_game_session(self, message):
assert self.player is not None

Expand Down Expand Up @@ -1778,14 +1759,16 @@ <h2 class="section-title" id="header-classes">Classes</h2>

username = row.login

new_irc_password = hexlify(os.urandom(16)).decode()
# DEPRECATED: IRC passwords are handled outside of the lobby server.
# This message remains here for backwards compatibility, but the data
# sent is meaningless and can be ignored by clients.
await self.send({
&#34;command&#34;: &#34;irc_password&#34;,
&#34;password&#34;: new_irc_password
&#34;password&#34;: &#34;deprecated&#34;
})

await self.on_player_login(
player_id, username, new_irc_password, unique_id, auth_method
player_id, username, unique_id, auth_method
)

async def command_hello(self, message):
Expand All @@ -1810,14 +1793,13 @@ <h2 class="section-title" id="header-classes">Classes</h2>
)

await self.on_player_login(
player_id, username, password, unique_id, &#34;password&#34;
player_id, username, unique_id, &#34;password&#34;
)

async def on_player_login(
self,
player_id: int,
username: str,
password: str,
unique_id: str,
method: str
):
Expand Down Expand Up @@ -1849,7 +1831,6 @@ <h2 class="section-title" id="header-classes">Classes</h2>
last_login=func.now()
)
)
await self.update_irc_password(conn, username, password)

self.player = Player(
login=username,
Expand Down Expand Up @@ -1946,22 +1927,6 @@ <h2 class="section-title" id="header-classes">Classes</h2>

await self.send_game_list()

async def update_irc_password(self, conn, login, password):
# Since the password is hashed on the client, what we get at this point
# is really md5(md5(sha256(password))). This is entirely insane.
temp = md5(password.encode()).hexdigest()
irc_pass = &#34;md5:&#34; + md5(temp.encode()).hexdigest()

try:
await conn.execute(
&#34;UPDATE anope.anope_db_NickCore &#34;
&#34;SET pass = :passwd WHERE display = :display&#34;,
passwd=irc_pass,
display=login
)
except (OperationalError, ProgrammingError):
self._logger.error(&#34;Failure updating NickServ password for %s&#34;, login)

async def command_restore_game_session(self, message):
assert self.player is not None

Expand Down Expand Up @@ -2874,14 +2839,16 @@ <h3>Methods</h3>

username = row.login

new_irc_password = hexlify(os.urandom(16)).decode()
# DEPRECATED: IRC passwords are handled outside of the lobby server.
# This message remains here for backwards compatibility, but the data
# sent is meaningless and can be ignored by clients.
await self.send({
&#34;command&#34;: &#34;irc_password&#34;,
&#34;password&#34;: new_irc_password
&#34;password&#34;: &#34;deprecated&#34;
})

await self.on_player_login(
player_id, username, new_irc_password, unique_id, auth_method
player_id, username, unique_id, auth_method
)</code></pre>
</details>
</dd>
Expand Down Expand Up @@ -3224,7 +3191,7 @@ <h3>Methods</h3>
)

await self.on_player_login(
player_id, username, password, unique_id, &#34;password&#34;
player_id, username, unique_id, &#34;password&#34;
)</code></pre>
</details>
</dd>
Expand Down Expand Up @@ -3791,7 +3758,7 @@ <h3>Methods</h3>
</details>
</dd>
<dt id="server.lobbyconnection.LobbyConnection.on_player_login"><code class="name flex">
<span>async def <span class="ident">on_player_login</span></span>(<span>self, player_id: int, username: str, password: str, unique_id: str, method: str)</span>
<span>async def <span class="ident">on_player_login</span></span>(<span>self, player_id: int, username: str, unique_id: str, method: str)</span>
</code></dt>
<dd>
<div class="desc"></div>
Expand All @@ -3803,7 +3770,6 @@ <h3>Methods</h3>
self,
player_id: int,
username: str,
password: str,
unique_id: str,
method: str
):
Expand Down Expand Up @@ -3835,7 +3801,6 @@ <h3>Methods</h3>
last_login=func.now()
)
)
await self.update_irc_password(conn, username, password)

self.player = Player(
login=username,
Expand Down Expand Up @@ -4046,32 +4011,6 @@ <h1 id="params">Params</h1>
await self.abort(message)</code></pre>
</details>
</dd>
<dt id="server.lobbyconnection.LobbyConnection.update_irc_password"><code class="name flex">
<span>async def <span class="ident">update_irc_password</span></span>(<span>self, conn, login, password)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">async def update_irc_password(self, conn, login, password):
# Since the password is hashed on the client, what we get at this point
# is really md5(md5(sha256(password))). This is entirely insane.
temp = md5(password.encode()).hexdigest()
irc_pass = &#34;md5:&#34; + md5(temp.encode()).hexdigest()

try:
await conn.execute(
&#34;UPDATE anope.anope_db_NickCore &#34;
&#34;SET pass = :passwd WHERE display = :display&#34;,
passwd=irc_pass,
display=login
)
except (OperationalError, ProgrammingError):
self._logger.error(&#34;Failure updating NickServ password for %s&#34;, login)</code></pre>
</details>
</dd>
<dt id="server.lobbyconnection.LobbyConnection.write"><code class="name flex">
<span>def <span class="ident">write</span></span>(<span>self, message)</span>
</code></dt>
Expand Down Expand Up @@ -4207,7 +4146,6 @@ <h4><code><a title="server.lobbyconnection.LobbyConnection" href="#server.lobbyc
<li><code><a title="server.lobbyconnection.LobbyConnection.send_game_list" href="#server.lobbyconnection.LobbyConnection.send_game_list">send_game_list</a></code></li>
<li><code><a title="server.lobbyconnection.LobbyConnection.send_updated_achievements" href="#server.lobbyconnection.LobbyConnection.send_updated_achievements">send_updated_achievements</a></code></li>
<li><code><a title="server.lobbyconnection.LobbyConnection.send_warning" href="#server.lobbyconnection.LobbyConnection.send_warning">send_warning</a></code></li>
<li><code><a title="server.lobbyconnection.LobbyConnection.update_irc_password" href="#server.lobbyconnection.LobbyConnection.update_irc_password">update_irc_password</a></code></li>
<li><code><a title="server.lobbyconnection.LobbyConnection.write" href="#server.lobbyconnection.LobbyConnection.write">write</a></code></li>
<li><code><a title="server.lobbyconnection.LobbyConnection.write_launch_game" href="#server.lobbyconnection.LobbyConnection.write_launch_game">write_launch_game</a></code></li>
<li><code><a title="server.lobbyconnection.LobbyConnection.write_warning" href="#server.lobbyconnection.LobbyConnection.write_warning">write_warning</a></code></li>
Expand Down

0 comments on commit 8a29a01

Please sign in to comment.