diff --git a/master_server/database/dynamodb.py b/master_server/database/dynamodb.py index 52abf23..b6ad14a 100644 --- a/master_server/database/dynamodb.py +++ b/master_server/database/dynamodb.py @@ -42,23 +42,23 @@ def _get_server_id(server_ip, server_port): def _convert_server_to_dict(server): entry = { "info": {}, - "time_first_seen": server.time_first_seen, - "time_last_seen": server.time_last_seen, - "online": server.online, } if server.ipv4: entry["ipv4"] = { "ip": str(server.ipv4.ip), "port": server.ipv4.port, - "server_id": _get_server_id(server.ipv4.ip, server.ipv4.port), } + entry["server_id"] = _get_server_id(server.ipv4.ip, server.ipv4.port) + if server.ipv6: entry["ipv6"] = { "ip": str(server.ipv6.ip), "port": server.ipv6.port, - "server_id": _get_server_id(server.ipv6.ip, server.ipv6.port), } + # Make sure the IPv4 variant always wins. + if "server_id" not in entry: + entry["server_id"] = _get_server_id(server.ipv6.ip, server.ipv6.port) for name, _ in getmembers(InfoMap, lambda o: isinstance(o, Attribute)): if name == "newgrfs": diff --git a/master_server/database/redis.py b/master_server/database/redis.py index e8552e5..aceb0e3 100644 --- a/master_server/database/redis.py +++ b/master_server/database/redis.py @@ -133,7 +133,7 @@ async def get_server_info_for_web(self, server_id): entry = { "info": info, - "online": True, + "server_id": server_id, } direct_ipv4_str = await self._redis.get(f"gc-direct-ipv4:{server_id}") @@ -142,7 +142,6 @@ async def get_server_info_for_web(self, server_id): entry["ipv4"] = { "ip": direct_ipv4["ip"], "port": direct_ipv4["port"], - "server_id": server_id, } direct_ipv6_str = await self._redis.get(f"gc-direct-ipv6:{server_id}") @@ -151,7 +150,6 @@ async def get_server_info_for_web(self, server_id): entry["ipv6"] = { "ip": direct_ipv6["ip"], "port": direct_ipv6["port"], - "server_id": server_id, } return entry