feat(launcher): provision, patch and start the PokeMMO client (#161)

This commit is contained in:
Fiereu authored and GitHub committed 2026-08-10 21:01:11 +02:00
1 parent 0385dc8dcf
commit a7e0c38796
56 files changed
+373 -22

No files matched your search

+2 -2
View File
@@ -65,10 +65,10 @@
- codegen/** - codegen/**
- decomp/** - decomp/**
"area: patcher": "area: launcher":
- changed-files: - changed-files:
- any-glob-to-any-file: - any-glob-to-any-file:
- patcher/** - launcher/**
- keys/** - keys/**
"area: build": "area: build":
@@ -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.
+4
View File
@@ -5,6 +5,10 @@ description: How-to guides for working on OpenMMO.
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 - [Writing a code generator](writing-generators/): how to add a new
build-time generator that turns pret decomp data into Kotlin game data. build-time generator that turns pret decomp data into Kotlin game data.
- [Writing overworld scripts](writing-scripts/): where the overworld scripts - [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.
-4
View File
@@ -9,7 +9,3 @@ group=de.fiereu.openmmo
# x-release-please-start-version # x-release-please-start-version
version=0.1.0 version=0.1.0
# x-release-please-end # x-release-please-end
# May be overridden by the user
pokemmo.executable=C:/Program Files/PokeMMO/PokeMMO.exe
pokemmo.workingDir=C:/Program Files/PokeMMO
+5
View File
@@ -22,6 +22,8 @@ typesafe-config = "1.4.9"
dagger = "2.60.1" dagger = "2.60.1"
ksp = "2.3.11" ksp = "2.3.11"
ineter = "0.3.1" ineter = "0.3.1"
compose = "1.11.1"
tomlkt = "0.5.0"
dotenv = "4.0.0" dotenv = "4.0.0"
[libraries] [libraries]
@@ -62,6 +64,7 @@ dagger = { module = "com.google.dagger:dagger", version.ref = "dagger" }
dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "dagger" } dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "dagger" }
mockk = { module = "io.mockk:mockk", version.ref = "mockk" } mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
ineter = { module = "com.github.maltalex:ineter", version.ref = "ineter" } ineter = { module = "com.github.maltalex:ineter", version.ref = "ineter" }
tomlkt = { module = "net.peanuuutz.tomlkt:tomlkt-jvm", version.ref = "tomlkt" }
[bundles] [bundles]
crypto = ["bouncycastle-pkix", "bouncycastle-provider"] crypto = ["bouncycastle-pkix", "bouncycastle-provider"]
@@ -74,3 +77,5 @@ jooq = { id = "org.jooq.jooq-codegen-gradle", version.ref = "jooq" }
flyway = { id = "org.flywaydb.flyway", version.ref = "flyway" } flyway = { id = "org.flywaydb.flyway", version.ref = "flyway" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
dotenv = { id = "co.uzzu.dotenv.gradle", version.ref = "dotenv" } dotenv = { id = "co.uzzu.dotenv.gradle", version.ref = "dotenv" }
compose = { id = "org.jetbrains.compose", version.ref = "compose" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
+1 -1
View File
@@ -7,7 +7,7 @@
## Description ## Description
The keys module is responsible for generating the keys used by the servers for signing packets and by the client for verifying them. The keys module is responsible for generating the keys used by the servers for signing packets and by the client for verifying them.
It generates the public keys that are later used by the patcher module to replace the client's public keys. It generates the public keys that are later used by the launcher module to replace the client's public keys.
> Generated keys are specifically excluded from git commits using `.gitignore` and should not be committed. > Generated keys are specifically excluded from git commits using `.gitignore` and should not be committed.
@@ -1,3 +1,3 @@
Removed on request of pokemmo.eu. Removed on request of pokemmo.eu.
Date: 2026-08-17 Date: 2026-08-17
Nonce: 666b997e54fb4de89c7bf8c413e73791 Nonce: f69dd08f686f43f29ec073b2c2427cb7
@@ -1,3 +1,3 @@
Removed on request of pokemmo.eu. Removed on request of pokemmo.eu.
Date: 2026-08-17 Date: 2026-08-17
Nonce: 02298e034dbe43c8806519586565af31 Nonce: 0e1a35a946954c879a1887634b8e5e3e
@@ -1,3 +1,3 @@
Removed on request of pokemmo.eu. Removed on request of pokemmo.eu.
Date: 2026-08-17 Date: 2026-08-17
Nonce: 046de4127f604c5da3fee2fb911d5770 Nonce: 84eb70ff96eb429f86d98af1bd59587b
@@ -1,3 +1,3 @@
Removed on request of pokemmo.eu. Removed on request of pokemmo.eu.
Date: 2026-08-17 Date: 2026-08-17
Nonce: ac0e4ce718fd4df5a5e7f0d6c55bc2f6 Nonce: 224389821191402e9f4eaf6cd9e3f4ff
@@ -1,3 +1,3 @@
Removed on request of pokemmo.eu. Removed on request of pokemmo.eu.
Date: 2026-08-17 Date: 2026-08-17
Nonce: efb57ec407504b7c8dea8baec60cccb4 Nonce: 481ff40f2bbe4cb6b7cd696511fc099a
@@ -1,3 +1,3 @@
Removed on request of pokemmo.eu. Removed on request of pokemmo.eu.
Date: 2026-08-17 Date: 2026-08-17
Nonce: 884762934db04059872aee9e569d6422 Nonce: e240fe0b590d4a7d82ca22a6cd34b215
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 430fc37898d64ed4887ebbefe47d6baf
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: d5099c1f19144386b364781479a59851
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 3397a241023a45dc8568102adfe56666
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 2ac2c23daaf14082a6d9195977400c59
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: bc35ddd74fe44f439e6c74a7ebabc6d4
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: e516ca1301a04fda8109cde828674b17
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 062a7d552928488d83ef7b9caf25eb4f
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 6ad6add9d76e4c86ac4ccec12670c27a
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 1f4cda5805b646268a19735194ddf2bf
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: f3486c4543f2480284f6f6675e5e8e3a
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 4b556f26f5794e659784bd8826ed953c
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 0ad131cbddcd48d3aadb536060932766
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 469f1a69b6484279981bee8a7148f960
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 4aee6b711c974d9aaf252b869e554d66
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 9d87e8ffc7e2407081f4bf26b52964eb
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 26c236cc4e8e46ddb5f3e0c488a483fa
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 32fc9cde904e4d609decc1ef1aa03ae7
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: ffbbc88a20764b7bb0ccd6c509564ebd
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 0b1c5498e1ab43678542ebe7013fd8a5
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: c66a04afd47c4720b69399f2e67432c8
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: ba14469a3e32468190b5c97d26b709bd
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 69b1bab5eb67490ba99d4873866539e0
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 3d462b1c98ac4f87bffdf766dd1b1cb1
@@ -1,3 +1,3 @@
Removed on request of pokemmo.eu. Removed on request of pokemmo.eu.
Date: 2026-08-17 Date: 2026-08-17
Nonce: 41c150695ef247af96e948424c0c699b Nonce: 13f04ebb52674d399cd373cc9eedba41
@@ -1,3 +1,3 @@
Removed on request of pokemmo.eu. Removed on request of pokemmo.eu.
Date: 2026-08-17 Date: 2026-08-17
Nonce: 68d817da920e40abb55776133586a48f Nonce: 1fbc18b1183f4241b0d711df4d10a9fc
@@ -1,3 +1,3 @@
Removed on request of pokemmo.eu. Removed on request of pokemmo.eu.
Date: 2026-08-17 Date: 2026-08-17
Nonce: 66fdaab931e54ca3889d27ed6e3668ae Nonce: 6ad421d9f349407e94f71d74bb082310
@@ -1,3 +1,3 @@
Removed on request of pokemmo.eu. Removed on request of pokemmo.eu.
Date: 2026-08-17 Date: 2026-08-17
Nonce: 102a4c64afbc4551903da2ab479c60f4 Nonce: f4e1d1b63a264f3c845e160f892910de
@@ -1,3 +1,3 @@
Removed on request of pokemmo.eu. Removed on request of pokemmo.eu.
Date: 2026-08-17 Date: 2026-08-17
Nonce: be582db140fd44c2b8a3e0b2e39d6152 Nonce: ea6f11c72e804a6baebb74c9ff149a3a
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 01998db430534411bae6d3bfe30e4eff
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: e8ac21a278a445f0ab743304631aebb2
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 0aaab9eb67f94d9c9d617148386c00d6
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 620e9345b3f94096bfc624d4f4d0ae50
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 91dfcf1c50b3462bafcabbb26737090a
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 67112c1979d144dc970c3cd41daea5ca
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 44c89144130441679166ed6dcc91058d
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: f864a914a03748a39753a95fca1f2afa
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 353513946c52475c8841fecd368f0500
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: d01f1b3bf0364ad1b0aeac799221127a
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 2982f44371dc4cf3a077af90589acce1
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: c71a7d9aa7f843639b7b685c4198d438
@@ -0,0 +1,3 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 43a1013476f140178af721004bbfef2c
@@ -1,3 +0,0 @@
Removed on request of pokemmo.eu.
Date: 2026-08-17
Nonce: 83616ef24a6849d7bd35ff77cfa88667
+3 -1
View File
@@ -2,6 +2,8 @@ dependencyResolutionManagement {
@Suppress("UnstableApiUsage") @Suppress("UnstableApiUsage")
repositories { repositories {
mavenCentral() mavenCentral()
// Compose Multiplatform pulls its androidx artifacts from here and nowhere else.
google { content { includeGroupByRegex("androidx.*") } }
} }
} }
@@ -12,7 +14,7 @@ plugins {
rootProject.name = "openmmo" rootProject.name = "openmmo"
include(":keys") include(":keys")
include(":patcher") include(":launcher")
include(":common") include(":common")
include(":bytecodec") include(":bytecodec")
include(":common.test") include(":common.test")