ddnet/src/engine/client/serverbrowser_http.h

27 lines
700 B
C
Raw Normal View History

Add client-side HTTP server info Summary ======= The idea of this is that clients will not have to ping each server for server infos which takes long, leaks the client's IP address even to servers the user does not join and is a DoS vector of the game servers for attackers. For the Internet, DDNet and KoG tab, the server list is entirely fetched from the master server, filtering out servers that don't belong into the list. The favorites tab is also supposed to work that way, except for servers that are marked as "also ping this server if it's not in the master server list". The LAN tab continues to broadcast the server info packet to find servers in the LAN. How does it work? ================= The client ships with a list of master server list URLs. On first start, the client checks which of these work and selects the fastest one. Querying the server list is a HTTP GET request on that URL. The response is a JSON document that contains server infos, server addresses as URLs and an approximate location. It can also contain a legacy server list which is a list of bare IP addresses similar to the functionality the old master servers provided via UDP. This allows us to backtrack on the larger update if it won't work out. Lost functionality ================== (also known as user-visible changes) Since the client doesn't ping each server in the list anymore, it has no way of knowing its latency to the servers. This is alleviated a bit by providing an approximate location for each server (continent) so the client only has to know its own location for approximating pings.
2018-07-11 20:46:04 +00:00
#ifndef ENGINE_CLIENT_SERVERBROWSER_HTTP_H
#define ENGINE_CLIENT_SERVERBROWSER_HTTP_H
#include <base/system.h>
class CServerInfo;
class IEngine;
class IServerBrowserHttp
{
public:
virtual ~IServerBrowserHttp() {}
virtual void Update() = 0;
virtual bool IsRefreshing() = 0;
virtual void Refresh() = 0;
virtual int NumServers() const = 0;
virtual const NETADDR &ServerAddress(int Index) const = 0;
virtual void Server(int Index, NETADDR *pAddr, CServerInfo *pInfo) const = 0;
virtual int NumLegacyServers() const = 0;
virtual const NETADDR &LegacyServer(int Index) const = 0;
};
IServerBrowserHttp *CreateServerBrowserHttp(IEngine *pEngine);
#endif // ENGINE_CLIENT_SERVERBROWSER_HTTP_H