feat(launcher): provision, patch and start the PokeMMO client (#161)
This commit is contained in:
1 parent
0385dc8dcf
commit
a7e0c38796
56 files changed
+373
-22
No files matched your search
@@ -0,0 +1,159 @@
|
||||
---
|
||||
title: Deploying the feed and the launcher
|
||||
description: How to publish the OpenMMO feed and build a launcher that trusts it.
|
||||
---
|
||||
|
||||
Players run a launcher. The launcher downloads a PokeMMO client, patches it, and
|
||||
starts it. To know which server to send the client to, it needs a feed.
|
||||
|
||||
The feed is a handful of static files on a web host. The launcher is built once
|
||||
and points at that host. This guide sets up both.
|
||||
|
||||
For local work you need none of this. `./gradlew :launcher:dev` serves a feed on
|
||||
loopback and starts the launcher against it. See
|
||||
[Running the game client](../running-the-client/).
|
||||
|
||||
## What the feed holds
|
||||
|
||||
| File | Read by | Purpose |
|
||||
|------|---------|---------|
|
||||
| `main.xml` | the client | Which login server to use, and at which revision. |
|
||||
| `main.sig256` | the client | Signature of `main.xml`. |
|
||||
| `news.xml` | the client | The news panel on the client's login screen. |
|
||||
| `game.public.pem` | the launcher | The server's root key, patched into the client. |
|
||||
| `game.public.pem.sig256` | the launcher | Signature of `game.public.pem`. |
|
||||
| `feed.public.pem` | nobody | Published so anyone can check the signatures. |
|
||||
|
||||
The client reads its files directly, because the launcher rewrites the PokeMMO
|
||||
urls inside the client to point here. The launcher reads the server key so it
|
||||
can patch it in.
|
||||
|
||||
## Why the files are signed
|
||||
|
||||
The client and the launcher each trust exactly one key, and that key is
|
||||
compiled into them. Everything else is checked against it.
|
||||
|
||||
TLS alone would not be enough. TLS proves you are talking to the right web host,
|
||||
but it does not prove the host is honest. Anyone who could write to the host
|
||||
could hand out a different server address or a different server key, and the
|
||||
client would follow it. A signature made with a key the host never holds closes
|
||||
that gap. If a signature does not check out, the launcher refuses to patch and
|
||||
the client refuses to start.
|
||||
|
||||
## Set the feed up once
|
||||
|
||||
### 1. Make the feed key pair
|
||||
|
||||
```bash
|
||||
./gradlew :keys:generateFeed
|
||||
```
|
||||
|
||||
This writes `keys/build/feed.private.pem` and `keys/build/feed.public.pem`.
|
||||
|
||||
Keep the private key out of git and somewhere safe. Losing it means every
|
||||
launcher already out there stops trusting your feed, and the only fix is a new
|
||||
launcher release.
|
||||
|
||||
The key is RSA-3072 and has to stay that size. The launcher writes it over
|
||||
PokeMMO's key inside the client binary, and a replacement can be padded but
|
||||
never shortened.
|
||||
|
||||
### 2. Create the repository
|
||||
|
||||
Put the files in the root of a repository and turn on GitHub Pages. Add a
|
||||
`CNAME` file holding the domain, then add a DNS CNAME record pointing that
|
||||
domain at the Pages host. Wait for the certificate to be issued before testing.
|
||||
|
||||
Add a `.gitattributes` with this line:
|
||||
|
||||
```
|
||||
* -text
|
||||
```
|
||||
|
||||
The files are signed byte for byte. Without that line git may rewrite line
|
||||
endings on checkout, the bytes stop matching the signature, and every launcher
|
||||
rejects the feed.
|
||||
|
||||
### 3. Write `main.xml`
|
||||
|
||||
Start from `launcher/src/main/resources/main_feed_template.xml` and fill in
|
||||
three things:
|
||||
|
||||
- `ip` and `ip_cn`: the hostname of your login server
|
||||
- `port`: the login server port, which is `2106` by default
|
||||
- `revision`: the client revision, which must match a patch manifest in
|
||||
`launcher/manifests/`
|
||||
|
||||
Leave the updater and android entries alone. The client reads them but the
|
||||
launcher does the updating, so the zeroed hashes are fine.
|
||||
|
||||
### 4. Sign it
|
||||
|
||||
```bash
|
||||
openssl dgst -sha256 -sign feed.private.pem -out main.sig256 main.xml
|
||||
```
|
||||
|
||||
Re-run this every time you edit `main.xml`. An old signature is the same to the
|
||||
client as a forged one.
|
||||
|
||||
### 5. Publish the server key
|
||||
|
||||
Copy the login server's public root key into the repository as
|
||||
`game.public.pem` and sign it the same way:
|
||||
|
||||
```bash
|
||||
openssl dgst -sha256 -sign feed.private.pem -out game.public.pem.sig256 game.public.pem
|
||||
```
|
||||
|
||||
Publish only the public half. The private key belongs on the server and nowhere
|
||||
else.
|
||||
|
||||
### 6. Keep the names short
|
||||
|
||||
Use `main.xml` and `news.xml`, not longer names. The launcher rewrites urls that
|
||||
are already compiled into the client, and a replacement can be padded but never
|
||||
shortened. A longer name simply will not fit.
|
||||
|
||||
## Build the launcher
|
||||
|
||||
Put the published `feed.public.pem` in `keys/build/` so the build bakes the
|
||||
right key in, then build with the feed origin:
|
||||
|
||||
```bash
|
||||
./gradlew :launcher:packageDistributionForCurrentOS \
|
||||
-Popenmmo.feedOrigin=https://feed.openmmo.dev
|
||||
```
|
||||
|
||||
Without the property the launcher points at the loopback dev feed, which is
|
||||
what you want for development and never for a release.
|
||||
|
||||
Two keys go in at build time, and they behave differently. The feed key is
|
||||
baked in and can only be changed by shipping a new launcher. The server key is
|
||||
fetched from the feed on every run, so rotating it is a feed change and needs no
|
||||
new release.
|
||||
|
||||
## Check it worked
|
||||
|
||||
Start the launcher and press Play. In the client log you want to see:
|
||||
|
||||
```
|
||||
Loaded Main Feed from mirror 0
|
||||
```
|
||||
|
||||
If you see `Error verifying SHA256withRSA feed signature` instead, the client
|
||||
fetched your feed but did not trust it. Either `main.sig256` is stale, or the
|
||||
launcher was built with a different `feed.public.pem` than the one that signed
|
||||
it.
|
||||
|
||||
If the client loads the feed and then logs `Failed to verify signature` while
|
||||
connecting, the feed and the launcher are fine but the server key is wrong.
|
||||
Check that `game.public.pem` is the key the login server actually runs with.
|
||||
|
||||
## When things change
|
||||
|
||||
- **New client revision.** Add a manifest under `launcher/manifests/`, update
|
||||
`revision` in `main.xml`, and re-sign it.
|
||||
- **Server key rotated.** Publish the new `game.public.pem` and its signature.
|
||||
Launchers pick it up on the next run.
|
||||
- **Feed key rotated.** Re-sign every file and ship a new launcher release,
|
||||
because the old one still trusts the old key.
|
||||
@@ -5,6 +5,10 @@ description: How-to guides for working on OpenMMO.
|
||||
|
||||
How-to guides for working on OpenMMO.
|
||||
|
||||
- [Running the game client](running-the-client/): how the launcher downloads a
|
||||
PokeMMO client, patches it, and points it at an OpenMMO server.
|
||||
- [Deploying the feed and the launcher](deploying-the-feed/): how to publish the
|
||||
feed players connect through, and build a launcher that trusts it.
|
||||
- [Writing a code generator](writing-generators/): how to add a new
|
||||
build-time generator that turns pret decomp data into Kotlin game data.
|
||||
- [Writing overworld scripts](writing-scripts/): where the overworld scripts
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
title: Running the game client
|
||||
description: How the launcher downloads a PokeMMO client, patches it, and points it at an OpenMMO server.
|
||||
---
|
||||
|
||||
The launcher gets a PokeMMO client from the official servers, patches it, and
|
||||
starts it. It works in its own folder and never touches a PokeMMO install you
|
||||
already have.
|
||||
|
||||
## Start it
|
||||
|
||||
Run the servers first, then:
|
||||
|
||||
```bash
|
||||
./gradlew :launcher:dev
|
||||
```
|
||||
|
||||
This does two things. It serves a feed on `https://127.0.0.1:20443`, and it opens
|
||||
the launcher window. Press Play, and the client starts.
|
||||
|
||||
Leave the command running while you play. The client reads the feed the whole
|
||||
time it is open, so stopping it too early breaks the game. The launcher itself
|
||||
closes as soon as the client is up, which is normal.
|
||||
|
||||
## What ends up where
|
||||
|
||||
Everything lives under `%LOCALAPPDATA%/OpenMMO`, or the XDG equivalent on Linux
|
||||
and macOS.
|
||||
|
||||
| Folder | What is in it |
|
||||
|--------|---------------|
|
||||
| `client` | Exactly what PokeMMO publishes, checked against their hashes. |
|
||||
| `runtime` | The patched copy the game runs from. Rebuilt on every launch. |
|
||||
|
||||
The two are kept apart so a broken file can always be repaired from a known good
|
||||
copy. Files no patch touches are hard linked, so the second folder costs almost
|
||||
no disk.
|
||||
|
||||
The client writes its own settings and ROM paths into `runtime`, and those are
|
||||
left alone when the folder is rebuilt.
|
||||
|
||||
## Why the client trusts us
|
||||
|
||||
The client will not start without a feed, and it checks that feed against a key
|
||||
built into it. The launcher patches our key over theirs, so the client accepts a
|
||||
feed we signed.
|
||||
|
||||
In development that feed comes from the server `:launcher:dev` runs. A released
|
||||
launcher reads the published one instead:
|
||||
|
||||
```bash
|
||||
./gradlew :launcher:createDistributable -Popenmmo.feedOrigin=https://feed.openmmo.dev
|
||||
```
|
||||
|
||||
## Adding a patch
|
||||
|
||||
Patches live in `launcher/manifests/manifest-<revision>.toml`, one file per
|
||||
client version. A patch that no longer matches fails the launch and names
|
||||
itself, so a client update never corrupts anything quietly.
|
||||
|
||||
```toml
|
||||
[[patches]]
|
||||
type = "binary_string"
|
||||
name = "SupportUrl"
|
||||
target = "@client"
|
||||
find = "https://support.pokemmo.com"
|
||||
replace = "https://support.openmmo.dev"
|
||||
```
|
||||
|
||||
`target = "@client"` means the game binary, whatever it is called on this
|
||||
platform.
|
||||
|
||||
**A replacement must be exactly as long as the text it replaces.** The client
|
||||
stores the length of every string separately, so a longer one cannot fit and a
|
||||
shorter one leaves rubbish behind. For a url you can pad the end with `?xxx`,
|
||||
which servers ignore.
|
||||
|
||||
Two other patch types exist. `strings` adds lines to `data/strings/strings_*.xml`
|
||||
using ids from 1000000000 up, which is above anything PokeMMO uses. `file` writes
|
||||
a whole file from an asset next to the manifest.
|
||||
Reference in new issue
Block a user