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

Remove Coturn brokering #982

Merged
merged 1 commit into from
Nov 12, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ SESSION: QString

##### ICE Servers

- `{command: ice_servers}`: Send ICE TURN/STUN servers - Returns: `{command: ice_servers, : <ice servers>, date_created: <date token was created in ISO 8601 format>, ttl: <ttl in seconds>}`
- (deprecated) `{command: ice_servers}`: Send ICE TURN/STUN servers - Returns: `{command: ice_servers, : <ice servers>, date_created: <date token was created in ISO 8601 format>, ttl: <ttl in seconds>}`

#### Parties
- `{command: invite_to_party, recipient_id: <...>}`: Invite this player to a party
Expand Down
14 changes: 0 additions & 14 deletions integration_tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@ async def test_ping(client_factory):
await client.read_until_command("pong", timeout=5)


async def test_ice_servers(client_factory):
client, _ = await client_factory.login("test")

await client.send_command("ice_servers")
msg = await client.read_until_command("ice_servers")

assert msg["ttl"] > 60
assert msg["ice_servers"]
for server in msg["ice_servers"]:
assert server["urls"]
assert server["username"]
assert server["credential"]
Askaholic marked this conversation as resolved.
Show resolved Hide resolved


async def test_matchmaker_info(client_factory):
client, _ = await client_factory.login("test")

Expand Down
4 changes: 2 additions & 2 deletions server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
using the Interactive Connectivity Establishment (ICE) protocol, using the
lobby server as a medium of exchanging candidate addresses between clients. If
clients require a relay in order to connect to eachother, they will
authenticate with a separate coturn server using credentials supplied by the
lobby server.
authenticate with a separate sturn or turn server using credentials supplied
by a separate API service.

## Achievements
When a game ends, each client will report a summary of the game in the form of
Expand Down
3 changes: 0 additions & 3 deletions server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ def __init__(self):
self.MINORITY_BONUS = 1
self.MINORITY_BONUS_RATING_RANGE = 1250

self.COTURN_HOSTS = []
self.COTURN_KEYS = []

self.GEO_IP_DATABASE_PATH = "GeoLite2-Country.mmdb"
self.GEO_IP_DATABASE_URL = "https://download.maxmind.com/app/geoip_download"
self.GEO_IP_LICENSE_KEY = ""
Expand Down
3 changes: 0 additions & 3 deletions server/ice_servers/__init__.py

This file was deleted.

51 changes: 0 additions & 51 deletions server/ice_servers/coturn.py

This file was deleted.

14 changes: 4 additions & 10 deletions server/lobbyconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
VisibilityState
)
from .geoip_service import GeoIpService
from .ice_servers.coturn import CoturnHMAC
from .ladder_service import LadderService
from .oauth_service import OAuthService
from .party_service import PartyService
Expand Down Expand Up @@ -80,7 +79,6 @@ def __init__(
self.geoip_service = geoip
self.game_service = game_service
self.player_service = players
self.coturn_generator = CoturnHMAC(config.COTURN_HOSTS, config.COTURN_KEYS)
self.ladder_service = ladder_service
self.party_service = party_service
self.rating_service = rating_service
Expand Down Expand Up @@ -1139,20 +1137,16 @@ async def command_modvault(self, message):
else:
raise ValueError("invalid type argument")

# DEPRECATED: ICE servers are handled outside of the lobby server.
# This message remains here for backwards compatibility, but the list
# of servers will always be empty.
async def command_ice_servers(self, message):
if not self.player:
return

ttl = 86400
ice_servers = self.coturn_generator.server_tokens(
username=self.player.id,
ttl=ttl
)

await self.send({
"command": "ice_servers",
"ice_servers": ice_servers,
"ttl": ttl
"ice_servers": [],
})

@player_idle("invite a player")
Expand Down
21 changes: 0 additions & 21 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import gc
import logging
from contextlib import asynccontextmanager, contextmanager
from typing import Iterable
from unittest import mock

import hypothesis
Expand Down Expand Up @@ -427,23 +426,3 @@ def oauth_service():
@pytest.fixture
def game_stats_service(event_service, achievement_service):
return GameStatsService(event_service, achievement_service)


@pytest.fixture
def coturn_hosts() -> Iterable[str]:
return ["a", "b", "c", "d"]


@pytest.fixture
def coturn_keys(coturn_hosts) -> Iterable[str]:
return [f"secret_{host}" for host in coturn_hosts]


@pytest.fixture
def coturn_credentials() -> Iterable[str]:
return [
"mO/6NHZaG4fwCf7mVuaWNRS7Atw=",
"uSjJUafCX3fEQTGK3NI+mUe6UDo=",
"I5BcpufNrBb4JDj80KY/7VATNis=",
"4wYEgoPz2MHf35Fva8NWulI3vVU="
]
3 changes: 0 additions & 3 deletions tests/data/test_conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ NEWBIE_BASE_MEAN: 500
NEWBIE_MIN_GAMES: 10
TOP_PLAYER_MIN_RATING: 1600

COTURN_HOSTS: []
COTURN_KEYS: []

GEO_IP_DATABASE_PATH: "GeoLite2-Country.mmdb"
GEO_IP_DATABASE_URL: "https://download.maxmind.com/app/geoip_download"
GEO_IP_LICENSE_KEY: ""
Expand Down
3 changes: 1 addition & 2 deletions tests/integration_tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,8 +764,7 @@ async def test_ice_servers_empty(lobby_server):
# By default the server config should not have any ice servers
assert msg == {
"command": "ice_servers",
"ice_servers": [],
"ttl": 86400
"ice_servers": []
}


Expand Down
35 changes: 0 additions & 35 deletions tests/unit_tests/test_ice.py

This file was deleted.

6 changes: 1 addition & 5 deletions tests/unit_tests/test_lobbyconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,16 +689,12 @@ async def test_command_ice_servers(
lobbyconnection: LobbyConnection,
):
lobbyconnection.send = mock.AsyncMock()
lobbyconnection.coturn_generator.server_tokens = mock.Mock(
return_value=["coturn_tokens"]
)

await lobbyconnection.on_message_received({"command": "ice_servers"})

lobbyconnection.send.assert_called_once_with({
"command": "ice_servers",
"ice_servers": ["coturn_tokens"],
"ttl": 86400,
"ice_servers": [],
})


Expand Down