Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/#676 remove python version check #677

Merged
merged 8 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 3 additions & 34 deletions server/lobbyconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import aiohttp
import humanize
import pymysql
import semver
from sqlalchemy import and_, func, select

import server.metrics as metrics
Expand Down Expand Up @@ -454,14 +453,7 @@ def _set_user_agent_and_version(self, user_agent, version):
metrics.user_agent_version.labels(str(version)).inc()
self._version = version

async def _check_version(self):
versionDB, updateFile = self.player_service.client_version_info
update_msg = {
"command": "update",
"update": updateFile,
"new_version": versionDB
}

async def _check_user_agent(self):
if not self.user_agent or "downlords-faf-client" not in self.user_agent:
await self.send_warning(
"You are using an unofficial client version! "
Expand All @@ -471,28 +463,6 @@ async def _check_version(self):
f'<a href="{config.WWW_URL}">{config.WWW_URL}</a>'
)

if not self._version or not self.user_agent:
update_msg["command"] = "welcome"
# For compatibility with 0.10.x updating mechanism
await self.send(update_msg)
return False

# Check their client is reporting the right version number.
if "downlords-faf-client" not in self.user_agent:
try:
version = self._version
if "-" in version:
version = version.split("-")[0]
if "+" in version:
version = version.split("+")[0]
if semver.compare(versionDB, version) > 0:
await self.send(update_msg)
return False
except ValueError:
await self.send(update_msg)
return False
return True

async def check_policy_conformity(self, player_id, uid_hash, session, ignore_result=False):
if not config.USE_POLICY_SERVER:
return True
Expand Down Expand Up @@ -738,9 +708,8 @@ async def command_ask_session(self, message):
user_agent = message.get("user_agent")
version = message.get("version")
self._set_user_agent_and_version(user_agent, version)

if await self._check_version():
await self.send({"command": "session", "session": self.session})
await self._check_user_agent()
await self.send({"command": "session", "session": self.session})

async def command_avatar(self, message):
action = message["action"]
Expand Down
9 changes: 0 additions & 9 deletions server/player_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def __init__(self, database: FAFDatabase):

# Static-ish data fields.
self.uniqueid_exempt = {}
self.client_version_info = ("0.0.0", None)
self._dirty_players = set()

async def initialize(self) -> None:
Expand Down Expand Up @@ -256,14 +255,6 @@ async def update_data(self):
rows = await result.fetchall()
self.uniqueid_exempt = frozenset(map(lambda x: x[0], rows))

# Client version number
result = await conn.execute(
"SELECT version, file FROM version_lobby ORDER BY id DESC LIMIT 1"
)
row = await result.fetchone()
if row is not None:
self.client_version_info = (row[0], row[1])

async def shutdown(self):
tasks = []
for player in self:
Expand Down
3 changes: 0 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ def pytest_configure(config):
config.addinivalue_line(
"markers", "slow: marks tests as slow (deselect with '-m \"not slow\"')"
)
config.addinivalue_line(
"filterwarnings", "ignore:Function 'semver.compare':DeprecationWarning"
)


@pytest.fixture(scope="session", autouse=True)
Expand Down
3 changes: 0 additions & 3 deletions tests/data/test-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ insert into unique_id_users (user_id, uniqueid_hash) values (1, 'some_id');
insert into unique_id_users (user_id, uniqueid_hash) values (2, 'another_id');
insert into unique_id_users (user_id, uniqueid_hash) values (3, 'some_id');

-- Lobby version table
insert into version_lobby (id, `file`, version) values (1, 'some-installer.msi', '0.10.125');

-- Sample maps
insert into map (id, display_name, map_type, battle_type, author) values
(1, 'SCMP_001', 'FFA', 'skirmish', 1),
Expand Down
2 changes: 0 additions & 2 deletions tests/unit_tests/test_player_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ async def test_mark_dirty(player_factory, player_service):

async def test_update_data(player_factory, player_service):
await player_service.update_data()

assert player_service.is_uniqueid_exempt(1) is True
assert player_service.client_version_info == ("0.10.125", "some-installer.msi")


async def test_broadcast_shutdown(player_factory, player_service):
Expand Down