EchoTools / EchoRelay

A proof-of-concept reimplementation of Echo VR's web services and dedicated game servers
13 stars 13 forks source link

EchoRelay

This is a fork of 'Xenomega/EchoRelay' which is being actively updated, This fork's aim is to impove on the work of Xenomega's EchoRelay.


EchoRelay is a proof-of-concept reimplementation of Echo VR's web services and dedicated game servers. It was created for educational/research purposes, to explore video game backend infrastructure design and service implementations.

Echo VR's official servers were shut down on August 1st, 2023. EchoRelay established the first networked match since that time, on August 29th, 2023. This project was made public October 31st, 2023.

This project's aim is not to enable unofficial matches for the public, please read the see the Disclaimer section for more information about the project, its aim, goals, and sensitivities.

EchoRelay

"さあ時の扉を開けて行こうよ"

Note: All research was solely done by me (@Xenomega). I am not a participant of any Echo VR community.

Features

The following features are supported by EchoRelay:

Architecture

Design

At a high level, Echo VR's original backend infrastructure can be boiled down to:

  1. Central services: responsible for core services (e.g. account operations) and to discover game servers to match to.
    • LOGIN (websocket): User login, session management, account operations.
    • CONFIG (websocket): Seasonal in-game settings (e.g. season start/end, in-game display banners).
    • MATCHING (websocket): Fulfills client requests for matchmaking with a game server registered with SERVERDB.
    • SERVERDB (websocket): Game server registration and game session management for clients joining through MATCHING.
    • TRANSACTION (websocket): Provides an in-game store and transaction processing.
    • API (HTTP/HTTPS): An API server used to report server status, news, and record additional data.
  2. Dedicated game servers: responsible for actually hosting game lobbies for clients to matchmake to.
    • For the original developers, a special build of the game is presumably built, which exposes routines that run Echo VR in dedicated server mode.
    • Dedicated game servers load a pnsradgameserver.dll library from the game folder after startup (if it exists). This library satisfies an interface for the game to register and communicate with SERVERDB and coordinate game sessions/matching.
    • Game servers register themselves through the SERVERDB service, and clients matchmake to a game server through the MATCHING service (invoking further communication between SERVERDB and the dedicated game server to accept the client).
    • Clients connect to a UDP port exposed on dedicated game servers, exposed to them by MATCHING.

Implementation

EchoRelay provides a C#.NET implementation of the abovementioned central services, and a library + patches to run the Echo VR game as a game server. Each project directory contains its own README with additional information:

  1. Central services:

    • EchoRelay.Core: A C#.NET library providing an implementation of the central server with supported services.
    • EchoRelay.App: A simple C#.NET WinForms UI app providing visual configuration, operation, and monitoring of a central server powered by EchoRelay.Core.
    • EchoRelay.Cli: A simple C#.NET CLI (command-line interface) tool, providing lightweight options to deploy and operate a server powered by EchoRelay.Core.
  2. Dedicated game servers:

    • EchoRelay.Patch: A C++ library to be loaded alongside Echo VR. It applies patches to the game on startup, enabling additional CLI commands in Echo VR (e.g. -server, required to operate a game server).
    • EchoRelay.GameServer: A C++ library which reimplements the interface the game expects from pnsradgameserver.dll. It accepts requests to register the game server, listens for websocket messages from SERVERDB such as starting a new session, accepting new players, rejecting/kicking a player, etc.
    • This introduces unofficial websocket messages, likely similar to the original pnsradgameserver.dll, but specific to EchoRelay.Core's central service reimplementation.

Installation

This section discusses end-to-end installation of the system. However, if EchoRelay servers are already operational, a minimal client setup only requires a single JSON file provided by the server operator to be saved in the client's game folder, as noted in the later Setting up clients section.

Requirements

Fetching binaries

You must acquire built libraries and executables for EchoRelay to install them. There are two options:

  1. Pre-compiled binaries
    • Ensure you have the .NET 7.0 runtime installed.
    • Download pre-compiled binaries from the Releases page of this repository.
      • Central services can be run on any platform via EchoRelay.Cli. Windows additionally supports EchoRelay.App for a basic UI version.
      • Game server operation requires Echo VR, and thus is Windows-only.
  2. Building from source code
    • Ensure you have Windows 10+, .NET 7.0 SDK, and Microsoft Visual Studio 2022 with C# and C++ (vc143) support installed.
    • Clone this repository and open the solution (.sln) file in Visual Studio.
    • Build the solution, it should succeed without any errors.
      • If you encounter an error related to a missing MSDetours dependency, manually install the MSDetours 4.0.1 nuget package to the EchoRelay.Patch project.
    • Rename EchoRelay.Patch.dll -> dbgcore.dll, and rename EchoRelay.GameServer.dll -> pnsradgameserver.dll.
    • Note: EchoRelay.Cli and EchoRelay.Core can be built for other platforms by simply running the dotnet build command, after installing the .NET 7.0 SDK.

Setting up central services

As the name suggests, central services are the main central endpoint which all clients/game servers will connect to (e.g. for logging in, matchmaking, discovery and registration of game servers). It should be at a stable/static IP.

Option 1: Using the WinForms UI app

  1. Run EchoRelay.App as an administrator. It will ask you to configure a storage folder and locate the Echo VR game executable. Note the TCP port number you set here.
  2. Within the application, click the button with the "Play" icon to start the server, if it isn't started/listening already.
  3. The application should now display a generated "service config" containing your endpoints necessary to connect to the server. Copy or save this.
  4. Ensure access controls are appropriately set in the Storage->Access Controls tab of the application, to prevent unwanted connections from being established.

Option 2: Using the command-line app

  1. Run EchoRelay.Cli as an administrator, with the argument -d providing an existing, but empty storage directory for server resources, -p for TCP port (default 777), etc.
    • For more command options, run EchoRelay.Cli --help or read the project's README.
  2. When the server starts, it should output some information such as a service config. Either copy this, or use the --outputconfig argument to save it to a file.

Port forwarding

The central server should stay running for all services to work. The same storage folder should be used each time for persistent data across server restarts.

Setting up game servers

After central services are set up, you'll want to stand up some game servers. They will register themselves to central services, and central services will then use them to matchmake clients to. Game servers can run on machines independent on the central services, so long as they have the correct service config file, with the correct SERVERDB API key.

  1. Copy dbgcore.dll and pnsradgameserver.dll into your game folder where echovr.exe is located.
  2. The central services/server operator should provide game server operators with the service config generated by their central server (from Step 3 of their setup). It should be saved to ready-at-dawn-echo-arena/_local/config.json.
    • You should update the displayname and auth parameters of the login service URI to values personal to your account, as specified by the FAQs section of this document.
  3. Look at ready-at-dawn-echo-arena\sourcedb\rad15\json\r14\config\netconfig_dedicatedserver.json, and note the port and retries JSON keys.
    • port will be the first UDP port that game servers you start will try to bind to. If they fail, they will increase the port number for as many retries as defined, and try again.
      • e.g. With a port of 1234 and a retries set to 10, game servers will bind to the first available UDP port in the range: 1234-1244
    • You may wish to increase retries in the previous step to a larger number. This will avoid multiple game servers/clients reserving all these ports. Note that netconfig_client.json is configured by default to also reserve one of these ports from the same range when a client is run.
  4. Port forward the UDP game server port range on your router (and Windows/software firewalls, if enabled). Ensure the external port matches the internal port when forwarding.

Every central server should have at least two game servers running: one for your player's current lobby, another for the player to transition to a new lobby with a new gametype.

Setting up clients

This section describes the setup required to get a player connected to a configured EchoRelay network:

  1. The central services/server operator should provide clients with the service config generated by their central server app (in Step 3 of their setup). It should be saved to ready-at-dawn-echo-arena/_local/config.json in the client's game folder.
    • If a machine is meant to run client-only, the serverdb_host key in the service config should not be provided by the server operator, and they should enforce API key authentication to protect against unauthenticated game servers.
    • Clients should update the displayname and auth parameters of the login service URI to values personal to their account, as specified by the FAQs section of this document.

Playing Echo VR

Now your EchoRelay central services should be operational, game servers and clients should be configured to connect and matchmake to eachother!

Disclaimer

This project is not intended to host unofficial services for the public, nor is it reflective of what true infrastructure might look like (e.g. use of a real web framework such as ASP.NET, integration with IIS, real database support, logging, monitoring, cloud-scalable/elastic microservices, secrets management, load balancing, rate limiting, isolation, etc).

Instead, EchoRelay aims to provide a lightweight and portable proof-of-concept which shows the results of my work to those similarly interested in exploring these topics for research/educational purposes. The proof-of-concept has been publicized so it can be potentially referenced in a future document detailing design considerations for game server architecture and sharing reverse engineering techniques for those looking to educate themselves.

Echo VR is an online-enabled, free-to-play game which had its online services retired on August 1, 2023. Its compiled binaries do not employ anti-cheat mechanisms or any meaningful security mitigations. This made it an ideal target for me to explore the topic without introducing risk to an active online ecosystem or its users.

This project was developed with additional considerations to uphold ethical integrity and ensure fair-use:

TLDR: If you're not looking to explore reverse engineering techniques or server/service implementations as a personal researcher, this project is not meant for you. It should not be thought of as a feature-complete or bug-free server solution.

FAQs

Will this be regularly maintained, and supported?

Why so many components? Why not simplify it?

Why only the PC VR version of the game? Why not the Quest APK?

What are the displayname and auth parameters in the LOGIN service endpoint?

What is API key authentication for SERVERDB?

Why do I need to port forward and use external IPs?

Why don't central services leverage SSL/TLS?

Will EchoRelay overwrite my profile prior to the official server shutdown?

Is it possible to restore profiles prior to official server shutdown?

Why is my game in a persistently broken state (e.g. permanently 'ghosted', persistently "failed to connect" to a specific gametype, etc)?

Can I use your code in my own projects?

Shoutouts

Thanks to (@Xenomega for creating this project and for bringing EchoVR back.

Thanks to @dualgame for information about how different user flows are expected to work, you were a tremendous help in providing context, so this could be reimplemented and operate as expected.