mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 19:25:56 +00:00
Compare commits
150
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bbf16ed4f | ||
|
|
324e9810cc | ||
|
|
1aade1dcf9 | ||
|
|
787549237f | ||
|
|
088cd05e4f | ||
|
|
dc97095bd6 | ||
|
|
c6d8e5554d | ||
|
|
0900a4a143 | ||
|
|
eeb102e260 | ||
|
|
ea376a66d3 | ||
|
|
88747c8da1 | ||
|
|
8e1eb825df | ||
|
|
4fcf0dde3f | ||
|
|
e4791fc45c | ||
|
|
f55a9fb42b | ||
|
|
8ad06fd78a | ||
|
|
af82963f35 | ||
|
|
321ac597ce | ||
|
|
925a81f4f2 | ||
|
|
df1901ea90 | ||
|
|
569d5fffc4 | ||
|
|
7888dbc763 | ||
|
|
f0e8a8c12f | ||
|
|
af5a9717d4 | ||
|
|
bf2fffcffa | ||
|
|
4a99dd3a6a | ||
|
|
306003b698 | ||
|
|
d9be2b9d82 | ||
|
|
81b040ef02 | ||
|
|
5fdee1d658 | ||
|
|
4e1f548012 | ||
|
|
b3ee94071d | ||
|
|
76dc7452de | ||
|
|
02e3a9e4e6 | ||
|
|
8addc97bc5 | ||
|
|
57807b9769 | ||
|
|
7e29a9f2ec | ||
|
|
af9f148889 | ||
|
|
92385cf569 | ||
|
|
b00e732c7f | ||
|
|
594bdee594 | ||
|
|
d4408a0e92 | ||
|
|
b61a186470 | ||
|
|
9e9778af74 | ||
|
|
d5f1e9cc83 | ||
|
|
aa25e9c721 | ||
|
|
1fd3a5482e | ||
|
|
2715170622 | ||
|
|
8801c6f308 | ||
|
|
341f2f0230 | ||
|
|
4d59ce8cb1 | ||
|
|
de90418e84 | ||
|
|
3b75d37ce4 | ||
|
|
1bc4060121 | ||
|
|
6038eacea5 | ||
|
|
83e87d49fc | ||
|
|
0189e3eebf | ||
|
|
5544d62c23 | ||
|
|
93784af0d9 | ||
|
|
ff09d3d056 | ||
|
|
ed2b1291cb | ||
|
|
e033cfbc92 | ||
|
|
154fdfb0e9 | ||
|
|
79e9e85fac | ||
|
|
a48717340b | ||
|
|
351ace1c56 | ||
|
|
ba143e1ccd | ||
|
|
5343020bed | ||
|
|
9d135765cd | ||
|
|
58a99f0a6d | ||
|
|
d9c10c4564 | ||
|
|
8d2befd7f0 | ||
|
|
8d9dc47fed | ||
|
|
5796cffb5e | ||
|
|
112cb7e69c | ||
|
|
517e04dace | ||
|
|
e87cd0bb78 | ||
|
|
d22ff09ac6 | ||
|
|
407bfe3a4d | ||
|
|
5012f7b104 | ||
|
|
16c3b1ec57 | ||
|
|
57ec6892aa | ||
|
|
344d9772b0 | ||
|
|
e27357d1b0 | ||
|
|
40213213bd | ||
|
|
0e62be5097 | ||
|
|
36d82ecc78 | ||
|
|
354a7d83f8 | ||
|
|
86f5bcc007 | ||
|
|
d0d7639026 | ||
|
|
f40c0e1324 | ||
|
|
65df660484 | ||
|
|
2defb7b002 | ||
|
|
df102f16fa | ||
|
|
5963e97c59 | ||
|
|
e60b5e2e5a | ||
|
|
d828c982de | ||
|
|
453b870914 | ||
|
|
9d570b7688 | ||
|
|
e035f33fc0 | ||
|
|
2b95553168 | ||
|
|
2561e85893 | ||
|
|
51e0f136d6 | ||
|
|
b69fa6b867 | ||
|
|
64b3511436 | ||
|
|
f6ac5c93d9 | ||
|
|
21d54c1431 | ||
|
|
ad39bd2020 | ||
|
|
65ace578f7 | ||
|
|
6e438cfe95 | ||
|
|
c743157b97 | ||
|
|
1dc212968d | ||
|
|
42c05c50e7 | ||
|
|
461ffddd0d | ||
|
|
2caa687490 | ||
|
|
71e1488336 | ||
|
|
6fa3c9ccf4 | ||
|
|
95ab5dd9ef | ||
|
|
e39cecb333 | ||
|
|
3e57d32c90 | ||
|
|
d968f6bfd6 | ||
|
|
1267bcc41e | ||
|
|
ec40f146aa | ||
|
|
d05bfe8b09 | ||
|
|
d41a7c7494 | ||
|
|
5abba832e5 | ||
|
|
aab0c28e1a | ||
|
|
c36aaeca74 | ||
|
|
9009550510 | ||
|
|
c2e4634367 | ||
|
|
ffb1df3fce | ||
|
|
426808527b | ||
|
|
297bd39101 | ||
|
|
35a2d5dea7 | ||
|
|
f6006edfaf | ||
|
|
843eb9b2eb | ||
|
|
b2b2009b0d | ||
|
|
cfcace8337 | ||
|
|
9870a3814c | ||
|
|
d64bb882fa | ||
|
|
ca46c1809b | ||
|
|
7f15ffe69f | ||
|
|
9210be98b5 | ||
|
|
e8f99c16b7 | ||
|
|
d971fd5e28 | ||
|
|
c590b82d27 | ||
|
|
adefa84885 | ||
|
|
efd4b8bbf2 | ||
|
|
9e84763f14 | ||
|
|
0527e045ba |
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
target
|
||||||
|
**/target
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.git
|
||||||
@@ -6,33 +6,114 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags: ['v*']
|
tags: ['v*']
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
publish_release:
|
||||||
|
description: Publish the GitHub release (leave off to prepare signed artifacts)
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
release-intent:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
build: ${{ steps.intent.outputs.build }}
|
||||||
|
steps:
|
||||||
|
- id: intent
|
||||||
|
name: Keep already published release assets immutable
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
REQUEST_PUBLISH: ${{ inputs.publish_release && 'true' || 'false' }}
|
||||||
|
run: |
|
||||||
|
python3 - <<'PY'
|
||||||
|
import json, os, subprocess
|
||||||
|
build = True
|
||||||
|
if os.environ['GITHUB_EVENT_NAME'] == 'push' or os.environ.get('REQUEST_PUBLISH') == 'true':
|
||||||
|
result = subprocess.run(['gh', 'api', 'repos/' + os.environ['GITHUB_REPOSITORY'] + '/releases/tags/' + os.environ['GITHUB_REF_NAME']], capture_output=True, text=True)
|
||||||
|
if result.returncode == 0:
|
||||||
|
build = json.loads(result.stdout)['draft']
|
||||||
|
if not build:
|
||||||
|
print('Published release already exists; preserve its assets and prerelease status.')
|
||||||
|
elif 'HTTP 404' not in result.stderr:
|
||||||
|
raise RuntimeError('Could not establish whether this release already exists: ' + result.stderr)
|
||||||
|
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
|
||||||
|
output.write('build=' + str(build).lower() + '\n')
|
||||||
|
PY
|
||||||
installer:
|
installer:
|
||||||
|
needs: release-intent
|
||||||
|
if: needs.release-intent.outputs.build == 'true'
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
|
- name: Validate release version
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
$version = (Get-Content package.json -Raw | ConvertFrom-Json).version
|
||||||
|
if ($env:GITHUB_EVENT_NAME -eq 'push' -and $env:GITHUB_REF_NAME -ne "v$version") {
|
||||||
|
throw 'The release tag does not match the application version.'
|
||||||
|
}
|
||||||
|
- name: Cache Rust dependencies and compiled targets
|
||||||
|
uses: actions/cache@v6
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
target
|
||||||
|
key: manager-installer-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}-${{ github.run_id }}
|
||||||
|
restore-keys: manager-installer-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}-
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 22
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- name: Tests
|
- name: Tests
|
||||||
run: cargo test --workspace -- --test-threads=1
|
run: cargo test --workspace -- --test-threads=1
|
||||||
- name: Build, sign and publish
|
- name: Build and sign (publish only when requested)
|
||||||
|
id: tauri
|
||||||
uses: tauri-apps/tauri-action@v0
|
uses: tauri-apps/tauri-action@v0
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ github.token }}
|
GITHUB_TOKEN: ${{ (github.event_name == 'push' || inputs.publish_release) && github.token || '' }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
||||||
with:
|
with:
|
||||||
tagName: ${{ github.ref_name }}
|
tagName: ${{ (github.event_name == 'push' || inputs.publish_release) && 'v__VERSION__' || '' }}
|
||||||
releaseName: CoA Server Manager ${{ github.ref_name }}
|
releaseName: CoA Server Manager v__VERSION__
|
||||||
releaseBody: See the assets to download the installer. Existing installations update themselves.
|
releaseBody: See the assets to download the installer. Existing installations update themselves.
|
||||||
releaseDraft: false
|
releaseDraft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
args: --bundles nsis
|
args: --bundles nsis
|
||||||
includeUpdaterJson: true
|
includeUpdaterJson: true
|
||||||
|
- name: Preserve the exact signed installer and updater metadata
|
||||||
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
MANAGER_ARTIFACTS: ${{ steps.tauri.outputs.artifactPaths }}
|
||||||
|
run: |
|
||||||
|
$paths = @($env:MANAGER_ARTIFACTS | ConvertFrom-Json)
|
||||||
|
$installers = @($paths | Where-Object { $_ -like '*-setup.exe' })
|
||||||
|
if ($installers.Count -ne 1) { throw 'Expected exactly one Windows NSIS installer.' }
|
||||||
|
$installer = [IO.Path]::GetFullPath($installers[0])
|
||||||
|
$workspace = [IO.Path]::GetFullPath((Get-Location).Path).TrimEnd('\') + '\'
|
||||||
|
if (-not $installer.StartsWith($workspace, [StringComparison]::OrdinalIgnoreCase)) { throw 'Installer escaped the workspace.' }
|
||||||
|
if (-not (Test-Path -LiteralPath "$installer.sig")) { throw 'The installer has no updater signature.' }
|
||||||
|
$version = (Get-Content package.json -Raw | ConvertFrom-Json).version
|
||||||
|
$name = [IO.Path]::GetFileName($installer).Replace(' ', '.')
|
||||||
|
New-Item -ItemType Directory -Force _prepared-manager | Out-Null
|
||||||
|
Copy-Item -LiteralPath $installer -Destination "_prepared-manager/$name"
|
||||||
|
Copy-Item -LiteralPath "$installer.sig" -Destination "_prepared-manager/$name.sig"
|
||||||
|
$platform = @{
|
||||||
|
signature = (Get-Content -LiteralPath "$installer.sig" -Raw).Trim()
|
||||||
|
url = "https://github.com/$env:GITHUB_REPOSITORY/releases/download/v$version/$([Uri]::EscapeDataString($name))"
|
||||||
|
}
|
||||||
|
@{ version = $version; notes = 'See the release notes.'; pub_date = [DateTime]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ssZ'); platforms = @{ 'windows-x86_64' = $platform } } |
|
||||||
|
ConvertTo-Json -Depth 8 | Set-Content _prepared-manager/latest.json -Encoding utf8NoBOM
|
||||||
|
@{ schema = 1; version = $version; source = $env:GITHUB_SHA; run = $env:GITHUB_RUN_ID; installer = $name; sha256 = (Get-FileHash -LiteralPath $installer -Algorithm SHA256).Hash.ToLowerInvariant() } |
|
||||||
|
ConvertTo-Json | Set-Content _prepared-manager/prepared-source.json -Encoding utf8NoBOM
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: prepared-manager-windows
|
||||||
|
path: _prepared-manager/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 14
|
||||||
@@ -4,5 +4,8 @@ dist
|
|||||||
*.log
|
*.log
|
||||||
.env
|
.env
|
||||||
src-tauri/gen
|
src-tauri/gen
|
||||||
|
|
||||||
|
# standalone service workspaces build into their own target folders
|
||||||
|
services/*/target/
|
||||||
# Disposable database fixtures and private recovery data
|
# Disposable database fixtures and private recovery data
|
||||||
.cache/
|
.cache/
|
||||||
@@ -51,3 +51,16 @@ Server promotion uses the persistent Windows PC and the shared workflow's verifi
|
|||||||
production databases; run applicable local acceptance in disposable fixtures. Record the actual passed,
|
production databases; run applicable local acceptance in disposable fixtures. Record the actual passed,
|
||||||
failed and unrun checks. Verify both GitHub Latest and the public signed stable pointer before reporting
|
failed and unrun checks. Verify both GitHub Latest and the public signed stable pointer before reporting
|
||||||
that users can update. Leave the durable handoff described in the runbook for the next agent.
|
that users can update. Leave the durable handoff described in the runbook for the next agent.
|
||||||
|
|
||||||
|
## Public documentation languages
|
||||||
|
|
||||||
|
Maintain the public README and every player/server-owner guide in all six Manager languages:
|
||||||
|
English, Russian, German, French, Spanish and Simplified Chinese. English stays at `README.md`
|
||||||
|
and the player-facing `docs/*.md`; translated READMEs use `README.<locale>.md`, with guides in
|
||||||
|
`docs/<locale>/` (`ru`, `de`, `fr`, `es`, `zh-CN`). Language switches open the same page.
|
||||||
|
When changing a public guide, update its counterparts in the same change. Write naturally for
|
||||||
|
players in each language rather than translating word for word. Keep steps, feature limits and
|
||||||
|
experimental Portable Characters warnings equivalent. Use actual UI labels; retain English labels
|
||||||
|
where the released UI falls back to English. English screenshots stay in `docs/screenshots/`; localized images use its `ru`, `de`, `fr`, `es` and `zh-CN` subfolders. Keep the interface and annotation language consistent with each guide.
|
||||||
|
The public guide index is `docs/README.md`; internal protocol specifications and audits are not
|
||||||
|
player guides. Keep canonical release histories in English and link to them instead of making copies.
|
||||||
@@ -8,6 +8,75 @@ Published releases and previews. Pre-release entries do not change the stable up
|
|||||||
|
|
||||||
Dates follow GitHub publication (UTC); legacy records retain their archived dates. Newest releases first.
|
Dates follow GitHub publication (UTC); legacy records retain their archived dates. Newest releases first.
|
||||||
|
|
||||||
|
## 0.9.0 — 2026-10-28
|
||||||
|
|
||||||
|
**Portable Characters are experimental and may contain bugs.**
|
||||||
|
|
||||||
|
- Choose Parallel or Global level scaling in module settings.
|
||||||
|
- Report Content Scaling problems directly to its repository.
|
||||||
|
- Send custom race problem reports directly to their maintainer.
|
||||||
|
- Internet sharing restores the LAN address after server restarts.
|
||||||
|
- Configure custom race availability for new characters.
|
||||||
|
- Public listing offers every realm that starts together, not just the main one.
|
||||||
|
- Public listing is a short list of realms with a window for the details.
|
||||||
|
- Configure profession and defense skill gains in server settings.
|
||||||
|
- Starting a server sets the character classes of the realm chosen on Overview.
|
||||||
|
- Start Wildcard and Warcraft Reborn together with Conquest of Azeroth.
|
||||||
|
- Control portable characters and keep Manager running in the system tray.
|
||||||
|
|
||||||
|
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.0) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.8.2...v0.9.0)
|
||||||
|
|
||||||
|
## 0.8.2 — 2026-10-27
|
||||||
|
|
||||||
|
**Portable Characters are experimental and may contain bugs.**
|
||||||
|
|
||||||
|
- Installs the verified CoA Custom 1.9.2 client patches and quest safety addon, while recognizing existing 1.9.1 installations.
|
||||||
|
- Server updates preserve the order of database migrations introduced during merges, preventing older snapshots from overwriting newer progression.
|
||||||
|
|
||||||
|
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.8.2) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.8.1...v0.8.2)
|
||||||
|
|
||||||
|
## 0.8.1 — 2026-10-25
|
||||||
|
|
||||||
|
**Portable Characters are experimental and may contain bugs.**
|
||||||
|
|
||||||
|
- Install the matching CoA Custom 1.9.1 client files.
|
||||||
|
|
||||||
|
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.8.1) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.8.0...v0.8.1)
|
||||||
|
|
||||||
|
## 0.8.0 — 2026-10-24
|
||||||
|
|
||||||
|
**Portable Characters are experimental and may contain bugs.**
|
||||||
|
|
||||||
|
- Server owners can allow portable characters per realm.
|
||||||
|
- Allowing portable characters also prepares the server for portable sessions.
|
||||||
|
- Managers stay compatible with the public connection service.
|
||||||
|
- Relay connections recover and use the ports of the installed server.
|
||||||
|
- Portable progress resumes after reconnecting or restarting the Manager.
|
||||||
|
- Older copies on another host may require maintenance before returning.
|
||||||
|
|
||||||
|
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.8.0) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.7.3...v0.8.0)
|
||||||
|
|
||||||
|
## 0.7.3 — 2026-10-23
|
||||||
|
|
||||||
|
**Portable Characters are experimental and may contain bugs.**
|
||||||
|
|
||||||
|
- Portable characters open again after using an experimental Manager.
|
||||||
|
|
||||||
|
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.7.3) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.7.2...v0.7.3)
|
||||||
|
|
||||||
|
## 0.7.2 — 2026-10-23
|
||||||
|
|
||||||
|
- Advanced settings cover creature melee damage, spell damage and health by rank.
|
||||||
|
- Internet sharing accepts existing port forwards to the same server.
|
||||||
|
- The Auction House Bot card has a single switch.
|
||||||
|
- More character and server browser controls now use your selected language.
|
||||||
|
- Online player counts correctly separate random bots from players.
|
||||||
|
- Custom races work with shared addon folders on another drive.
|
||||||
|
- Configure the day and night cycle from the module settings.
|
||||||
|
- A stalled database inspection no longer blocks server maintenance indefinitely.
|
||||||
|
|
||||||
|
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.7.2) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.7.1...v0.7.2)
|
||||||
|
|
||||||
## 0.7.1 — 2026-10-22
|
## 0.7.1 — 2026-10-22
|
||||||
|
|
||||||
Close the game, then open Modules → Custom Races → Repair Client Patch to update existing patches, or Install Client Patch for a new installation. Updating the Manager does not automatically replace game files or update your server.
|
Close the game, then open Modules → Custom Races → Repair Client Patch to update existing patches, or Install Client Patch for a new installation. Updating the Manager does not automatically replace game files or update your server.
|
||||||
|
|||||||
Generated
+376
-6
@@ -8,6 +8,41 @@ version = "2.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aead"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"
|
||||||
|
dependencies = [
|
||||||
|
"crypto-common",
|
||||||
|
"generic-array",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aes"
|
||||||
|
version = "0.8.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"cipher",
|
||||||
|
"cpufeatures",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aes-gcm"
|
||||||
|
version = "0.10.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1"
|
||||||
|
dependencies = [
|
||||||
|
"aead",
|
||||||
|
"aes",
|
||||||
|
"cipher",
|
||||||
|
"ctr",
|
||||||
|
"ghash",
|
||||||
|
"subtle",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "1.1.5"
|
version = "1.1.5"
|
||||||
@@ -276,6 +311,15 @@ dependencies = [
|
|||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "blake2"
|
||||||
|
version = "0.10.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe"
|
||||||
|
dependencies = [
|
||||||
|
"digest",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block-buffer"
|
name = "block-buffer"
|
||||||
version = "0.10.4"
|
version = "0.10.4"
|
||||||
@@ -477,6 +521,30 @@ version = "1.0.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chacha20"
|
||||||
|
version = "0.9.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"cipher",
|
||||||
|
"cpufeatures",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chacha20poly1305"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35"
|
||||||
|
dependencies = [
|
||||||
|
"aead",
|
||||||
|
"chacha20",
|
||||||
|
"cipher",
|
||||||
|
"poly1305",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.4.45"
|
version = "0.4.45"
|
||||||
@@ -489,20 +557,51 @@ dependencies = [
|
|||||||
"windows-link",
|
"windows-link",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cipher"
|
||||||
|
version = "0.4.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
|
||||||
|
dependencies = [
|
||||||
|
"crypto-common",
|
||||||
|
"inout",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "coa-control-proto"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"base64 0.22.1",
|
||||||
|
"coa-registry-proto",
|
||||||
|
"ed25519-dalek",
|
||||||
|
"hex",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sha2",
|
||||||
|
"snow",
|
||||||
|
"thiserror 2.0.21",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coa-core"
|
name = "coa-core"
|
||||||
version = "0.6.21"
|
version = "0.9.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"coa-control-proto",
|
||||||
|
"coa-registry-proto",
|
||||||
"dunce",
|
"dunce",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
|
"flate2",
|
||||||
"fs4",
|
"fs4",
|
||||||
"hex",
|
"hex",
|
||||||
"if-addrs",
|
"if-addrs",
|
||||||
"num-bigint",
|
"num-bigint",
|
||||||
"rand_core",
|
"rand_core 0.6.4",
|
||||||
"reqwest 0.12.28",
|
"reqwest 0.12.28",
|
||||||
|
"rusqlite",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha1",
|
"sha1",
|
||||||
@@ -512,15 +611,30 @@ dependencies = [
|
|||||||
"thiserror 2.0.21",
|
"thiserror 2.0.21",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
"tungstenite",
|
||||||
"uuid",
|
"uuid",
|
||||||
"windows-sys 0.60.2",
|
"windows-sys 0.60.2",
|
||||||
"zip 2.4.2",
|
"zip 2.4.2",
|
||||||
"zstd",
|
"zstd",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "coa-registry-proto"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"base64 0.22.1",
|
||||||
|
"ed25519-dalek",
|
||||||
|
"hex",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sha2",
|
||||||
|
"thiserror 2.0.21",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coa-release"
|
name = "coa-release"
|
||||||
version = "0.6.21"
|
version = "0.9.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"coa-core",
|
"coa-core",
|
||||||
@@ -529,9 +643,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coa-server-manager"
|
name = "coa-server-manager"
|
||||||
version = "0.6.21"
|
version = "0.9.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"coa-control-proto",
|
||||||
"coa-core",
|
"coa-core",
|
||||||
|
"coa-registry-proto",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tauri",
|
"tauri",
|
||||||
@@ -668,6 +784,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
|
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"generic-array",
|
"generic-array",
|
||||||
|
"rand_core 0.6.4",
|
||||||
"typenum",
|
"typenum",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -700,6 +817,15 @@ version = "1.0.13"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "914a755b7c2d4af2bdcff7ce1739e2db9a1b81a9b07123d8015786ae03c0980d"
|
checksum = "914a755b7c2d4af2bdcff7ce1739e2db9a1b81a9b07123d8015786ae03c0980d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ctr"
|
||||||
|
version = "0.9.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"
|
||||||
|
dependencies = [
|
||||||
|
"cipher",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "curve25519-dalek"
|
name = "curve25519-dalek"
|
||||||
version = "4.1.3"
|
version = "4.1.3"
|
||||||
@@ -761,6 +887,12 @@ dependencies = [
|
|||||||
"syn 3.0.6",
|
"syn 3.0.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "data-encoding"
|
||||||
|
version = "2.11.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dbus"
|
name = "dbus"
|
||||||
version = "0.9.12"
|
version = "0.9.12"
|
||||||
@@ -862,6 +994,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"block-buffer",
|
"block-buffer",
|
||||||
"crypto-common",
|
"crypto-common",
|
||||||
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1000,7 +1133,7 @@ checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"curve25519-dalek",
|
"curve25519-dalek",
|
||||||
"ed25519",
|
"ed25519",
|
||||||
"rand_core",
|
"rand_core 0.6.4",
|
||||||
"serde",
|
"serde",
|
||||||
"sha2",
|
"sha2",
|
||||||
"subtle",
|
"subtle",
|
||||||
@@ -1101,6 +1234,18 @@ dependencies = [
|
|||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fallible-iterator"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fallible-streaming-iterator"
|
||||||
|
version = "0.1.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
@@ -1460,6 +1605,16 @@ dependencies = [
|
|||||||
"r-efi 6.0.0",
|
"r-efi 6.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ghash"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1"
|
||||||
|
dependencies = [
|
||||||
|
"opaque-debug",
|
||||||
|
"polyval",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gio"
|
name = "gio"
|
||||||
version = "0.18.4"
|
version = "0.18.4"
|
||||||
@@ -1614,11 +1769,32 @@ version = "0.12.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.16.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
|
||||||
|
dependencies = [
|
||||||
|
"foldhash",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.17.1"
|
version = "0.17.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
||||||
|
dependencies = [
|
||||||
|
"foldhash",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashlink"
|
||||||
|
version = "0.12.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a596f1b20ed2cc5ecac41a164aaebc7258057060f06c0cf7a2ba3991ee7990fb"
|
||||||
|
dependencies = [
|
||||||
|
"hashbrown 0.17.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
@@ -1956,6 +2132,15 @@ dependencies = [
|
|||||||
"cfb",
|
"cfb",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "inout"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ipnet"
|
name = "ipnet"
|
||||||
version = "2.12.2"
|
version = "2.12.2"
|
||||||
@@ -2255,6 +2440,17 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libsqlite3-sys"
|
||||||
|
version = "0.38.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f1d20bef17f513b9b3004532233187769cd072d790971f4e4da0e346eb6401e8"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"pkg-config",
|
||||||
|
"vcpkg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linux-raw-sys"
|
name = "linux-raw-sys"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
@@ -2696,6 +2892,12 @@ version = "1.21.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "opaque-debug"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "open"
|
name = "open"
|
||||||
version = "5.4.4"
|
version = "5.4.4"
|
||||||
@@ -2979,6 +3181,29 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "poly1305"
|
||||||
|
version = "0.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf"
|
||||||
|
dependencies = [
|
||||||
|
"cpufeatures",
|
||||||
|
"opaque-debug",
|
||||||
|
"universal-hash",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "polyval"
|
||||||
|
version = "0.6.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"cpufeatures",
|
||||||
|
"opaque-debug",
|
||||||
|
"universal-hash",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "portable-atomic"
|
name = "portable-atomic"
|
||||||
version = "1.15.0"
|
version = "1.15.0"
|
||||||
@@ -3009,6 +3234,15 @@ version = "0.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ppv-lite86"
|
||||||
|
version = "0.2.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "precomputed-hash"
|
name = "precomputed-hash"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@@ -3107,6 +3341,26 @@ version = "6.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.9.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41"
|
||||||
|
dependencies = [
|
||||||
|
"rand_chacha",
|
||||||
|
"rand_core 0.9.5",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_chacha"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||||
|
dependencies = [
|
||||||
|
"ppv-lite86",
|
||||||
|
"rand_core 0.9.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand_core"
|
name = "rand_core"
|
||||||
version = "0.6.4"
|
version = "0.6.4"
|
||||||
@@ -3116,6 +3370,15 @@ dependencies = [
|
|||||||
"getrandom 0.2.17",
|
"getrandom 0.2.17",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.9.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom 0.3.4",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "raw-window-handle"
|
name = "raw-window-handle"
|
||||||
version = "0.6.2"
|
version = "0.6.2"
|
||||||
@@ -3305,6 +3568,31 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rsqlite-vfs"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c51c9ae4df8a7fba42103df5c621fa3c37eccf3a3c650879e90fc48b11cc192c"
|
||||||
|
dependencies = [
|
||||||
|
"hashbrown 0.16.1",
|
||||||
|
"thiserror 2.0.21",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rusqlite"
|
||||||
|
version = "0.40.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23f2a97da3e3873c73cb2a2e71b35c40ff95e0b1eefa8d72d8499a6928c3b5b3"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.13.2",
|
||||||
|
"fallible-iterator",
|
||||||
|
"fallible-streaming-iterator",
|
||||||
|
"hashlink",
|
||||||
|
"libsqlite3-sys",
|
||||||
|
"smallvec",
|
||||||
|
"sqlite-wasm-rs",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-hash"
|
name = "rustc-hash"
|
||||||
version = "2.1.3"
|
version = "2.1.3"
|
||||||
@@ -3769,7 +4057,7 @@ version = "2.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
|
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rand_core",
|
"rand_core 0.6.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3812,6 +4100,22 @@ version = "1.16.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e"
|
checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "snow"
|
||||||
|
version = "0.9.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "850948bee068e713b8ab860fe1adc4d109676ab4c3b621fd8147f06b261f2f85"
|
||||||
|
dependencies = [
|
||||||
|
"aes-gcm",
|
||||||
|
"blake2",
|
||||||
|
"chacha20poly1305",
|
||||||
|
"curve25519-dalek",
|
||||||
|
"rand_core 0.6.4",
|
||||||
|
"rustc_version",
|
||||||
|
"sha2",
|
||||||
|
"subtle",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "socket2"
|
name = "socket2"
|
||||||
version = "0.6.5"
|
version = "0.6.5"
|
||||||
@@ -3880,6 +4184,18 @@ dependencies = [
|
|||||||
"der",
|
"der",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sqlite-wasm-rs"
|
||||||
|
version = "0.5.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dc3efc0da82635d7e1ced0053bbbfa8c7ab9645d0bf36ceb4f7127bb85315d75"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"js-sys",
|
||||||
|
"rsqlite-vfs",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stable_deref_trait"
|
name = "stable_deref_trait"
|
||||||
version = "1.2.1"
|
version = "1.2.1"
|
||||||
@@ -4798,6 +5114,24 @@ version = "0.2.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tungstenite"
|
||||||
|
version = "0.26.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4793cb5e56680ecbb1d843515b23b6de9a75eb04b66643e256a396d43be33c13"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"data-encoding",
|
||||||
|
"http",
|
||||||
|
"httparse",
|
||||||
|
"log",
|
||||||
|
"native-tls",
|
||||||
|
"rand",
|
||||||
|
"sha1",
|
||||||
|
"thiserror 2.0.21",
|
||||||
|
"utf-8",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typeid"
|
name = "typeid"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
@@ -4833,6 +5167,16 @@ version = "1.13.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
|
checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "universal-hash"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea"
|
||||||
|
dependencies = [
|
||||||
|
"crypto-common",
|
||||||
|
"subtle",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "untrusted"
|
name = "untrusted"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
@@ -4864,6 +5208,12 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "utf-8"
|
||||||
|
version = "0.7.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf8_iter"
|
name = "utf8_iter"
|
||||||
version = "1.0.4"
|
version = "1.0.4"
|
||||||
@@ -5758,6 +6108,26 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy"
|
||||||
|
version = "0.8.61"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "879fb705ce98c32e41ebdb970fbe1204f8492423b314c6ab0354c3e7b5542866"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy-derive"
|
||||||
|
version = "0.8.61"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "708882a28301d604fa039cc7727607a98d04c4b86dc76ec9cc683f805d709759"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.119",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerofrom"
|
name = "zerofrom"
|
||||||
version = "0.1.8"
|
version = "0.1.8"
|
||||||
|
|||||||
+3
-2
@@ -1,9 +1,10 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = ["crates/coa-core", "crates/coa-release", "src-tauri"]
|
members = ["crates/coa-core", "crates/coa-release", "crates/coa-registry-proto", "crates/coa-control-proto", "src-tauri"]
|
||||||
|
exclude = ["services/coa-registry", "services/coa-registry-e2e", "services/coa-coordinator", "services/coa-relay"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.6.21"
|
version = "0.9.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-only"
|
license = "AGPL-3.0-only"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,228 @@
|
|||||||
|
# Per-race availability audit
|
||||||
|
|
||||||
|
Date: 2026-10-27. This is an internal implementation audit, not a supported-feature guide.
|
||||||
|
|
||||||
|
## Frozen sources
|
||||||
|
|
||||||
|
Separate `feat/per-race-toggles` branches and checkouts:
|
||||||
|
|
||||||
|
| Component | Checkout | Fetched base |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Manager | `C:/games/source/per-race-manager` | `origin/master`, `925a81f` |
|
||||||
|
| Core | `C:/games/source/per-race-core` | `origin/coa-bots`, `1c658cab46d5057a8972cebd84c840aa6fbc4a91` |
|
||||||
|
| CoA Companions | `C:/games/source/per-race-companions` | `origin/master`, `6a289fc2230ce9425924ca86dee02d0bb8d3d344` |
|
||||||
|
| Build | `C:/games/source/per-race-build` | `origin/main`, `89795b6` |
|
||||||
|
|
||||||
|
The build runbook explicitly selects `Corfirean/azerothcore-wotlk-coa:coa-bots`, not its `main`.
|
||||||
|
The old `C:/games/source/server/azerothcore-wotlk-coa` checkout instead tracks jealous-sound upstream
|
||||||
|
and has local modifications. It must not be used as the feature's release base.
|
||||||
|
The primary Manager and Companions checkouts also contain unrelated work and remain untouched.
|
||||||
|
|
||||||
|
SQUID is a separate repository, `Zyth45/mod-playerbots`, not `Corfirean/mod-coa-playerbots`.
|
||||||
|
Existing research checkout: `C:/games/source/squid-playerbots`. Its current local branch is
|
||||||
|
`fix/custom-races-existing-bots`, one commit ahead of `origin/coa`. Build policy selects the highest
|
||||||
|
stable numeric tag, so that local branch must not silently become the shipped dependency.
|
||||||
|
|
||||||
|
## Manager integration points
|
||||||
|
|
||||||
|
- `crates/coa-core/src/custom_races.rs`: package version `1.9.2`, release URLs, MPQ/root/addon lists,
|
||||||
|
hash manifests, client status, install, enable/disable and uninstall.
|
||||||
|
- `PatchTransaction`, `SavedFile`, `recover_patch_transaction`: shared client-relative journal in
|
||||||
|
`.coa-races-transaction/journal.json`, saved files and `committed` marker. Uncommitted changes roll back.
|
||||||
|
Paths use `fsx::safe_join`; file moves handle cross-volume addon locations.
|
||||||
|
- `patch_lock`: exclusive OS file lock on `.coa-races.lock`. The empty file's existence is normal and
|
||||||
|
does not prove another operation is active. Do not delete it as a stale-lock workaround.
|
||||||
|
- Client mutations reject `client::is_running`; reuse this gate and lock for availability changes.
|
||||||
|
- `patch_files`, `matches_patch`, `preserve_original`: ownership and preservation depend on manifests
|
||||||
|
and hashes, not just a filename. Availability overlay ownership needs its own verified record.
|
||||||
|
- `modules/catalog.json`: `custom-races` uses `coa_custom_races.conf` and `CoACustomRaces.Enable`.
|
||||||
|
Companions use `mod_coa_playerbots.conf` / `CoaBots.Enable`; SQUID uses
|
||||||
|
`playerbots.conf` / `AiPlayerbot.Enabled`.
|
||||||
|
- `crates/coa-core/src/modules.rs`: `toggle`, `settings_in`, `save_settings_in` write current module
|
||||||
|
configuration. Bot switches enforce stopped servers and the existing control lock.
|
||||||
|
- `src/screens/ModulesPage.tsx`: Custom Races card, master toggle, install/progress/status UI.
|
||||||
|
- `src/lib/api.ts` and `src-tauri/src/lib.rs`: existing `custom_races_status`,
|
||||||
|
`custom_races_install`, `custom_races_uninstall`, `custom_races_toggle_client` commands.
|
||||||
|
There is no per-race command or verified availability status yet.
|
||||||
|
- `src-tauri/src/lib.rs::play`: local launch reads `realms::state`, calls `client::sync_realm`, then
|
||||||
|
launches. Remote launch has a separate realmlist override path; it cannot infer a remote race policy.
|
||||||
|
- `crates/coa-core/src/realms.rs`: modes CoA, Wildcard and Warcraft Reborn; current configs are captured
|
||||||
|
under `Settings/realm-profiles/<mode>.json`. Use this mechanism rather than a parallel realm store.
|
||||||
|
Existing bot restrictions for non-CoA modes must remain effective.
|
||||||
|
- `crates/coa-core/src/clientdl.rs::apply`: manifest-based client updates, `keep_modified`, staging,
|
||||||
|
preservation of replaced files. No availability-overlay invalidation or rebuild exists today.
|
||||||
|
|
||||||
|
### Confirmed reconciliation risk
|
||||||
|
|
||||||
|
`custom_races.rs::sync_bot_races_config` writes a replacement `AiPlayerbot.ExcludedBotRaces` value:
|
||||||
|
recommended full exclusions or experimental `65,72,77,80,81`. It does not preserve arbitrary user
|
||||||
|
exclusions. `modules.rs` calls it from the master switch and BotsEnable saving; some callers discard
|
||||||
|
errors. Per-race integration cannot rely on this overwrite behavior.
|
||||||
|
|
||||||
|
`playerbots_conf_paths` can also copy a `.dist` file when no active config exists; it is not a purely
|
||||||
|
read-only discovery API. Status inspection should avoid adding more implicit writes.
|
||||||
|
|
||||||
|
## Core gates and bypasses
|
||||||
|
|
||||||
|
- `modules/mod-coa-custom-races/src/mod_coa_custom_races.cpp`: `WorldScript` loads the master switch;
|
||||||
|
`AccountScript::CanAccountCreateCharacter` accepts stock IDs 1–8, 10, 11 or an enabled master switch.
|
||||||
|
No disabled-ID list is implemented. Stock ID 9 is deliberately not included.
|
||||||
|
- `modules/mod-coa-custom-races/conf/coa_custom_races.conf.dist`: Enable and BotsEnable exist;
|
||||||
|
DisabledRaceIds does not.
|
||||||
|
- `src/server/game/Handlers/CharacterHandler.cpp`: normal character creation invokes
|
||||||
|
`sScriptMgr->CanAccountCreateCharacter` inside its finalization callback and rejects with
|
||||||
|
`CHAR_CREATE_DISABLED`. A packet from an unpatched client reaches that gate too.
|
||||||
|
- `src/server/game/Scripting/ScriptDefines/AccountScript.cpp`: hook aggregation must be preserved.
|
||||||
|
- `src/server/game/DataStores/DBCStores.cpp::LoadDBCStores`: chooses `DataDir/dbc_races/<file>` if
|
||||||
|
the master switch is enabled and that file exists, otherwise `DataDir/dbc/<file>`.
|
||||||
|
Per-race creation policy must not remove DBC rows or change login data.
|
||||||
|
- `.agents/docs/systems/ascension-character-creation.md`: native client compatibility depends on
|
||||||
|
`CharBaseInfo.dbc`; race button indices are not RaceIDs. Existing race/class checks must stay intact.
|
||||||
|
|
||||||
|
## Both bot systems
|
||||||
|
|
||||||
|
### CoA Companions
|
||||||
|
|
||||||
|
`module/src/BotSpawnRandom.cpp::GetValidBotRaces` reads the global and bot custom-race switches,
|
||||||
|
`CoaBots.CustomRaces.Enable`, and both AiPlayerbot/CoaBots exclusion lists. It checks DBC presence.
|
||||||
|
Its experimental defaults apply only when the combined exclusion set is empty: adding an owner list
|
||||||
|
to that set would silently remove those defaults. Keep those policies independent.
|
||||||
|
|
||||||
|
`CreateBotClone`, `CreateOneRandomBot`, and leveled spawning clone SQL character data directly;
|
||||||
|
they bypass the account creation hook. Enforce new-character policy at the common clone creation
|
||||||
|
entry as well as random selection. Preserve existing bots and faction selection via
|
||||||
|
`Player::TeamIdForRace`.
|
||||||
|
|
||||||
|
Additional confirmed callers: `module/src/BotBattlegroundFill.cpp::QueueBotForSide` and
|
||||||
|
`module/src/BotLfgFill.cpp` call `CreateOneRandomBot` after trying to reuse an existing bot.
|
||||||
|
The existing-bot reuse path must remain separate from creation restrictions.
|
||||||
|
|
||||||
|
`tools/offline_bot_factory.py` is another direct-SQL creation path. Its main loop chooses a
|
||||||
|
template by class and faction, then copies `template.race` into the new character overrides.
|
||||||
|
It currently does not read the custom-race creation policy. Reject or filter prohibited
|
||||||
|
templates before generating new accounts, GUIDs or SQL; do not rewrite their races.
|
||||||
|
|
||||||
|
### SQUID Playerbots
|
||||||
|
|
||||||
|
`src/PlayerbotAIConfig.cpp` loads `AiPlayerbot.ExcludedBotRaces` and adds
|
||||||
|
`AiPlayerbot.CrashingBotRaces`; it reads BotsEnable. `src/CoaBotRacePolicy.h` implements
|
||||||
|
`IsCoaBotRaceAllowed`. `src/Bot/Factory/RandomPlayerbotFactory.cpp::CreateRandomBot` applies
|
||||||
|
that policy before faction and race/class selection.
|
||||||
|
|
||||||
|
The same predicate also appears in `src/Bot/RandomPlayerbotMgr.cpp` and
|
||||||
|
`src/Bot/PlayerbotMgr.cpp`, including existing-character admission. Do not append owner creation
|
||||||
|
restrictions globally to this shared exclusion vector: that would also affect existing bots.
|
||||||
|
The predicate currently does not itself require `CoACustomRaces.Enable`.
|
||||||
|
`RandomPlayerbotFactory.cpp` calls `Player::Create` directly without the account hook.
|
||||||
|
Use a creation-only check in this factory, leaving existing-character admission unchanged.
|
||||||
|
|
||||||
|
## Portable Characters
|
||||||
|
|
||||||
|
Manager import code is under `crates/coa-core/src/portable/realm/`.
|
||||||
|
`import.rs` validates identity namespaces and race/class start data (`UnknownRaceClass`).
|
||||||
|
Availability policy must not become an import rejection or an identity rewrite. The inspected
|
||||||
|
creation hook is in the normal packet handler, not this importer. In the core,
|
||||||
|
`src/server/coa/CoAPortableImport.cpp` checks `GetPlayerInfo(model.Race, model.Class)` and writes
|
||||||
|
`model.Race` to the imported character and character cache. It does not invoke the account
|
||||||
|
creation hook. Preserve this separation. Live compatibility is still untested.
|
||||||
|
|
||||||
|
## Client experiment, actual observations
|
||||||
|
|
||||||
|
The owner updated `C:/games/Ascension` from 1.9.1 to 1.9.2 during this audit; its manifest now says
|
||||||
|
`# CoA Custom 1.9.2`. A separate physical client copy is being prepared under
|
||||||
|
`C:/games/source/per-race-evidence/client`; game assets are outside Git. The copy completed:
|
||||||
|
25646 files copied, zero failures. The separate server file copy also completed, but has not
|
||||||
|
been configured or started. No database service has been started for this task.
|
||||||
|
|
||||||
|
Read-only MPQ membership probing found ChrRaces in patch-ZZZF, ZZZE, ZZZC, ZZZ, ZZW, ZZV, ZZU,
|
||||||
|
ZZS, T, M and several locale archives. CharacterCreate.lua has multiple owners too.
|
||||||
|
The old `mpqprobe.py` precedence model explicitly admits an inference for Ascension multi-letter
|
||||||
|
archives. Therefore `patch-ZZZF.MPQ` is a candidate source, not runtime-confirmed effective data.
|
||||||
|
`patch-ZZZZ.MPQ` exists already; no overlay filename has been qualified.
|
||||||
|
|
||||||
|
Extracted from `patch-ZZZF.MPQ`:
|
||||||
|
|
||||||
|
- WDBC, 95 records, 69 fields, record size 276, string block 2428, total bytes 28668.
|
||||||
|
- SHA-256 `b78635b08bf0bd63d2898fce97c1fb162c8a9c41632703172eefa88bae79061f`.
|
||||||
|
- Actual rows: Sethrak 82, Gnoll 83, Saberon 97. Their Flags are 12.
|
||||||
|
- String block starts with `Hu`, not NUL; imposing an initial empty-string invariant incorrectly
|
||||||
|
rejects this real table. String boundaries and referenced offsets still need validation.
|
||||||
|
- Sethrak experiment changes only Flags 12 → 13. All other bytes compare equal.
|
||||||
|
- One generated MPQ was read back through StormLib; its DBC equals the expected patched bytes.
|
||||||
|
- The installed `pympq` Python extension crashed during interpreter finalization. The experimental
|
||||||
|
tool instead uses the installed Unicode StormLib DLL directly. It is not a runtime dependency
|
||||||
|
proposal for Manager or its users.
|
||||||
|
|
||||||
|
`tools/race_availability_poc.py` requires an explicit source archive and creates output only in a new
|
||||||
|
directory. It does not select an archive order, install an overlay or assert in-game success.
|
||||||
|
`tools/test_race_availability_poc.py` uses synthetic bytes only.
|
||||||
|
|
||||||
|
### Background verification after interactive testing was deferred
|
||||||
|
|
||||||
|
The owner requested no screen capture/input and no client/server/MySQL launches while other bot
|
||||||
|
tests run. These restrictions remain active. The owner reported that the copied client launches;
|
||||||
|
this does not confirm creation behavior or effective DBC loading.
|
||||||
|
|
||||||
|
- 17 DBC/fingerprint tests and 8 synthetic MPQ integration tests pass (25 total, none skipped).
|
||||||
|
- Native tests use the explicitly selected existing Unicode StormLib DLL, with no new install.
|
||||||
|
- Output is built and verified in a temporary directory before publishing the offline result folder.
|
||||||
|
Failures leave no published result; this is not the future client transaction implementation.
|
||||||
|
- One and fifty disabled races both produce one MPQ. StormLib adds an internal `(listfile)`;
|
||||||
|
the sole game payload is `DBFilesClient/ChrRaces.dbc`.
|
||||||
|
- Every referenced localized race-name offset is bounds-checked; invalid UTF-8 is rejected.
|
||||||
|
- The experimental fingerprint includes original DBC SHA-256, normalized IDs, algorithm version
|
||||||
|
and explicitly recorded profile. A profile label does not prove client compatibility.
|
||||||
|
- The real three-race offline experiment is in
|
||||||
|
`C:/games/source/per-race-evidence/multiple-races-offline/report.json`.
|
||||||
|
Source MPQ SHA-256: `40eac695cfcafb598b8376f3b9a61ecc037e4d445b87279cfe387a91edad32c3`.
|
||||||
|
Generated DBC SHA-256: `243fb36837b76ebd6943da574cc095be548b4530be7f06487debea6703db10d3`.
|
||||||
|
|
||||||
|
The first copy launch showed a missing-critical-files message and subsequently crashed on exit.
|
||||||
|
The crash report identifies `AMDXN32.DLL` in the AMD graphics driver at the fault address; this
|
||||||
|
does not establish the root cause. EXE, Extensions, dinput8, d3d9, dxgi, EsteriaAppearance and
|
||||||
|
patch-ZZZF hashes matched the primary client during comparison. The experimental overlay was
|
||||||
|
not installed. No graphics-driver or client-runtime changes were made to work around the crash.
|
||||||
|
|
||||||
|
## Reference implementations and update preservation
|
||||||
|
|
||||||
|
Inspected read-only reference clones:
|
||||||
|
|
||||||
|
- `aspollon/AFK-Realm` at `ea9c5bf691c98cace8cc03c06183c161022946de`.
|
||||||
|
- `aspollon/mod-custom-races` at `5a8f2ff8a0d494ffadf64e677a438aa7f5a6671b`.
|
||||||
|
|
||||||
|
`mod-custom-races/afk-realm.json` declares client patch generation and GlueXML Lua insertion.
|
||||||
|
`client/CustomRaces.lua` extends and lays out buttons, using race names/files and configured IDs.
|
||||||
|
This is a reference, not evidence of compatibility with the current CoA/Esteria UI or a reason
|
||||||
|
to replace CSM's prebuilt-server distribution.
|
||||||
|
|
||||||
|
`crates/coa-core/src/config/merge.rs` performs additive `.dist` merging: missing keys are added,
|
||||||
|
existing user values and unknown keys are retained. A new DisabledRaceIds key should use this
|
||||||
|
path. Existing realm snapshots already capture module `.conf` files. Neither mechanism currently
|
||||||
|
coordinates an availability overlay with client update/repair; that remains implementation work.
|
||||||
|
|
||||||
|
## Open gates
|
||||||
|
|
||||||
|
Update after the owner found the existing Hide Races panel: see
|
||||||
|
[existing-filter research](docs/PER_RACE_EXISTING_FILTER_RESEARCH.md). The inspected Lua already
|
||||||
|
supports personal name/index-based hiding, but it is not a realm-scoped RaceID policy. Nine
|
||||||
|
offline Lua 5.1 probes confirmed key behavior and limitations. Reusing its layout/UI is now a
|
||||||
|
candidate to investigate before choosing a production DBC implementation. This is not evidence
|
||||||
|
that the DBC approach failed, and it does not qualify client support.
|
||||||
|
|
||||||
|
The owner subsequently confirmed the GlueXML probe: restricted races disappeared from selection
|
||||||
|
and were grey, unchecked and disabled in Hide Races. The production client integration should
|
||||||
|
reuse this filter; changing DBC flags is no longer the selected implementation path.
|
||||||
|
|
||||||
|
Server controls, strict catalog-bound configuration, the core creation hook and both bot factory
|
||||||
|
guards are implemented and have passed offline checks and native builds. Existing-bot admission
|
||||||
|
and user/crashing exclusions remain separate from the new creation policy.
|
||||||
|
|
||||||
|
Remaining gates:
|
||||||
|
1. Integrate automatic client reconciliation, ownership and recovery with realm settings.
|
||||||
|
2. Qualify client update/repair and shared-client PLAY behavior.
|
||||||
|
3. Verify live creation rejection/re-enable, existing-character login, imports and both bot systems
|
||||||
|
when the owner's database test environment becomes available.
|
||||||
|
|
||||||
|
Status: **PARTIAL** — server implementation and builds pass; live server acceptance and production
|
||||||
|
client synchronization remain pending. See docs/PER_RACE_TOGGLES_TESTS.md for exact scope.
|
||||||
|
No existing character data, production service, release channel, or primary client archive was changed.
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
# CoA Server Manager
|
||||||
|
|
||||||
|
[English](README.md) · [Русский](README.ru.md) · **Deutsch** · [Français](README.fr.md) · [Español](README.es.md) · [简体中文](README.zh-CN.md)
|
||||||
|
|
||||||
|
**Portable Characters sind experimentell.** Die Funktion wird noch entwickelt und kann Fehler enthalten.
|
||||||
|
|
||||||
|
Eine Windows-Anwendung, mit der du deinen eigenen **Conquest of Azeroth**-Server auf Basis von AzerothCore mit wenigen Schritten einrichtest und betreibst. Konsole, manuelle Konfigurationsdateien und separate Datenbankprogramme sind dafür nicht nötig. Entwickelt mit Tauri 2, Rust und React.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Funktionen
|
||||||
|
|
||||||
|
- **Portable Characters — experimentell.** Bewahre Charaktere samt gespeicherten Versionen im Manager auf und übernimm vorhandene Charaktere von Realms, auf die du Zugriff hast. [Zur Anleitung](docs/de/PORTABLE-CHARACTERS.md).
|
||||||
|
- **Realms entdecken.** Vergleiche öffentlich gelistete Realms nach Spielmodus, Höchststufe, Raten, Modulen und Spielerzahl.
|
||||||
|
- **Einfache Einrichtung.** Der Manager lädt ein signiertes Serverpaket herunter, prüft die Dateien, richtet die Datenbank ein und erstellt dein erstes Konto. Downloads lassen sich fortsetzen; vorhandene Server kannst du ebenfalls einbinden.
|
||||||
|
- **Starten, stoppen, spielen.** Steuere Datenbank, Auth- und Weltserver gemeinsam. Status, Laufzeit und Spielerzahl siehst du direkt. Beim Spielstart wird die passende Realmlist verwendet.
|
||||||
|
- **Spielclient verwalten.** Verwende deinen vorhandenen Client oder lade ihn über den Manager herunter: etwa 43 GB, fortsetzbar und dateiweise geprüft. Verwaltete Clients erhalten Update-Hinweise; selbst veränderte Dateien werden nur mit deiner Zustimmung ersetzt.
|
||||||
|
- **Serverupdates.** Der Manager sucht beim Start und alle fünf Minuten nach Updates. Ed25519-Signaturen schützen die Pakete. Vor dem Update wird eine Sicherung erstellt; eigene Änderungen bleiben erhalten und ein Rollback ist möglich.
|
||||||
|
- **Sicherungen.** Sichere Charaktere, Konten und Einstellungen bei Bedarf oder automatisch vor Updates. Prüfen und Wiederherstellen geht direkt in der Anwendung.
|
||||||
|
- **CoA, Wildcard und Warcraft Reborn.** Wähle den Realm unter Übersicht. Die Serverversion muss den gewählten Modus unterstützen. Beim ersten Wechsel entstehen eine eigene Welt und eine leere Charakterdatenbank. Konten werden geteilt, Charaktere und Moduleinstellungen bleiben getrennt. Ein laufender Server speichert die Charaktere und startet beim Wechsel neu. Schließe vorher den Client; bei geöffnetem Client wird die Realm-Auswahl erst beim nächsten Start über den Manager übernommen. Bots sind auf Wildcard und Warcraft Reborn nicht verfügbar; andere Zusatzmodule sind dort experimentell. Sicherungen und Datenbankupdates berücksichtigen alle angelegten Realms. CoA und Wildcard können gemeinsam laufen. [Wildcard](docs/de/WILDCARD.md) · [Warcraft Reborn](docs/de/WARCRAFT-REBORN.md).
|
||||||
|
- **Begleiter-Bots.** Erstelle Bots mit passender Stufe, verfolge den Fortschritt, pausiere die Erstellung oder melde Bots ab. Entferne bei Bedarf eine bestimmte Anzahl, um den Server zu entlasten, und lege die Zahl beim Serverstart fest.
|
||||||
|
- **Realmlists wechseln.** Speichere benannte Verbindungen wie Solo oder PTR und wähle sie neben der Spiel-Schaltfläche. Die zuvor verwendete Datei wird gesichert.
|
||||||
|
- **Konten und Einstellungen.** Verwalte Namen, Passwörter und Zugriffsrechte. Für Server und Bots gibt es verständliche Optionen und Voreinstellungen, außerdem eine Serverkonsole und eine Spielerliste mit Kontoverwaltung.
|
||||||
|
- **Module.** Aktiviere Zusatzfunktionen, öffne ihre Einstellungen oder die GitHub-Seite des jeweiligen Projekts.
|
||||||
|
- **Mit Freunden spielen.** Erreichbarkeit prüfen, Firewall und UPnP einrichten und Verbindungen über LAN, direkte Adressen oder private Netze/Tailscale vorbereiten. Anleitungen und ein Paket mit Verbindungsdaten helfen deinen Freunden beim Beitritt.
|
||||||
|
- **Probleme melden.** Bereite einen GitHub-Fehlerbericht mit automatisch eingetragenen Versionsangaben vor.
|
||||||
|
- **Managerupdates.** Sie werden im Hintergrund geladen und beim Schließen installiert. Deine Server werden dabei weder angehalten noch verändert.
|
||||||
|
- **Sprachen:** Englisch, Russisch, Deutsch, Französisch, Spanisch und vereinfachtes Chinesisch.
|
||||||
|
|
||||||
|
## Screenshots und Anleitungen
|
||||||
|
|
||||||
|
| Portable Characters — experimentell | Öffentliche Realms |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
| Begleiter | Sicherungen |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
[Zur Galerie](docs/de/SCREENSHOTS.md) · [Alle Anleitungen](docs/de/README.md). Die Galerie zeigt auch Einrichtung, Module, Spielclient, Verbindungen mit Freunden und die Übernahme eines vorhandenen Charakters.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Lade das Installationsprogramm von der [Release-Seite](https://github.com/Corfirean/coa-server-manager/releases/latest) herunter und starte es. Für den Server brauchst du etwa 10 GB freien Speicher. Der Spielclient benötigt zusätzlich etwa 43 GB: Wähle einen vorhandenen Client oder lade ihn über den Manager.
|
||||||
|
|
||||||
|
## Änderungen
|
||||||
|
|
||||||
|
[Manager-Changelog](CHANGELOG.md) · [Server-Changelog](https://github.com/Corfirean/coa-server-build/blob/main/CHANGELOG.md). Manager und Server haben getrennte Versionsverläufe. Ein Managerupdate aktualisiert nicht den Server.
|
||||||
|
|
||||||
|
## Projektstatus
|
||||||
|
|
||||||
|
**In aktiver Entwicklung.** Fehler sind weiterhin möglich. Wenn du ein Problem findest, [erstelle bitte ein Issue](https://github.com/Corfirean/coa-server-manager/issues/new/choose).
|
||||||
|
|
||||||
|
### Bekannte Einschränkungen
|
||||||
|
|
||||||
|
- Der Ascension-Client 3.3.5 nimmt keine Zugangsdaten über die Kommandozeile an. Gib dein Passwort selbst ein oder verknüpfe ein bestehendes Konto.
|
||||||
|
- Windows schützt vertrauliche Daten mit DPAPI (`CryptProtectData`) und zusätzlicher Entropie zur Domänentrennung. Linux/macOS verwenden Dateien mit den Zugriffsrechten `0600`.
|
||||||
|
- Eine bestehende direkte TCP-Verbindung lässt sich nicht während der Sitzung auf einen Relay umstellen. Nach einem Verbindungsabbruch wird beim nächsten Beitritt automatisch auf die Ausweichroute zurückgegriffen.
|
||||||
|
- Für sichere entfernte Importe portabler Charaktere muss `CharacterDatabase.WorkerThreads = 1` bleiben; das ist der Standardwert.
|
||||||
|
|
||||||
|
## Entwicklung
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install
|
||||||
|
cargo test --workspace
|
||||||
|
npx tsc --noEmit
|
||||||
|
node tools/check-i18n.mjs
|
||||||
|
npx vite
|
||||||
|
cargo build -p coa-server-manager
|
||||||
|
```
|
||||||
|
|
||||||
|
Die Befehle installieren Abhängigkeiten, führen Tests aus, prüfen Typen und Übersetzungen, starten die Browseransicht mit Testdaten und bauen die native Anwendung. Der Debug-Build verwendet `http://localhost:1420`.
|
||||||
|
|
||||||
|
Die Programmlogik liegt in `crates/coa-core`, Paket- und Signaturwerkzeuge in `crates/coa-release`, native Befehle in `src-tauri` und die Oberfläche in `src`.
|
||||||
|
|
||||||
|
`cargo run -p coa-core --example scan -- <folder>` prüft eine vorhandene Installation nur lesend. Verwende für Start-/Stopp-Tests ausschließlich eine entbehrliche Testkopie: `tools/make-fixture.ps1` erstellt `C:\games\coa-fixture` aus der unveränderten Paketdatenbank mit anderen Ports. Teste niemals an einem genutzten Server. `tests/e2e/cdp.mjs` steuert das echte Fenster über WebView2 mit `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9222`.
|
||||||
|
|
||||||
|
## Lizenz
|
||||||
|
|
||||||
|
Der Manager ist freie Software unter der [GNU AGPL v3.0](LICENSE), Kennung `AGPL-3.0-only`.
|
||||||
|
|
||||||
|
- Der installierte Server basiert auf einem öffentlichen [AzerothCore-Fork](https://github.com/Corfirean/azerothcore-wotlk-coa). Für von MaNGOS übernommene Teile gilt GPL-2.0-or-later, für eigene AzerothCore-Teile AGPL-3.0. [mod-coa-playerbots](https://github.com/Corfirean/mod-coa-playerbots) steht unter AGPL-3.0. Die exakten Quellstände stehen im Paketmanifest, damit der passende Quellcode auffindbar bleibt.
|
||||||
|
- Das mitgelieferte MySQL behält seine GPL-2.0-Lizenz; der Lizenztext liegt im Paket unter `Licenses`.
|
||||||
|
- Die Spieldaten in `Data` (`dbc`, `maps`, `vmaps`, `mmaps`) stammen aus dem Client des eingestellten Ascension-Realms Conquest of Azeroth. Sie fallen **nicht** unter die Lizenz des Managers.
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
# CoA Server Manager
|
||||||
|
|
||||||
|
[English](README.md) · [Русский](README.ru.md) · [Deutsch](README.de.md) · [Français](README.fr.md) · **Español** · [简体中文](README.zh-CN.md)
|
||||||
|
|
||||||
|
**Los personajes portátiles son una función experimental.** Sigue en desarrollo y puede contener errores.
|
||||||
|
|
||||||
|
Una aplicación para Windows con la que instalar y gestionar tu propio servidor de **Conquest of Azeroth**, basado en AzerothCore, en pocos pasos. No necesitas usar la consola, editar archivos de configuración a mano ni manejar programas de bases de datos. Creada con Tauri 2, Rust y React.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Funciones
|
||||||
|
|
||||||
|
- **Personajes portátiles — experimental.** Guarda personajes y sus distintas versiones en el Manager, o convierte en portátil un personaje que ya tengas en un reino al que puedas acceder. [Ver la guía](docs/es/PORTABLE-CHARACTERS.md).
|
||||||
|
- **Buscador de reinos.** Compara reinos públicos por modo de juego, nivel máximo, multiplicadores, módulos y población.
|
||||||
|
- **Instalación sencilla.** Descarga un paquete de servidor firmado, comprueba los archivos, prepara la base de datos y crea tu primera cuenta. Las descargas se pueden reanudar. También puedes importar un servidor existente.
|
||||||
|
- **Iniciar, detener y jugar.** Controla conjuntamente la base de datos y los servidores de autenticación y mundo. Consulta su estado, tiempo de actividad y jugadores conectados. Al abrir el juego se utiliza la realmlist correcta.
|
||||||
|
- **Cliente de juego.** Usa el que ya tengas o descárgalo desde el Manager: unos 43 GB, con descarga reanudable y verificación de archivos. Los clientes gestionados reciben avisos de actualización; los archivos que hayas modificado solo se sustituyen con tu permiso.
|
||||||
|
- **Actualizaciones del servidor.** Se buscan al iniciar y cada cinco minutos. Los paquetes se verifican mediante firmas Ed25519, se crea una copia antes de actualizar, se conservan tus cambios y es posible volver atrás.
|
||||||
|
- **Copias de seguridad.** Guarda personajes, cuentas y ajustes cuando quieras o automáticamente antes de una actualización. Comprueba y restaura las copias desde la aplicación.
|
||||||
|
- **CoA, Wildcard y Warcraft Reborn.** Elige el reino en Resumen. La versión del servidor debe admitir el modo seleccionado. El primer cambio crea un mundo independiente y una base de personajes vacía. Las cuentas son compartidas; los personajes y los ajustes de módulos se mantienen separados. Si el servidor está encendido, guarda los personajes y se reinicia al cambiar. Cierra el cliente antes del cambio; si está abierto, el nuevo reino se aplicará la próxima vez que lo abras desde el Manager. No hay bots en Wildcard ni en Warcraft Reborn; los demás módulos opcionales son experimentales allí. Las copias y las actualizaciones cubren todos los reinos creados. CoA y Wildcard pueden funcionar a la vez. [Wildcard](docs/es/WILDCARD.md) · [Warcraft Reborn](docs/es/WARCRAFT-REBORN.md).
|
||||||
|
- **Bots compañeros.** Llena el mundo con bots de nivel adecuado, sigue su creación, ponla en pausa o desconecta los bots. Elimina una cantidad concreta para reducir la carga y decide cuántos se conectan al iniciar el servidor.
|
||||||
|
- **Cambio de realmlist.** Guarda conexiones con nombres como Solo o PTR y selecciónalas junto al botón de jugar. El archivo anterior se guarda antes de sustituirlo.
|
||||||
|
- **Cuentas y ajustes.** Gestiona nombres, contraseñas y permisos. Configura el servidor y los bots con opciones explicadas y ajustes predefinidos. También tienes una consola de servidor y una lista de jugadores con herramientas de cuentas.
|
||||||
|
- **Módulos.** Activa funciones adicionales, cambia sus ajustes o abre el repositorio de sus autores desde la misma página.
|
||||||
|
- **Jugar con amigos.** Comprueba si pueden acceder, configura el cortafuegos y UPnP, y prepara conexiones por LAN, dirección directa o red privada/Tailscale. Incluye guías y un paquete con los datos de conexión para compartir.
|
||||||
|
- **Informar de problemas.** Prepara un informe para GitHub con las versiones ya rellenadas.
|
||||||
|
- **Actualizaciones del Manager.** Se descargan en segundo plano y se instalan al cerrar la aplicación. No detienen ni modifican tus servidores.
|
||||||
|
- **Idiomas:** inglés, ruso, alemán, francés, español y chino simplificado.
|
||||||
|
|
||||||
|
## Capturas y guías
|
||||||
|
|
||||||
|
| Personajes portátiles — experimental | Reinos públicos |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
| Compañeros | Copias de seguridad |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
[Galería completa](docs/es/SCREENSHOTS.md) · [Todas las guías](docs/es/README.md). También encontrarás la instalación, los módulos, el cliente, las conexiones con amigos y cómo convertir un personaje existente en portátil.
|
||||||
|
|
||||||
|
## Instalación
|
||||||
|
|
||||||
|
Descarga el instalador desde la [página de versiones](https://github.com/Corfirean/coa-server-manager/releases/latest) y ejecútalo. Necesitas unos 10 GB libres para el servidor. El cliente se instala por separado y ocupa unos 43 GB: indica tu carpeta existente o descárgalo con el Manager.
|
||||||
|
|
||||||
|
## Historial de cambios
|
||||||
|
|
||||||
|
[Cambios del Manager](CHANGELOG.md) · [Cambios del servidor](https://github.com/Corfirean/coa-server-build/blob/main/CHANGELOG.md). Sus versiones se siguen por separado. Actualizar el Manager no actualiza el servidor.
|
||||||
|
|
||||||
|
## Estado del proyecto
|
||||||
|
|
||||||
|
**En desarrollo activo.** Todavía puede haber errores. Si encuentras un problema, [abre una incidencia](https://github.com/Corfirean/coa-server-manager/issues/new/choose).
|
||||||
|
|
||||||
|
### Limitaciones conocidas
|
||||||
|
|
||||||
|
- El cliente Ascension 3.3.5 no acepta credenciales por línea de comandos. Introduce la contraseña manualmente o vincula una cuenta existente.
|
||||||
|
- En Windows, los secretos se protegen con DPAPI (`CryptProtectData`) y entropía para separar dominios. Linux/macOS usan archivos con permisos `0600`.
|
||||||
|
- Una conexión TCP directa ya establecida no puede pasar a un relé a mitad de sesión. Tras una interrupción, la ruta alternativa se selecciona automáticamente en la siguiente conexión.
|
||||||
|
- Para importar personajes portátiles de forma remota con seguridad, mantén `CharacterDatabase.WorkerThreads = 1`, su valor predeterminado.
|
||||||
|
|
||||||
|
## Desarrollo
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install
|
||||||
|
cargo test --workspace
|
||||||
|
npx tsc --noEmit
|
||||||
|
node tools/check-i18n.mjs
|
||||||
|
npx vite
|
||||||
|
cargo build -p coa-server-manager
|
||||||
|
```
|
||||||
|
|
||||||
|
Estos comandos instalan dependencias, ejecutan pruebas, comprueban tipos y traducciones, abren la interfaz en el navegador con datos de prueba y compilan la aplicación nativa. La versión de depuración utiliza `http://localhost:1420`.
|
||||||
|
|
||||||
|
La lógica está en `crates/coa-core`, las herramientas de empaquetado y firma en `crates/coa-release`, los comandos nativos en `src-tauri` y la interfaz en `src`.
|
||||||
|
|
||||||
|
`cargo run -p coa-core --example scan -- <folder>` inspecciona una instalación sin modificarla. Para probar el inicio y la parada, usa solo una copia desechable: `tools/make-fixture.ps1` crea `C:\games\coa-fixture` a partir de la base intacta del paquete y con puertos diferentes. No hagas estas pruebas en un servidor en uso. `tests/e2e/cdp.mjs` controla la ventana real mediante WebView2 con `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9222`.
|
||||||
|
|
||||||
|
## Licencia
|
||||||
|
|
||||||
|
El Manager es software libre bajo [GNU AGPL v3.0](LICENSE), identificador `AGPL-3.0-only`.
|
||||||
|
|
||||||
|
- El servidor instalado procede de un [fork público de AzerothCore](https://github.com/Corfirean/azerothcore-wotlk-coa). Las partes heredadas de MaNGOS usan GPL-2.0-or-later y las propias de AzerothCore, AGPL-3.0. [mod-coa-playerbots](https://github.com/Corfirean/mod-coa-playerbots) utiliza AGPL-3.0. El manifiesto de cada paquete indica los commits exactos para localizar el código fuente correspondiente.
|
||||||
|
- MySQL conserva su licencia GPL-2.0; el texto se incluye en la carpeta `Licenses` del paquete.
|
||||||
|
- Los datos de juego de `Data` (`dbc`, `maps`, `vmaps`, `mmaps`) se extrajeron del cliente del antiguo reino Ascension Conquest of Azeroth. **No** están cubiertos por la licencia del Manager.
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
# CoA Server Manager
|
||||||
|
|
||||||
|
[English](README.md) · [Русский](README.ru.md) · [Deutsch](README.de.md) · **Français** · [Español](README.es.md) · [简体中文](README.zh-CN.md)
|
||||||
|
|
||||||
|
**Les personnages portables sont une fonctionnalité expérimentale.** Elle est encore en développement et peut présenter des bugs.
|
||||||
|
|
||||||
|
Une application Windows pour installer et gérer votre propre serveur **Conquest of Azeroth**, basé sur AzerothCore, en quelques étapes. Pas besoin de console, de modifier les fichiers de configuration à la main ou d'utiliser un outil de base de données. L'application utilise Tauri 2, Rust et React.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Fonctionnalités
|
||||||
|
|
||||||
|
- **Personnages portables — expérimental.** Conservez vos personnages et leurs sauvegardes dans le Manager, ou rendez portable un personnage déjà présent sur un royaume auquel vous avez accès. [Voir le guide](docs/fr/PORTABLE-CHARACTERS.md).
|
||||||
|
- **Découverte des royaumes.** Comparez les royaumes publics selon leur mode de jeu, niveau maximal, taux de progression, modules et population.
|
||||||
|
- **Installation simplifiée.** Le Manager télécharge un paquet serveur signé, vérifie les fichiers, configure la base de données et crée votre premier compte. Les téléchargements peuvent reprendre après une interruption. Vous pouvez aussi importer un serveur existant.
|
||||||
|
- **Démarrer, arrêter, jouer.** Une commande suffit pour gérer la base de données et les serveurs d'authentification et de monde. L'état, la durée de fonctionnement et les joueurs connectés restent visibles. Le lancement du jeu utilise la bonne realmlist.
|
||||||
|
- **Gestion du client de jeu.** Utilisez votre client ou téléchargez-le depuis l'application : environ 43 Go, avec reprise et vérification des fichiers. Un client géré reçoit des mises à jour ; vos fichiers modifiés ne sont remplacés qu'avec votre accord.
|
||||||
|
- **Mises à jour du serveur.** Recherche au démarrage et toutes les cinq minutes, vérification des signatures Ed25519, sauvegarde préalable, conservation des modifications personnelles et possibilité de revenir en arrière.
|
||||||
|
- **Sauvegardes.** Enregistrez personnages, comptes et paramètres à la demande ou automatiquement avant les mises à jour. Vérifiez et restaurez les sauvegardes dans l'application.
|
||||||
|
- **CoA, Wildcard et Warcraft Reborn.** Choisissez le royaume dans Vue d'ensemble. La version du serveur doit prendre en charge le mode choisi. Le premier changement crée un monde distinct et une base de personnages vide. Les comptes sont partagés, mais personnages et réglages des modules restent séparés. Un serveur en cours d'exécution sauvegarde les personnages puis redémarre lors du changement. Fermez le client avant de changer de royaume ; s'il est ouvert, le choix prendra effet au prochain lancement depuis le Manager. Les bots sont indisponibles sur Wildcard et Warcraft Reborn ; les autres modules optionnels y sont expérimentaux. Sauvegardes et mises à jour couvrent tous les royaumes créés. CoA et Wildcard peuvent fonctionner ensemble. [Wildcard](docs/fr/WILDCARD.md) · [Warcraft Reborn](docs/fr/WARCRAFT-REBORN.md).
|
||||||
|
- **Bots compagnons.** Peuplez le monde avec des bots de niveau adapté, suivez leur création, mettez-la en pause ou déconnectez les bots. Retirez un nombre choisi de bots pour alléger le serveur et réglez combien se connectent au démarrage.
|
||||||
|
- **Changement de realmlist.** Enregistrez des connexions nommées, comme Solo et PTR, et choisissez-les à côté du bouton de jeu. Le fichier précédent est sauvegardé avant remplacement.
|
||||||
|
- **Comptes et réglages.** Gérez noms, mots de passe et droits d'accès. Configurez serveur et bots avec des options expliquées et des préréglages. Une console serveur et une liste des joueurs avec gestion des comptes sont également disponibles.
|
||||||
|
- **Modules.** Activez les fonctions supplémentaires, modifiez leurs réglages ou consultez leur projet GitHub depuis une même page.
|
||||||
|
- **Jouer avec des amis.** Vérifiez l'accessibilité du serveur, configurez pare-feu et UPnP, préparez une connexion en réseau local, directe ou via un réseau privé/Tailscale. Des guides et un paquet de connexion facilitent l'arrivée des amis.
|
||||||
|
- **Signalement des problèmes.** Préparez un rapport GitHub avec les versions déjà renseignées.
|
||||||
|
- **Mises à jour du Manager.** Téléchargées en arrière-plan, elles s'installent à la fermeture. Elles n'arrêtent pas vos serveurs et ne les modifient pas.
|
||||||
|
- **Langues :** anglais, russe, allemand, français, espagnol et chinois simplifié.
|
||||||
|
|
||||||
|
## Captures et guides
|
||||||
|
|
||||||
|
| Personnages portables — expérimental | Royaumes publics |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
| Compagnons | Sauvegardes |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
[Galerie complète](docs/fr/SCREENSHOTS.md) · [Tous les guides](docs/fr/README.md). La galerie présente aussi l'installation, les modules, le client, les connexions entre amis et la création d'un personnage portable.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Téléchargez et lancez l'installateur depuis les [publications GitHub](https://github.com/Corfirean/coa-server-manager/releases/latest). Prévoyez environ 10 Go libres pour le serveur. Le client de jeu est séparé et demande environ 43 Go : indiquez un dossier existant ou téléchargez-le avec le Manager.
|
||||||
|
|
||||||
|
## Historique des versions
|
||||||
|
|
||||||
|
[Changelog du Manager](CHANGELOG.md) · [Changelog du serveur](https://github.com/Corfirean/coa-server-build/blob/main/CHANGELOG.md). Leurs versions sont suivies séparément : mettre à jour le Manager ne met pas à jour le serveur.
|
||||||
|
|
||||||
|
## État du projet
|
||||||
|
|
||||||
|
**En développement actif.** Des bugs restent possibles. Si vous rencontrez un problème, [ouvrez une issue](https://github.com/Corfirean/coa-server-manager/issues/new/choose).
|
||||||
|
|
||||||
|
### Limites connues
|
||||||
|
|
||||||
|
- Le client Ascension 3.3.5 n'accepte pas les identifiants en ligne de commande. Saisissez votre mot de passe ou associez un compte existant.
|
||||||
|
- Windows protège les secrets avec DPAPI (`CryptProtectData`) et une entropie de séparation de domaine. Sous Linux/macOS, ils sont conservés dans des fichiers aux permissions `0600`.
|
||||||
|
- Une connexion TCP directe déjà établie ne peut pas basculer vers un relais en cours de session. Après une coupure, le repli automatique intervient à la connexion suivante.
|
||||||
|
- Pour importer à distance des personnages portables en sécurité, conservez `CharacterDatabase.WorkerThreads = 1`, la valeur par défaut.
|
||||||
|
|
||||||
|
## Développement
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install
|
||||||
|
cargo test --workspace
|
||||||
|
npx tsc --noEmit
|
||||||
|
node tools/check-i18n.mjs
|
||||||
|
npx vite
|
||||||
|
cargo build -p coa-server-manager
|
||||||
|
```
|
||||||
|
|
||||||
|
Ces commandes installent les dépendances, exécutent les tests, contrôlent les types et les traductions, ouvrent l'interface dans le navigateur avec des données de test, puis compilent l'application native. En mode debug, celle-ci utilise `http://localhost:1420`.
|
||||||
|
|
||||||
|
La logique se trouve dans `crates/coa-core`, les outils de paquetage et de signature dans `crates/coa-release`, les commandes natives dans `src-tauri` et l'interface dans `src`.
|
||||||
|
|
||||||
|
`cargo run -p coa-core --example scan -- <folder>` inspecte une installation sans la modifier. Pour tester démarrage et arrêt, utilisez uniquement une copie jetable : `tools/make-fixture.ps1` crée `C:\games\coa-fixture` depuis la base intacte du paquet, avec des ports distincts. Ne testez jamais sur un serveur utilisé par des joueurs. `tests/e2e/cdp.mjs` pilote la véritable fenêtre via WebView2 avec `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9222`.
|
||||||
|
|
||||||
|
## Licence
|
||||||
|
|
||||||
|
Le Manager est un logiciel libre sous [GNU AGPL v3.0](LICENSE), identifiant `AGPL-3.0-only`.
|
||||||
|
|
||||||
|
- Le serveur installé provient d'un [fork public d'AzerothCore](https://github.com/Corfirean/azerothcore-wotlk-coa). Les parties héritées de MaNGOS relèvent de GPL-2.0-or-later et les parties propres à AzerothCore d'AGPL-3.0. [mod-coa-playerbots](https://github.com/Corfirean/mod-coa-playerbots) utilise AGPL-3.0. Les commits exacts figurent dans le manifeste de chaque paquet pour retrouver les sources correspondantes.
|
||||||
|
- MySQL conserve sa licence GPL-2.0 ; son texte est fourni dans le dossier `Licenses` du paquet.
|
||||||
|
- Les données de jeu dans `Data` (`dbc`, `maps`, `vmaps`, `mmaps`) proviennent du client de l'ancien royaume Ascension Conquest of Azeroth. Elles ne sont **pas** couvertes par la licence du Manager.
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
# CoA Server Manager
|
# CoA Server Manager
|
||||||
|
|
||||||
|
**English** · [Русский](README.ru.md) · [Deutsch](README.de.md) · [Français](README.fr.md) · [Español](README.es.md) · [简体中文](README.zh-CN.md)
|
||||||
|
|
||||||
**Portable characters are experimental.** This feature is in active development and may contain bugs.
|
**Portable characters are experimental.** This feature is in active development and may contain bugs.
|
||||||
|
|
||||||
A Windows app that installs and runs your own **Conquest of Azeroth** server (AzerothCore) with a few clicks:
|
A Windows app that installs and runs your own **Conquest of Azeroth** server (AzerothCore) with a few clicks:
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
# CoA Server Manager
|
||||||
|
|
||||||
|
[English](README.md) · **Русский** · [Deutsch](README.de.md) · [Français](README.fr.md) · [Español](README.es.md) · [简体中文](README.zh-CN.md)
|
||||||
|
|
||||||
|
**Переносимые персонажи — экспериментальная функция.** Она ещё развивается и может работать с ошибками.
|
||||||
|
|
||||||
|
Приложение для Windows, с которым можно установить и запустить свой сервер **Conquest of Azeroth** на базе AzerothCore за несколько шагов. Управляйте сервером через интерфейс, без консоли, ручного редактирования конфигов и отдельных программ для базы данных. Менеджер написан на Tauri 2, Rust и React.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Возможности
|
||||||
|
|
||||||
|
- **Переносимые персонажи — экспериментально.** Храните персонажей и историю сохранений в менеджере, делайте переносимыми уже существующих персонажей с доступных вам реалмов. [Как это работает](docs/ru/PORTABLE-CHARACTERS.md).
|
||||||
|
- **Каталог реалмов.** Сравнивайте публичные серверы по режиму игры, максимальному уровню, рейтам, модулям и числу игроков.
|
||||||
|
- **Простая установка.** Менеджер скачивает подписанный пакет сервера, проверяет файлы, настраивает базу данных и создаёт первый аккаунт. Прерванную загрузку можно продолжить. Можно также подключить уже установленный сервер.
|
||||||
|
- **Запуск, остановка и игра.** Управляйте базой данных и обоими серверными процессами одной кнопкой. На главном экране видны состояние, время работы и игроки онлайн. Кнопка запуска игры выбирает нужный realmlist.
|
||||||
|
- **Игровой клиент.** Подключите свой клиент или скачайте его через менеджер — около 43 ГБ, с продолжением загрузки и проверкой файлов. Для управляемого клиента доступны обновления; ваши изменения заменяются только с вашего согласия.
|
||||||
|
- **Обновления сервера.** Проверка выполняется при запуске и каждые пять минут. Пакеты защищены подписью Ed25519; перед установкой создаётся резервная копия. Пользовательские изменения сохраняются, предусмотрен откат.
|
||||||
|
- **Резервные копии.** Сохраняйте персонажей, аккаунты и настройки вручную или автоматически перед обновлениями. Проверка и восстановление доступны в приложении.
|
||||||
|
- **CoA, Wildcard и Warcraft Reborn.** Выбирайте реалм в разделе «Обзор». Нужна серверная сборка с поддержкой выбранного режима. При первом переключении создаются отдельный мир и пустая база персонажей. Аккаунты общие, персонажи и настройки модулей раздельные. Переключение работающего сервера сохраняет персонажей и перезапускает его. Закройте клиент перед переключением; если он открыт, новый реалм будет выбран при следующем запуске через менеджер. Боты недоступны в Wildcard и Warcraft Reborn, остальные дополнительные модули там экспериментальны. Копии и обновления охватывают все созданные реалмы. Одновременно можно запускать CoA и Wildcard. [Гайд по Wildcard](docs/ru/WILDCARD.md) · [Warcraft Reborn](docs/ru/WARCRAFT-REBORN.md).
|
||||||
|
- **Компаньоны-боты.** Заселяйте мир ботами подходящего уровня, следите за созданием, приостанавливайте его, отключайте ботов или удаляйте нужное количество для снижения нагрузки. Можно задать число ботов при старте сервера.
|
||||||
|
- **Список подключений.** Сохраняйте несколько realmlist с понятными названиями, например Solo и PTR, и переключайте их рядом с кнопкой игры. Предыдущий файл сохраняется.
|
||||||
|
- **Аккаунты и настройки.** Управляйте именами, паролями и уровнями доступа. Настраивайте сервер и ботов через понятные параметры и готовые наборы; доступны консоль сервера и список игроков.
|
||||||
|
- **Модули.** Включайте дополнительные возможности, меняйте их настройки и переходите в репозитории авторов с одной страницы.
|
||||||
|
- **Игра с друзьями.** Проверка доступности, настройка брандмауэра и UPnP, подключение по локальной сети, напрямую или через частную сеть/Tailscale. Внутри есть пошаговые инструкции и пакет с данными подключения для друзей.
|
||||||
|
- **Сообщения об ошибках.** Менеджер помогает подготовить issue на GitHub и подставляет версии программ.
|
||||||
|
- **Обновление менеджера.** Загружается в фоне и устанавливается при закрытии приложения. Ваши серверы при этом не останавливаются и не изменяются.
|
||||||
|
- **Языки:** английский, русский, немецкий, французский, испанский и упрощённый китайский.
|
||||||
|
|
||||||
|
## Скриншоты и гайды
|
||||||
|
|
||||||
|
| Переносимые персонажи — экспериментально | Публичные реалмы |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
| Компаньоны | Резервные копии |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
[Все скриншоты](docs/ru/SCREENSHOTS.md) · [Гайды для игроков и владельцев серверов](docs/ru/README.md). В галерее также показаны установка, модули, клиент, подключение друзей и создание переносимого персонажа.
|
||||||
|
|
||||||
|
## Установка
|
||||||
|
|
||||||
|
Скачайте установщик со страницы [релизов](https://github.com/Corfirean/coa-server-manager/releases/latest) и запустите его. Для сервера нужно около 10 ГБ свободного места. Клиент устанавливается отдельно и занимает около 43 ГБ: укажите существующую папку или скачайте его через менеджер.
|
||||||
|
|
||||||
|
## Что изменилось
|
||||||
|
|
||||||
|
[Ченджлог менеджера](CHANGELOG.md) · [Ченджлог сервера](https://github.com/Corfirean/coa-server-build/blob/main/CHANGELOG.md). Это отдельные продукты с отдельной историей версий: обновление менеджера не обновляет сервер.
|
||||||
|
|
||||||
|
## Состояние проекта
|
||||||
|
|
||||||
|
**Проект активно развивается.** Ошибки ещё возможны. Если встретили проблему, [создайте issue](https://github.com/Corfirean/coa-server-manager/issues/new/choose).
|
||||||
|
|
||||||
|
### Известные ограничения
|
||||||
|
|
||||||
|
- Клиент Ascension 3.3.5 не принимает логин и пароль через командную строку. Введите пароль вручную или привяжите существующий аккаунт.
|
||||||
|
- В Windows секреты защищены DPAPI (`CryptProtectData`) с отдельной энтропией домена. На Linux/macOS используются файлы с правами `0600`.
|
||||||
|
- Уже открытое прямое TCP-соединение нельзя переключить на ретранслятор без разрыва. Резервный маршрут выбирается при следующем подключении.
|
||||||
|
- Для безопасного удалённого импорта переносимых персонажей оставьте `CharacterDatabase.WorkerThreads = 1` — это значение по умолчанию.
|
||||||
|
|
||||||
|
## Разработка
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install
|
||||||
|
cargo test --workspace
|
||||||
|
npx tsc --noEmit
|
||||||
|
node tools/check-i18n.mjs
|
||||||
|
npx vite
|
||||||
|
cargo build -p coa-server-manager
|
||||||
|
```
|
||||||
|
|
||||||
|
Команды устанавливают зависимости, запускают тесты, проверяют типы и переводы, открывают браузерный интерфейс с тестовыми данными и собирают нативное приложение. В отладочном режиме оно использует `http://localhost:1420`.
|
||||||
|
|
||||||
|
`crates/coa-core` содержит основную логику, `crates/coa-release` — упаковку и подписи, `src-tauri` — команды приложения, `src` — интерфейс.
|
||||||
|
|
||||||
|
Проверить существующую сборку без изменений можно командой `cargo run -p coa-core --example scan -- <folder>`. Для проверок запуска и остановки используйте только отдельную тестовую копию: `tools/make-fixture.ps1` создаёт `C:\games\coa-fixture` из чистой базы пакета, с другими портами. Не проводите такие проверки на сервере, которым пользуются игроки. `tests/e2e/cdp.mjs` управляет настоящим окном через WebView2 с `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9222`.
|
||||||
|
|
||||||
|
## Лицензия
|
||||||
|
|
||||||
|
Менеджер — свободное ПО под [GNU AGPL v3.0](LICENSE), идентификатор `AGPL-3.0-only`.
|
||||||
|
|
||||||
|
- Устанавливаемый сервер основан на [форке AzerothCore](https://github.com/Corfirean/azerothcore-wotlk-coa): части, унаследованные от MaNGOS, используют GPL-2.0-or-later, собственные части AzerothCore — AGPL-3.0. Модуль [mod-coa-playerbots](https://github.com/Corfirean/mod-coa-playerbots) использует AGPL-3.0. Точные коммиты записываются в манифест пакета, чтобы можно было найти соответствующий исходный код.
|
||||||
|
- MySQL распространяется по собственной лицензии GPL-2.0; её текст находится в папке `Licenses` пакета.
|
||||||
|
- Данные игры в `Data` (`dbc`, `maps`, `vmaps`, `mmaps`) извлечены из клиента закрытого реалма Ascension Conquest of Azeroth. Лицензия менеджера на них **не распространяется**.
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
# CoA Server Manager
|
||||||
|
|
||||||
|
[English](README.md) · [Русский](README.ru.md) · [Deutsch](README.de.md) · [Français](README.fr.md) · [Español](README.es.md) · **简体中文**
|
||||||
|
|
||||||
|
**便携角色是一项实验性功能。** 目前仍在开发中,使用时可能遇到问题。
|
||||||
|
|
||||||
|
这是一款 Windows 应用,帮助你用几个简单步骤搭建和管理自己的 **Conquest of Azeroth** 服务器,服务端基于 AzerothCore。日常操作不需要使用控制台、手动修改配置文件或单独操作数据库。应用采用 Tauri 2、Rust 和 React 开发。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 主要功能
|
||||||
|
|
||||||
|
- **便携角色(实验性)。** 在管理器中保存角色及其历史存档,也可以将有权访问的服务器上的现有角色转换为便携角色。[查看使用指南](docs/zh-CN/PORTABLE-CHARACTERS.md)。
|
||||||
|
- **查找服务器。** 浏览公开服务器,对比游戏模式、等级上限、倍率、模块和在线人数。
|
||||||
|
- **轻松安装。** 下载带签名的服务端安装包,逐一校验文件,配置数据库并创建首个账号。下载支持断点续传,也可以导入已有服务器。
|
||||||
|
- **启动、停止和进入游戏。** 一处控制数据库、认证服务和世界服务,随时查看运行状态、运行时间和在线玩家。启动游戏时会自动使用对应的 realmlist。
|
||||||
|
- **管理游戏客户端。** 指定现有客户端,或通过管理器下载约 43 GB 的客户端。下载可以续传,文件会经过校验。受管理的客户端可以检查更新;自行修改的文件只有在你同意后才会被替换。
|
||||||
|
- **更新服务器。** 应用启动时及之后每五分钟检查一次更新。安装包通过 Ed25519 签名验证,更新前自动备份,保留用户修改,并支持回滚。
|
||||||
|
- **备份与恢复。** 手动备份角色、账号和设置,或在更新前自动备份。在应用中即可校验和恢复。
|
||||||
|
- **CoA、Wildcard 和 Warcraft Reborn。** 在概览中选择服务器模式,服务端版本必须支持所选模式。首次切换会创建独立的世界数据库和空的角色数据库。各模式共用账号,角色和模块设置相互独立。运行中切换会先保存角色,再重启服务器。切换前请关闭客户端;如果客户端仍开着,新选择会在下次通过管理器启动游戏时生效。Wildcard 和 Warcraft Reborn 不支持机器人,其他可选模块在这两种模式下也属于实验性支持。备份和数据库更新涵盖所有已创建的模式。目前支持 CoA 与 Wildcard 同时运行。[Wildcard 指南](docs/zh-CN/WILDCARD.md) · [Warcraft Reborn 指南](docs/zh-CN/WARCRAFT-REBORN.md)。
|
||||||
|
- **伙伴机器人。** 创建等级合适的机器人并查看进度,暂停创建、让机器人下线,或移除指定数量以减轻服务器负担。也可以设置开服时登录的机器人数量。
|
||||||
|
- **切换 realmlist。** 为不同连接保存名称,例如 Solo 和 PTR,在进入游戏按钮旁直接切换。替换前会保存原文件。
|
||||||
|
- **账号和设置。** 管理账号名称、密码和权限,通过说明清楚的选项及预设调整服务器和机器人。还提供世界服务器控制台,以及带账号管理功能的玩家列表。
|
||||||
|
- **模块管理。** 在同一页面启用可选功能、调整设置,或打开相应项目的 GitHub 页面。
|
||||||
|
- **好友联机。** 检查服务器是否可达,配置防火墙和 UPnP,支持局域网、直接连接及私有网络/Tailscale。应用提供分步说明,还能准备可分享的连接资料包。
|
||||||
|
- **报告问题。** 帮你准备 GitHub 问题报告,并自动填写版本信息。
|
||||||
|
- **管理器自身更新。** 在后台下载,关闭应用时安装。更新管理器不会停止或修改你的服务器。
|
||||||
|
- **支持语言:** 英语、俄语、德语、法语、西班牙语和简体中文。
|
||||||
|
|
||||||
|
## 截图与指南
|
||||||
|
|
||||||
|
| 便携角色(实验性) | 公开服务器 |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
| 伙伴机器人 | 备份 |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
[查看完整截图](docs/zh-CN/SCREENSHOTS.md) · [玩家与服主指南](docs/zh-CN/README.md)。图库还展示了初始设置、模块、客户端、朋友联机,以及将现有角色转换为便携角色的流程。
|
||||||
|
|
||||||
|
## 安装
|
||||||
|
|
||||||
|
从 [GitHub 发布页](https://github.com/Corfirean/coa-server-manager/releases/latest)下载安装程序并运行。服务器约需 10 GB 可用空间。游戏客户端单独安装,约占 43 GB;你可以指定已有客户端目录,也可以交给管理器下载。
|
||||||
|
|
||||||
|
## 更新记录
|
||||||
|
|
||||||
|
[管理器更新记录](CHANGELOG.md) · [服务器更新记录](https://github.com/Corfirean/coa-server-build/blob/main/CHANGELOG.md)。两者的版本和更新记录分别维护。更新管理器不会同时更新服务器。
|
||||||
|
|
||||||
|
## 项目状态
|
||||||
|
|
||||||
|
**正在积极开发中。** 仍可能存在问题。如果遇到故障,请[提交 issue](https://github.com/Corfirean/coa-server-manager/issues/new/choose)。
|
||||||
|
|
||||||
|
### 已知限制
|
||||||
|
|
||||||
|
- Ascension 3.3.5 客户端不支持通过命令行传入账号和密码。请自行输入密码,或关联现有账号。
|
||||||
|
- Windows 使用 DPAPI(`CryptProtectData`)及用于域隔离的额外熵来保护机密数据。Linux/macOS 使用权限为 `0600` 的文件。
|
||||||
|
- 已建立的直连 TCP 会话无法在不中断连接的情况下切换至中继。连接中断后,会在下一次加入服务器时自动尝试备用路径。
|
||||||
|
- 为保证远程导入便携角色的安全,请保留默认设置 `CharacterDatabase.WorkerThreads = 1`。
|
||||||
|
|
||||||
|
## 开发
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install
|
||||||
|
cargo test --workspace
|
||||||
|
npx tsc --noEmit
|
||||||
|
node tools/check-i18n.mjs
|
||||||
|
npx vite
|
||||||
|
cargo build -p coa-server-manager
|
||||||
|
```
|
||||||
|
|
||||||
|
以上命令依次安装依赖、运行测试、检查类型与翻译、启动使用模拟数据的浏览器界面,以及编译原生应用。调试版应用连接 `http://localhost:1420`。
|
||||||
|
|
||||||
|
`crates/coa-core` 存放核心逻辑,`crates/coa-release` 提供打包和签名工具,`src-tauri` 处理原生命令,`src` 存放界面代码。
|
||||||
|
|
||||||
|
`cargo run -p coa-core --example scan -- <folder>` 可以只读检查现有安装。启动和停止测试必须使用可丢弃的独立副本:`tools/make-fixture.ps1` 会从安装包的原始数据库创建 `C:\games\coa-fixture`,并使用不同端口。不要在正在供玩家使用的服务器上进行此类测试。`tests/e2e/cdp.mjs` 可通过 WebView2 控制真实窗口,需设置 `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9222`。
|
||||||
|
|
||||||
|
## 许可
|
||||||
|
|
||||||
|
管理器是自由软件,采用 [GNU AGPL v3.0](LICENSE),标识为 `AGPL-3.0-only`。
|
||||||
|
|
||||||
|
- 所安装的服务器来自公开的 [AzerothCore 分支](https://github.com/Corfirean/azerothcore-wotlk-coa)。继承自 MaNGOS 的部分采用 GPL-2.0-or-later,AzerothCore 自有部分采用 AGPL-3.0。[mod-coa-playerbots](https://github.com/Corfirean/mod-coa-playerbots) 采用 AGPL-3.0。每个安装包的清单都记录了准确的提交版本,便于查找对应源码。
|
||||||
|
- 随附的 MySQL 保留其 GPL-2.0 许可,许可文本位于安装包的 `Licenses` 目录。
|
||||||
|
- `Data` 中的游戏数据(`dbc`、`maps`、`vmaps`、`mmaps`)提取自已关闭的 Ascension Conquest of Azeroth 服务器客户端,**不属于**管理器许可的授权范围。
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: added
|
||||||
|
audience: admins
|
||||||
|
title: Advanced settings cover creature melee damage, spell damage and health by rank
|
||||||
|
---
|
||||||
|
Configure normal, elite, rare, rare elite and world boss creatures separately. Existing normal-creature settings now identify their scope clearly. Changes persist in the server template and require a world server restart.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Internet sharing accepts existing port forwards to the same server
|
||||||
|
---
|
||||||
|
When a router rejects an already configured port forward, the Manager checks its destination. Matching enabled rules are accepted; conflicting rules report the affected TCP port and remain untouched.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: client
|
||||||
|
type: added
|
||||||
|
audience: players
|
||||||
|
title: New dragon races and updated racial abilities are available
|
||||||
|
---
|
||||||
|
The custom race client includes Drakkin, Drakonid, updated appearances and cursor addons. Existing client files are preserved when installing or removing the patches.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Server stop errors remain readable while private connection codes stay hidden
|
||||||
|
---
|
||||||
|
The Manager keeps useful MySQL shutdown messages in diagnostics without exposing portable character connection codes.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: players
|
||||||
|
title: Characters on other servers show their CoA class names
|
||||||
|
---
|
||||||
|
The character list shows Barbarian, Necromancer and the other CoA classes instead of a class number.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: players
|
||||||
|
title: Play can launch Windows clients that require administrator approval
|
||||||
|
---
|
||||||
|
Windows now shows its normal permission prompt when the game requires elevation. Other launch errors retain their original details.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: players
|
||||||
|
title: Switching Custom Races patches is faster and shows when changes are being applied
|
||||||
|
---
|
||||||
|
The Manager avoids copying large patches when switching them and prevents repeated clicks while the operation is running.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: changed
|
||||||
|
audience: players
|
||||||
|
title: Portable characters are now clearly marked as experimental
|
||||||
|
---
|
||||||
|
The experimental status is shown both in Characters and when making a character portable from another realm.
|
||||||
@@ -4,4 +4,4 @@ type: added
|
|||||||
audience: admins
|
audience: admins
|
||||||
title: Module settings for Content Scaling include creature health
|
title: Module settings for Content Scaling include creature health
|
||||||
---
|
---
|
||||||
The Content Scaling page now has five health multipliers: for the open world, dungeons and raids, and for ordinary mobs and bosses. They multiply the health the scaling already gives creatures (1 keeps the normal balance, lower is easier, 0.1 to 10) and need a server build that includes the matching Content Scaling settings.
|
Adjust creature health for the open world, dungeons, raids, ordinary enemies and bosses. Values from 0.1 to 10 multiply the existing balance; 1 keeps it unchanged. Requires a server build with the matching Content Scaling settings.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: added
|
||||||
|
audience: admins
|
||||||
|
title: Warcraft Reborn can now be created and selected as a separate realm
|
||||||
|
---
|
||||||
|
Warcraft Reborn has separate characters and settings, shares accounts, and is included in backups, updates and database checks. A server build with Warcraft Reborn support is required.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: changed
|
||||||
|
audience: players
|
||||||
|
title: Custom Races client patches now use the latest complete package
|
||||||
|
---
|
||||||
|
Install or repair Custom Races client patches from the Modules page to get the updated package, including its latest appearance fixes and login screen artwork.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: changed
|
||||||
|
audience: admins
|
||||||
|
title: The Auction House Bot card has a single switch
|
||||||
|
---
|
||||||
|
The separate "Post auctions" option is gone; turning the module on is enough. A server build with the single-switch Auction House Bot is needed, and an old EnableSeller line in the config is ignored.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: players
|
||||||
|
title: More character and server browser controls now use your selected language
|
||||||
|
---
|
||||||
|
Completed missing German, French, Spanish and Simplified Chinese labels and improved Chinese font support.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Online player counts correctly separate random bots from players
|
||||||
|
---
|
||||||
|
The server browser and overview now count SQUID random bots as bots, using the server's configured bot account prefix.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Custom races work with shared addon folders on another drive
|
||||||
|
---
|
||||||
|
Installing, switching and removing custom races now supports linked addon folders on another drive, including recovery after an interrupted operation.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: added
|
||||||
|
audience: admins
|
||||||
|
title: Configure the day and night cycle from the module settings
|
||||||
|
---
|
||||||
|
TimeIsTime now has a module card, an on/off switch and settings translated into all six Manager languages.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: A stalled database inspection no longer blocks server maintenance indefinitely
|
||||||
|
---
|
||||||
|
Update checks limit how long their database client can run and release the maintenance lock after a timeout. The Manager stops only its inspection client, keeps the database server running and reports that migration history could not be checked.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: added
|
||||||
|
audience: admins
|
||||||
|
title: Server owners can allow portable characters per realm
|
||||||
|
---
|
||||||
|
Portable admission is off until enabled by the realm owner. Export and import requests enforce the saved choice.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Allowing portable characters also prepares the server for portable sessions
|
||||||
|
---
|
||||||
|
Stop the server before enabling access for the first time. The Manager enables portable sessions in the effective module configuration and preserves the required database setting across restarts. Existing configuration is backed up.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: players
|
||||||
|
title: Portable characters open again after using an experimental Manager
|
||||||
|
---
|
||||||
|
Preserves saved characters and collections when opening a portable store upgraded by an experimental Manager.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Managers stay compatible with the public connection service
|
||||||
|
---
|
||||||
|
Coordinator authentication no longer changes when portable messages change. The publishing card shows game relay status separately.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Relay connections recover and use the ports of the installed server
|
||||||
|
---
|
||||||
|
Dropped or unresponsive relay links reconnect automatically. Abandoned game connections close, and tunnels refresh when local ports become available or change. Custom authentication ports are respected.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Portable progress resumes after reconnecting or restarting the Manager
|
||||||
|
---
|
||||||
|
The player Manager now saves remote baselines, checkpoints and logout progress durably. Repeated logins stay monitored, and transfer retries preserve the same character and session.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: known-issue
|
||||||
|
audience: admins
|
||||||
|
title: Older copies on another host may require maintenance before returning
|
||||||
|
---
|
||||||
|
Experimental portable play blocks an outdated existing copy on another host. Automatic refresh while that remote worldserver runs is not available. Your canonical character remains saved in your Manager.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: client
|
||||||
|
type: changed
|
||||||
|
audience: players
|
||||||
|
title: Install the matching CoA Custom 1.9.1 client files
|
||||||
|
---
|
||||||
|
The races installer verifies and installs all five client archives, including the new races and appearance corrections.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: changed
|
||||||
|
audience: players
|
||||||
|
title: Install the CoA Custom 1.9.2 client patches
|
||||||
|
---
|
||||||
|
Installs the updated Hozen and Centaur assets and quest safety addon. Existing CoA Custom 1.9.1 installations remain recognized when updating or removing patches.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: added
|
||||||
|
audience: admins
|
||||||
|
title: Report Content Scaling problems directly to its repository
|
||||||
|
---
|
||||||
|
The report form now includes a separate Content Scaling destination.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: added
|
||||||
|
audience: admins
|
||||||
|
title: Send custom race problem reports directly to their maintainer
|
||||||
|
---
|
||||||
|
The report form now includes Custom Races as a separate destination.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Internet sharing restores the LAN address after server restarts
|
||||||
|
---
|
||||||
|
Friends on the local network receive the server's LAN address and network mask while internet players keep using its public address.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Server updates preserve the order of database migrations added during merges
|
||||||
|
---
|
||||||
|
Older database snapshots no longer run after newer updates when preparing server packages. This prevents outdated Manastorm reward ranges from overwriting newer progression data.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: added
|
||||||
|
audience: admins
|
||||||
|
title: Configure custom race availability for new characters
|
||||||
|
---
|
||||||
|
Choose individual races in a compact table inside module settings using the installed server catalog. Saving requires a compatible server build and a stopped server. Client synchronization is not yet automatic.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Public listing offers every realm that starts together, not just the main one
|
||||||
|
---
|
||||||
|
With Wildcard or Warcraft Reborn started next to Conquest of Azeroth, Settings now has one listing block per realm, each with its own name, description and access options.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: changed
|
||||||
|
audience: admins
|
||||||
|
title: Public listing is a short list of realms with a window for the details
|
||||||
|
---
|
||||||
|
Settings shows one line per realm with its state, and publishing opens a window. Publish all realms at once. Account creation and portable characters are chosen before publishing; portable characters are on by default.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: added
|
||||||
|
audience: admins
|
||||||
|
title: Configure profession and defense skill gains in server settings
|
||||||
|
---
|
||||||
|
Advanced rate settings now include prospecting and milling skill gains, plus the points gained from crafting, defense and gathering.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Starting a server sets the character classes of the realm chosen on Overview
|
||||||
|
---
|
||||||
|
A new Conquest of Azeroth server could show two class models, or none, on the character creation screen. The Manager now sets the model of the chosen realm before every start.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: added
|
||||||
|
audience: admins
|
||||||
|
title: Start Wildcard and Warcraft Reborn together with Conquest of Azeroth
|
||||||
|
---
|
||||||
|
Settings now has two options, one for Wildcard and one for Warcraft Reborn. Turn on either one, or both to run all three realms at once, each with its own characters and port.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: admins
|
||||||
|
title: Existing unsupported character records no longer block unrelated server updates
|
||||||
|
---
|
||||||
|
Updates compare each affected character with its saved pre-update state. Unchanged older problems are reported as warnings without changing characters. Newly missing race/class data still blocks the update and triggers recovery; schema and identity checks remain enforced.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: added
|
||||||
|
audience: admins
|
||||||
|
title: Control portable characters and keep Manager running in the system tray
|
||||||
|
---
|
||||||
|
Realm access settings can enable portable characters. Closing the window keeps Manager in the tray, with commands to reopen or exit. Offline realm messages explain why players cannot connect.
|
||||||
+134
-1
@@ -112,6 +112,8 @@
|
|||||||
"Corfirean/coa-server-manager:20261016-preserve-core-migration-history.md",
|
"Corfirean/coa-server-manager:20261016-preserve-core-migration-history.md",
|
||||||
"Corfirean/coa-server-manager:20261016-shared-auth-migration-history.md",
|
"Corfirean/coa-server-manager:20261016-shared-auth-migration-history.md",
|
||||||
"Corfirean/coa-server-manager:20261016-update-compatibility-wording.md",
|
"Corfirean/coa-server-manager:20261016-update-compatibility-wording.md",
|
||||||
|
"Corfirean/coa-server-manager:20261017-creature-difficulty-rates.md",
|
||||||
|
"Corfirean/coa-server-manager:20261017-existing-router-mapping.md",
|
||||||
"Corfirean/coa-server-manager:20261018-custom-races-client.md",
|
"Corfirean/coa-server-manager:20261018-custom-races-client.md",
|
||||||
"Corfirean/coa-server-manager:20261019-portable-stop-diagnostics.md",
|
"Corfirean/coa-server-manager:20261019-portable-stop-diagnostics.md",
|
||||||
"Corfirean/coa-server-manager:20261019-remote-character-class-names.md",
|
"Corfirean/coa-server-manager:20261019-remote-character-class-names.md",
|
||||||
@@ -120,7 +122,34 @@
|
|||||||
"Corfirean/coa-server-manager:20261021-portable-experimental.md",
|
"Corfirean/coa-server-manager:20261021-portable-experimental.md",
|
||||||
"Corfirean/coa-server-manager:20261021-scaling-health-settings.md",
|
"Corfirean/coa-server-manager:20261021-scaling-health-settings.md",
|
||||||
"Corfirean/coa-server-manager:20261021-warcraft-reborn-realm.md",
|
"Corfirean/coa-server-manager:20261021-warcraft-reborn-realm.md",
|
||||||
"Corfirean/coa-server-manager:20261022-custom-races-client.md"
|
"Corfirean/coa-server-manager:20261022-custom-races-client.md",
|
||||||
|
"Corfirean/coa-server-manager:20261022-scaling-progression-modes.md",
|
||||||
|
"Corfirean/coa-server-manager:20261023-ah-bot-single-switch.md",
|
||||||
|
"Corfirean/coa-server-manager:20261023-interface-language-coverage.md",
|
||||||
|
"Corfirean/coa-server-manager:20261023-online-players-exclude-squid-bots.md",
|
||||||
|
"Corfirean/coa-server-manager:20261023-shared-addons-links.md",
|
||||||
|
"Corfirean/coa-server-manager:20261023-time-is-time-settings.md",
|
||||||
|
"Corfirean/coa-server-manager:20261023-update-check-database-timeout.md",
|
||||||
|
"Corfirean/coa-server-manager:20261024-portable-admission.md",
|
||||||
|
"Corfirean/coa-server-manager:20261024-portable-owner-core-activation.md",
|
||||||
|
"Corfirean/coa-server-manager:20261024-portable-schema-nine.md",
|
||||||
|
"Corfirean/coa-server-manager:20261024-relay-authentication.md",
|
||||||
|
"Corfirean/coa-server-manager:20261024-relay-recovery.md",
|
||||||
|
"Corfirean/coa-server-manager:20261024-remote-progress.md",
|
||||||
|
"Corfirean/coa-server-manager:20261024-remote-refresh.md",
|
||||||
|
"Corfirean/coa-server-manager:20261025-custom-races-191.md",
|
||||||
|
"Corfirean/coa-server-manager:20261026-custom-races-192.md",
|
||||||
|
"Corfirean/coa-server-manager:20261027-content-scaling-reports.md",
|
||||||
|
"Corfirean/coa-server-manager:20261027-custom-races-reports.md",
|
||||||
|
"Corfirean/coa-server-manager:20261027-internet-lan-address.md",
|
||||||
|
"Corfirean/coa-server-manager:20261027-merged-database-migration-order.md",
|
||||||
|
"Corfirean/coa-server-manager:20261027-per-race-server-settings.md",
|
||||||
|
"Corfirean/coa-server-manager:20261027-public-list-shows-every-running-realm.md",
|
||||||
|
"Corfirean/coa-server-manager:20261027-public-listing-window.md",
|
||||||
|
"Corfirean/coa-server-manager:20261027-skill-gain-controls.md",
|
||||||
|
"Corfirean/coa-server-manager:20261027-start-checks-the-realm-class-setting.md",
|
||||||
|
"Corfirean/coa-server-manager:20261027-start-wildcard-and-reborn-with-coa.md",
|
||||||
|
"Corfirean/coa-server-manager:20261028-portable-settings-and-tray.md"
|
||||||
],
|
],
|
||||||
"releases": [
|
"releases": [
|
||||||
{
|
{
|
||||||
@@ -623,6 +652,110 @@
|
|||||||
"links": [
|
"links": [
|
||||||
"[Guides and screenshots](https://github.com/Corfirean/coa-server-manager/blob/master/docs/README.md)"
|
"[Guides and screenshots](https://github.com/Corfirean/coa-server-manager/blob/master/docs/README.md)"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "v0.7.2",
|
||||||
|
"version": "0.7.2",
|
||||||
|
"date": "2026-10-23",
|
||||||
|
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.7.2",
|
||||||
|
"notes": [
|
||||||
|
"Advanced settings cover creature melee damage, spell damage and health by rank",
|
||||||
|
"Internet sharing accepts existing port forwards to the same server",
|
||||||
|
"The Auction House Bot card has a single switch",
|
||||||
|
"More character and server browser controls now use your selected language",
|
||||||
|
"Online player counts correctly separate random bots from players",
|
||||||
|
"Custom races work with shared addon folders on another drive",
|
||||||
|
"Configure the day and night cycle from the module settings",
|
||||||
|
"A stalled database inspection no longer blocks server maintenance indefinitely"
|
||||||
|
],
|
||||||
|
"commit": "4d59ce8cb1d4abd7f4992370e9a7ba4dc6bd02f7",
|
||||||
|
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.7.1...v0.7.2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "v0.7.3",
|
||||||
|
"version": "0.7.3",
|
||||||
|
"date": "2026-10-23",
|
||||||
|
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.7.3",
|
||||||
|
"notes": [
|
||||||
|
"Portable characters open again after using an experimental Manager"
|
||||||
|
],
|
||||||
|
"commit": "2715170622665f62c396fe1a79f7ef6504713ef1",
|
||||||
|
"experimentalFeatures": [
|
||||||
|
"portable-characters"
|
||||||
|
],
|
||||||
|
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.7.2...v0.7.3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "v0.8.0",
|
||||||
|
"version": "0.8.0",
|
||||||
|
"date": "2026-10-24",
|
||||||
|
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.8.0",
|
||||||
|
"notes": [
|
||||||
|
"Server owners can allow portable characters per realm",
|
||||||
|
"Allowing portable characters also prepares the server for portable sessions",
|
||||||
|
"Managers stay compatible with the public connection service",
|
||||||
|
"Relay connections recover and use the ports of the installed server",
|
||||||
|
"Portable progress resumes after reconnecting or restarting the Manager",
|
||||||
|
"Older copies on another host may require maintenance before returning"
|
||||||
|
],
|
||||||
|
"commit": "b00e732c7f53f33680aaf6bd520da64b70b26a5a",
|
||||||
|
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.7.3...v0.8.0",
|
||||||
|
"experimentalFeatures": [
|
||||||
|
"portable-characters"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "v0.8.1",
|
||||||
|
"version": "0.8.1",
|
||||||
|
"date": "2026-10-25",
|
||||||
|
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.8.1",
|
||||||
|
"notes": [
|
||||||
|
"Install the matching CoA Custom 1.9.1 client files"
|
||||||
|
],
|
||||||
|
"commit": "02e3a9e4e66870a627feeb0b4d3ec2d75a23973d",
|
||||||
|
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.8.0...v0.8.1",
|
||||||
|
"experimentalFeatures": [
|
||||||
|
"portable-characters"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "v0.8.2",
|
||||||
|
"version": "0.8.2",
|
||||||
|
"date": "2026-10-27",
|
||||||
|
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.8.2",
|
||||||
|
"notes": [
|
||||||
|
"Installs the verified CoA Custom 1.9.2 client patches and quest safety addon, while recognizing existing 1.9.1 installations",
|
||||||
|
"Server updates preserve the order of database migrations introduced during merges, preventing older snapshots from overwriting newer progression"
|
||||||
|
],
|
||||||
|
"commit": "81b040ef02763c7cf7a3a3da1424b73177e9d433",
|
||||||
|
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.8.1...v0.8.2",
|
||||||
|
"experimentalFeatures": [
|
||||||
|
"portable-characters"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "v0.9.0",
|
||||||
|
"version": "0.9.0",
|
||||||
|
"date": "2026-10-28",
|
||||||
|
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.0",
|
||||||
|
"notes": [
|
||||||
|
"Choose Parallel or Global level scaling in module settings",
|
||||||
|
"Report Content Scaling problems directly to its repository",
|
||||||
|
"Send custom race problem reports directly to their maintainer",
|
||||||
|
"Internet sharing restores the LAN address after server restarts",
|
||||||
|
"Configure custom race availability for new characters",
|
||||||
|
"Public listing offers every realm that starts together, not just the main one",
|
||||||
|
"Public listing is a short list of realms with a window for the details",
|
||||||
|
"Configure profession and defense skill gains in server settings",
|
||||||
|
"Starting a server sets the character classes of the realm chosen on Overview",
|
||||||
|
"Start Wildcard and Warcraft Reborn together with Conquest of Azeroth",
|
||||||
|
"Control portable characters and keep Manager running in the system tray"
|
||||||
|
],
|
||||||
|
"commit": "dc97095bd6b36d9b5111f04f0cfd88e1fb2ab1f1",
|
||||||
|
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.8.2...v0.9.0",
|
||||||
|
"experimentalFeatures": [
|
||||||
|
"portable-characters"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[package]
|
||||||
|
name = "coa-control-proto"
|
||||||
|
description = "Player <-> Host control protocol (Phase 12): coordinator framing, the end-to-end Noise channel, identity binding and the application messages. No I/O."
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
license = "AGPL-3.0-only"
|
||||||
|
publish = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
coa-registry-proto = { path = "../coa-registry-proto" }
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
serde_json = "1"
|
||||||
|
sha2 = "0.10"
|
||||||
|
hex = "0.4"
|
||||||
|
base64 = "0.22"
|
||||||
|
ed25519-dalek = "2"
|
||||||
|
snow = "0.9"
|
||||||
|
thiserror = "2"
|
||||||
|
uuid = { version = "1", features = ["serde", "v4", "v7"] }
|
||||||
@@ -0,0 +1,584 @@
|
|||||||
|
//! The application messages inside the end-to-end channel. One request, one response, in order. Nothing here is ever visible to the Coordinator.
|
||||||
|
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::{invalid, ControlError, Result};
|
||||||
|
|
||||||
|
pub const MAX_CONTROL_REQUEST_BYTES: usize = 4096;
|
||||||
|
pub const MAX_TRANSFER_REQUEST_BYTES: usize = 4 * 1024 * 1024; // 4 MiB
|
||||||
|
pub const MAX_REQUEST_BYTES: usize = MAX_TRANSFER_REQUEST_BYTES;
|
||||||
|
pub const MIN_USERNAME: usize = 3;
|
||||||
|
pub const MAX_USERNAME: usize = 16;
|
||||||
|
pub const MIN_PASSWORD: usize = 8;
|
||||||
|
pub const MAX_PASSWORD: usize = 16;
|
||||||
|
pub const MAX_CHARACTERS: usize = 200;
|
||||||
|
pub const MAX_SESSION_BYTES: usize = 12 * 1024 * 1024;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum SessionMessageKind {
|
||||||
|
Started,
|
||||||
|
Checkpoint,
|
||||||
|
Collection,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A game account name: 3 to 16 ASCII letters, digits or `_`, not beginning or ending with `_`.
|
||||||
|
pub fn valid_username(s: &str) -> bool {
|
||||||
|
(MIN_USERNAME..=MAX_USERNAME).contains(&s.len())
|
||||||
|
&& s.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'_')
|
||||||
|
&& !s.starts_with('_')
|
||||||
|
&& !s.ends_with('_')
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A game account password: 8 to 16 ASCII letters and digits (the game compares passwords case-insensitively, so letters carry no extra strength; digits and length do).
|
||||||
|
pub fn valid_password(s: &str) -> bool {
|
||||||
|
(MIN_PASSWORD..=MAX_PASSWORD).contains(&s.len()) && s.bytes().all(|b| b.is_ascii_alphanumeric())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A password for a realm, 16 characters of `A-Z0-9` from the operating system's randomness (about 82 bits), unique per realm.
|
||||||
|
pub fn generate_password() -> String {
|
||||||
|
const ALPHABET: &[u8; 36] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
|
let mut out = String::with_capacity(16);
|
||||||
|
while out.len() < 16 {
|
||||||
|
for b in Uuid::new_v4().as_bytes() {
|
||||||
|
// rejection sampling: 252 is the largest multiple of 36 below 256, so every symbol is equally likely
|
||||||
|
if *b < 252 && out.len() < 16 {
|
||||||
|
out.push(ALPHABET[(*b % 36) as usize] as char);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The account name wanted, made fit for the game: letters and digits only, upper case, at most 16 characters.
|
||||||
|
pub fn sanitize_username(wanted: &str) -> String {
|
||||||
|
let base: String = wanted
|
||||||
|
.chars()
|
||||||
|
.filter(char::is_ascii_alphanumeric)
|
||||||
|
.collect::<String>()
|
||||||
|
.to_ascii_uppercase();
|
||||||
|
let base: String = base.chars().take(MAX_USERNAME).collect();
|
||||||
|
if base.len() >= MIN_USERNAME {
|
||||||
|
base
|
||||||
|
} else {
|
||||||
|
format!("{base}PLAYER").chars().take(MAX_USERNAME).collect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The stable alternative of an occupied name: `DMITRY` becomes `DMITRY_7K4M`. The suffix is derived from the player's id, so the same player gets the same alternative.
|
||||||
|
pub fn alternative_username(base: &str, player: &Uuid, attempt: u32) -> String {
|
||||||
|
const ALPHABET: &[u8; 32] = b"ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
||||||
|
let bytes = player.as_bytes();
|
||||||
|
let mix = u32::from_be_bytes([bytes[12], bytes[13], bytes[14], bytes[15]])
|
||||||
|
.wrapping_add(attempt.wrapping_mul(0x9E37_79B1));
|
||||||
|
let suffix: String = (0..4)
|
||||||
|
.map(|i| ALPHABET[((mix >> (i * 5)) & 31) as usize] as char)
|
||||||
|
.collect();
|
||||||
|
let keep = MAX_USERNAME - 5;
|
||||||
|
let head: String = base.chars().take(keep).collect();
|
||||||
|
format!("{head}_{suffix}")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(tag = "op", rename_all = "snake_case", deny_unknown_fields)]
|
||||||
|
pub enum Request {
|
||||||
|
Hello {
|
||||||
|
protocol: u32,
|
||||||
|
client: String,
|
||||||
|
},
|
||||||
|
/// Make the player's account on this realm, or reuse it. `password` is the one the player's Manager keeps for this realm; it travels only inside the channel.
|
||||||
|
Provision {
|
||||||
|
desired: Option<String>,
|
||||||
|
password: String,
|
||||||
|
have_credentials: bool,
|
||||||
|
},
|
||||||
|
ListCharacters,
|
||||||
|
Claim {
|
||||||
|
token: u32,
|
||||||
|
},
|
||||||
|
ClaimAck {
|
||||||
|
character_id: Uuid,
|
||||||
|
},
|
||||||
|
/// Link an account the realm already has (one time).
|
||||||
|
Link {
|
||||||
|
login: String,
|
||||||
|
password: String,
|
||||||
|
},
|
||||||
|
Route,
|
||||||
|
/// Phase 12.1: Start or resume a remote portable character transfer.
|
||||||
|
TransferOffer {
|
||||||
|
transfer_id: Uuid,
|
||||||
|
character_id: Uuid,
|
||||||
|
ruleset: String,
|
||||||
|
canonical_revision: u64,
|
||||||
|
content_hash: String,
|
||||||
|
total_size: usize,
|
||||||
|
collections: BTreeMap<String, Vec<u32>>,
|
||||||
|
},
|
||||||
|
OwnedTransferOffer {
|
||||||
|
transfer_id: Uuid,
|
||||||
|
character_id: Uuid,
|
||||||
|
ruleset: String,
|
||||||
|
canonical_revision: u64,
|
||||||
|
content_hash: String,
|
||||||
|
total_size: usize,
|
||||||
|
collections: BTreeMap<String, Vec<u32>>,
|
||||||
|
},
|
||||||
|
/// A chunk of the encoded portable character snapshot payload.
|
||||||
|
TransferChunk {
|
||||||
|
transfer_id: Uuid,
|
||||||
|
offset: usize,
|
||||||
|
data: String,
|
||||||
|
},
|
||||||
|
/// Query status or resume progress of a transfer.
|
||||||
|
TransferStatus {
|
||||||
|
transfer_id: Uuid,
|
||||||
|
},
|
||||||
|
/// Commit the transferred payload into the realm and arm a session.
|
||||||
|
TransferCommit {
|
||||||
|
transfer_id: Uuid,
|
||||||
|
},
|
||||||
|
/// Acknowledge successful transfer and session arming.
|
||||||
|
TransferAck {
|
||||||
|
transfer_id: Uuid,
|
||||||
|
character_id: Uuid,
|
||||||
|
},
|
||||||
|
SessionPoll {
|
||||||
|
character_id: Uuid,
|
||||||
|
session_id: Uuid,
|
||||||
|
},
|
||||||
|
SessionRead {
|
||||||
|
character_id: Uuid,
|
||||||
|
session_id: Uuid,
|
||||||
|
message_hash: String,
|
||||||
|
offset: usize,
|
||||||
|
},
|
||||||
|
SessionAck {
|
||||||
|
character_id: Uuid,
|
||||||
|
session_id: Uuid,
|
||||||
|
message_hash: String,
|
||||||
|
offset: usize,
|
||||||
|
total_size: usize,
|
||||||
|
data: String,
|
||||||
|
},
|
||||||
|
/// Phase 13: Request a short-lived relay allocation for a relayed JOIN.
|
||||||
|
AllocateRelay {
|
||||||
|
player_id: Uuid,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum AppError {
|
||||||
|
UnsupportedVersion,
|
||||||
|
Invalid,
|
||||||
|
ProvisioningOff,
|
||||||
|
NoAccount,
|
||||||
|
NotAtCharacterSelect,
|
||||||
|
NotYours,
|
||||||
|
AlreadyClaimed,
|
||||||
|
NotEligible,
|
||||||
|
WrongCredentials,
|
||||||
|
AccountTaken,
|
||||||
|
RateLimited,
|
||||||
|
Unavailable,
|
||||||
|
Incompatible,
|
||||||
|
Conflict,
|
||||||
|
RelayUnavailable,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct CharacterEntry {
|
||||||
|
/// Opaque to the player: the Host's handle for this character, valid for this realm.
|
||||||
|
pub token: u32,
|
||||||
|
pub name: String,
|
||||||
|
pub class: u32,
|
||||||
|
pub race: u32,
|
||||||
|
pub level: u32,
|
||||||
|
pub eligible: bool,
|
||||||
|
pub reasons: Vec<String>,
|
||||||
|
/// Already portable and claimed by this player.
|
||||||
|
pub yours: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(tag = "op", rename_all = "snake_case")]
|
||||||
|
pub enum Response {
|
||||||
|
SessionPending {
|
||||||
|
kind: SessionMessageKind,
|
||||||
|
total_size: usize,
|
||||||
|
content_hash: String,
|
||||||
|
},
|
||||||
|
SessionIdle {
|
||||||
|
closed: bool,
|
||||||
|
},
|
||||||
|
SessionData {
|
||||||
|
offset: usize,
|
||||||
|
data: String,
|
||||||
|
},
|
||||||
|
SessionAcked {
|
||||||
|
received_size: usize,
|
||||||
|
complete: bool,
|
||||||
|
},
|
||||||
|
Welcome {
|
||||||
|
realm_id: coa_registry_proto::RealmId,
|
||||||
|
automatic: bool,
|
||||||
|
existing_only: bool,
|
||||||
|
route: Option<String>,
|
||||||
|
},
|
||||||
|
Provisioned {
|
||||||
|
username: String,
|
||||||
|
created: bool,
|
||||||
|
reset: bool,
|
||||||
|
},
|
||||||
|
Characters {
|
||||||
|
characters: Vec<CharacterEntry>,
|
||||||
|
},
|
||||||
|
/// The character as the Host exported it: `payload` is the base64 of the encoded portable snapshot, `sha256` the hash of its canonical JSON, `collections` the account's
|
||||||
|
/// appearance and vanity ids the Host holds for the account (kind -> ids).
|
||||||
|
Claimed {
|
||||||
|
character_id: Uuid,
|
||||||
|
ruleset: String,
|
||||||
|
sha256: String,
|
||||||
|
payload: String,
|
||||||
|
collections: BTreeMap<String, Vec<u32>>,
|
||||||
|
},
|
||||||
|
Linked {
|
||||||
|
username: String,
|
||||||
|
},
|
||||||
|
Done,
|
||||||
|
RouteInfo {
|
||||||
|
address: Option<String>,
|
||||||
|
},
|
||||||
|
/// The Host is ready to receive transfer chunks (or indicates an offset to resume from).
|
||||||
|
TransferReady {
|
||||||
|
transfer_id: Uuid,
|
||||||
|
received_offset: usize,
|
||||||
|
},
|
||||||
|
/// Acknowledgement of a transfer chunk.
|
||||||
|
TransferChunkAck {
|
||||||
|
transfer_id: Uuid,
|
||||||
|
received_offset: usize,
|
||||||
|
},
|
||||||
|
/// Successful commit and session arm.
|
||||||
|
TransferCommitted {
|
||||||
|
transfer_id: Uuid,
|
||||||
|
character_id: Uuid,
|
||||||
|
local_guid: u32,
|
||||||
|
session_id: Uuid,
|
||||||
|
projected_level: Option<u32>,
|
||||||
|
notes: Vec<String>,
|
||||||
|
},
|
||||||
|
/// Phase 13: Relay allocation details returned to the player.
|
||||||
|
RelayAllocated {
|
||||||
|
relay_host: String,
|
||||||
|
auth_port: u16,
|
||||||
|
world_port: u16,
|
||||||
|
token: String,
|
||||||
|
expires_at: i64,
|
||||||
|
},
|
||||||
|
Error {
|
||||||
|
code: AppError,
|
||||||
|
message: String,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn encode_request(r: &Request) -> Vec<u8> {
|
||||||
|
serde_json::to_vec(r).expect("a request serialises")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn decode_request(bytes: &[u8]) -> Result<Request> {
|
||||||
|
if bytes.len() > MAX_TRANSFER_REQUEST_BYTES {
|
||||||
|
return Err(ControlError::Limit("a request is too long".into()));
|
||||||
|
}
|
||||||
|
let r: Request = serde_json::from_slice(bytes)
|
||||||
|
.map_err(|_| ControlError::Invalid("a request is not valid".into()))?;
|
||||||
|
if !matches!(
|
||||||
|
&r,
|
||||||
|
Request::TransferOffer { .. }
|
||||||
|
| Request::OwnedTransferOffer { .. }
|
||||||
|
| Request::TransferChunk { .. }
|
||||||
|
| Request::SessionAck { .. }
|
||||||
|
) && bytes.len() > MAX_CONTROL_REQUEST_BYTES
|
||||||
|
{
|
||||||
|
return Err(ControlError::Limit(
|
||||||
|
"a standard control request exceeds 4096 bytes".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
match &r {
|
||||||
|
Request::SessionRead {
|
||||||
|
message_hash,
|
||||||
|
offset,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
if message_hash.len() != 64
|
||||||
|
|| !message_hash.bytes().all(|b| b.is_ascii_hexdigit())
|
||||||
|
|| *offset > MAX_SESSION_BYTES
|
||||||
|
{
|
||||||
|
return invalid("invalid portable session read");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Request::SessionAck {
|
||||||
|
message_hash,
|
||||||
|
offset,
|
||||||
|
total_size,
|
||||||
|
data,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
if message_hash.len() != 64
|
||||||
|
|| !message_hash.bytes().all(|b| b.is_ascii_hexdigit())
|
||||||
|
|| *total_size > MAX_SESSION_BYTES
|
||||||
|
|| *offset > *total_size
|
||||||
|
|| data.len() > 48 * 1024
|
||||||
|
{
|
||||||
|
return invalid("invalid portable session acknowledgement chunk");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Request::Provision {
|
||||||
|
desired, password, ..
|
||||||
|
} => {
|
||||||
|
if !valid_password(password)
|
||||||
|
|| desired
|
||||||
|
.as_deref()
|
||||||
|
.is_some_and(|d| d.len() > 64 || d.chars().any(char::is_control))
|
||||||
|
{
|
||||||
|
return invalid("a provisioning request has an unusable password or name");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Request::Link { login, password } => {
|
||||||
|
if !valid_username(login) || !valid_password_for_link(password) {
|
||||||
|
return invalid("a link request has an unusable login or password");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Request::Hello { client, .. } if client.len() > 64 => {
|
||||||
|
return invalid("the client name is too long")
|
||||||
|
}
|
||||||
|
Request::TransferOffer {
|
||||||
|
ruleset,
|
||||||
|
content_hash,
|
||||||
|
total_size,
|
||||||
|
collections,
|
||||||
|
..
|
||||||
|
}
|
||||||
|
| Request::OwnedTransferOffer {
|
||||||
|
ruleset,
|
||||||
|
content_hash,
|
||||||
|
total_size,
|
||||||
|
collections,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
if !matches!(ruleset.as_str(), "coa" | "wildcard" | "reborn") {
|
||||||
|
return invalid("transfer ruleset must be coa, wildcard, or reborn");
|
||||||
|
}
|
||||||
|
if content_hash.len() != 64 || !content_hash.chars().all(|c| c.is_ascii_hexdigit()) {
|
||||||
|
return invalid("transfer content hash must be 64 hex characters");
|
||||||
|
}
|
||||||
|
if *total_size > crate::noise::MAX_MESSAGE_BYTES {
|
||||||
|
return Err(ControlError::Limit(
|
||||||
|
"transfer total size is too large".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if collections.len() > 1000 {
|
||||||
|
return Err(ControlError::Limit(
|
||||||
|
"collections dictionary exceeds 1,000 keys".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
let total_items: usize = collections.values().map(|v| v.len()).sum();
|
||||||
|
if total_items > 100_000 {
|
||||||
|
return Err(ControlError::Limit(
|
||||||
|
"collection mapping exceeds 100,000 entries".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Request::TransferChunk { offset, data, .. } => {
|
||||||
|
if *offset > MAX_TRANSFER_REQUEST_BYTES {
|
||||||
|
return Err(ControlError::Limit(
|
||||||
|
"transfer chunk offset exceeds limit".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if data.len() > MAX_TRANSFER_REQUEST_BYTES {
|
||||||
|
return Err(ControlError::Limit("transfer chunk is too large".into()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
Ok(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An existing account's password may be anything the game accepts (6 to 16 printable characters without spaces or quotes).
|
||||||
|
pub fn valid_password_for_link(s: &str) -> bool {
|
||||||
|
(6..=16).contains(&s.len())
|
||||||
|
&& s.chars()
|
||||||
|
.all(|c| c.is_ascii_graphic() && c != '"' && c != '\'' && c != '\\')
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn encode_response(r: &Response) -> Vec<u8> {
|
||||||
|
serde_json::to_vec(r).expect("a response serialises")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn decode_response(bytes: &[u8]) -> Result<Response> {
|
||||||
|
if bytes.len() > MAX_TRANSFER_REQUEST_BYTES {
|
||||||
|
return Err(ControlError::Limit("a response is too long".into()));
|
||||||
|
}
|
||||||
|
serde_json::from_slice(bytes)
|
||||||
|
.map_err(|_| ControlError::Invalid("a response is not valid".into()))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn passwords_are_random_unique_and_fit_the_game() {
|
||||||
|
let a = generate_password();
|
||||||
|
let b = generate_password();
|
||||||
|
assert_ne!(a, b);
|
||||||
|
assert!(
|
||||||
|
valid_password(&a)
|
||||||
|
&& a.len() == 16
|
||||||
|
&& a.bytes()
|
||||||
|
.all(|c| c.is_ascii_uppercase() || c.is_ascii_digit()),
|
||||||
|
"{a}"
|
||||||
|
);
|
||||||
|
let mut seen = std::collections::HashSet::new();
|
||||||
|
for _ in 0..200 {
|
||||||
|
assert!(seen.insert(generate_password()), "no repeats");
|
||||||
|
}
|
||||||
|
let symbols: std::collections::HashSet<char> = (0..200)
|
||||||
|
.flat_map(|_| generate_password().chars().collect::<Vec<_>>())
|
||||||
|
.collect();
|
||||||
|
assert_eq!(symbols.len(), 36, "every symbol occurs");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn names_are_made_fit_and_the_alternative_is_stable() {
|
||||||
|
assert_eq!(sanitize_username("Dmitry"), "DMITRY");
|
||||||
|
assert_eq!(sanitize_username("d m-i_t.r y"), "DMITRY");
|
||||||
|
assert_eq!(sanitize_username("ab"), "ABPLAYER");
|
||||||
|
assert_eq!(
|
||||||
|
sanitize_username("a very long player name indeed"),
|
||||||
|
"AVERYLONGPLAYERN"
|
||||||
|
);
|
||||||
|
assert_eq!(sanitize_username("<script>"), "SCRIPT");
|
||||||
|
assert!(
|
||||||
|
valid_username(&sanitize_username("")) && valid_username(&sanitize_username("日本語"))
|
||||||
|
);
|
||||||
|
let p = Uuid::now_v7();
|
||||||
|
let alt = alternative_username("DMITRY", &p, 0);
|
||||||
|
assert!(
|
||||||
|
valid_username(&alt) && alt.starts_with("DMITRY_") && alt.len() == 11,
|
||||||
|
"{alt}"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
alt,
|
||||||
|
alternative_username("DMITRY", &p, 0),
|
||||||
|
"stable for the same player"
|
||||||
|
);
|
||||||
|
assert_ne!(
|
||||||
|
alt,
|
||||||
|
alternative_username("DMITRY", &p, 1),
|
||||||
|
"another attempt, another suffix"
|
||||||
|
);
|
||||||
|
assert_ne!(alt, alternative_username("DMITRY", &Uuid::now_v7(), 0));
|
||||||
|
assert_eq!(
|
||||||
|
alternative_username("ABCDEFGHIJKLMNOP", &p, 0).len(),
|
||||||
|
16,
|
||||||
|
"a long name is shortened to make room"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn requests_are_strict() {
|
||||||
|
let ok = encode_request(&Request::Provision {
|
||||||
|
desired: Some("DMITRY".into()),
|
||||||
|
password: generate_password(),
|
||||||
|
have_credentials: false,
|
||||||
|
});
|
||||||
|
assert!(decode_request(&ok).is_ok());
|
||||||
|
for bad in [
|
||||||
|
br#"{"op":"provision","desired":null,"password":"short","have_credentials":false}"#.as_slice(),
|
||||||
|
br#"{"op":"provision","desired":null,"password":"has space 123456","have_credentials":false}"#,
|
||||||
|
br#"{"op":"claim","token":1,"extra":true}"#,
|
||||||
|
br#"{"op":"link","login":"a b","password":"secret1"}"#,
|
||||||
|
br#"{"op":"unknown"}"#,
|
||||||
|
b"not json",
|
||||||
|
] {
|
||||||
|
assert!(decode_request(bad).is_err(), "{}", String::from_utf8_lossy(bad));
|
||||||
|
}
|
||||||
|
assert!(decode_request(&vec![b' '; MAX_REQUEST_BYTES + 1]).is_err());
|
||||||
|
assert!(decode_request(br#"{"op":"list_characters"}"#).is_ok());
|
||||||
|
assert!(
|
||||||
|
valid_password_for_link("pa55-w0rd")
|
||||||
|
&& !valid_password_for_link("has\"quote")
|
||||||
|
&& !valid_password_for_link("short")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn transfer_messages_roundtrip_and_validate() {
|
||||||
|
let tid = Uuid::new_v4();
|
||||||
|
let cid = Uuid::new_v4();
|
||||||
|
let hash = "a".repeat(64);
|
||||||
|
let offer = Request::TransferOffer {
|
||||||
|
transfer_id: tid,
|
||||||
|
character_id: cid,
|
||||||
|
ruleset: "coa".into(),
|
||||||
|
canonical_revision: 5,
|
||||||
|
content_hash: hash.clone(),
|
||||||
|
total_size: 1024,
|
||||||
|
collections: BTreeMap::new(),
|
||||||
|
};
|
||||||
|
let encoded = encode_request(&offer);
|
||||||
|
let decoded = decode_request(&encoded).unwrap();
|
||||||
|
assert_eq!(offer, decoded);
|
||||||
|
|
||||||
|
let bad_hash = Request::TransferOffer {
|
||||||
|
transfer_id: tid,
|
||||||
|
character_id: cid,
|
||||||
|
ruleset: "coa".into(),
|
||||||
|
canonical_revision: 5,
|
||||||
|
content_hash: "too_short".into(),
|
||||||
|
total_size: 1024,
|
||||||
|
collections: BTreeMap::new(),
|
||||||
|
};
|
||||||
|
assert!(decode_request(&encode_request(&bad_hash)).is_err());
|
||||||
|
|
||||||
|
let chunk = Request::TransferChunk {
|
||||||
|
transfer_id: tid,
|
||||||
|
offset: 0,
|
||||||
|
data: "aGVsbG8=".into(),
|
||||||
|
};
|
||||||
|
assert_eq!(chunk, decode_request(&encode_request(&chunk)).unwrap());
|
||||||
|
|
||||||
|
let resp = Response::TransferCommitted {
|
||||||
|
transfer_id: tid,
|
||||||
|
character_id: cid,
|
||||||
|
local_guid: 42,
|
||||||
|
session_id: Uuid::new_v4(),
|
||||||
|
projected_level: Some(60),
|
||||||
|
notes: vec!["Projected".into()],
|
||||||
|
};
|
||||||
|
let resp_dec = decode_response(&encode_response(&resp)).unwrap();
|
||||||
|
assert_eq!(resp, resp_dec);
|
||||||
|
|
||||||
|
// Control protocol v2 requires ruleset in TransferOffer; missing is rejected
|
||||||
|
let missing_ruleset_json = serde_json::json!({
|
||||||
|
"op": "transfer_offer",
|
||||||
|
"transfer_id": tid,
|
||||||
|
"character_id": cid,
|
||||||
|
"canonical_revision": 5,
|
||||||
|
"content_hash": hash,
|
||||||
|
"total_size": 1024,
|
||||||
|
"collections": {}
|
||||||
|
});
|
||||||
|
let encoded_missing = serde_json::to_vec(&missing_ruleset_json).unwrap();
|
||||||
|
assert!(
|
||||||
|
decode_request(&encoded_missing).is_err(),
|
||||||
|
"missing ruleset in v2 must be rejected"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,399 @@
|
|||||||
|
//! The Coordinator's own protocol. Text frames are JSON control messages; binary frames carry one end-to-end frame for one connection, prefixed with the
|
||||||
|
//! connection number. The Coordinator routes by connection number and never looks inside.
|
||||||
|
|
||||||
|
use base64::engine::general_purpose::URL_SAFE_NO_PAD as B64;
|
||||||
|
use base64::Engine;
|
||||||
|
use coa_registry_proto::RealmId;
|
||||||
|
use ed25519_dalek::{Signature, Signer, SigningKey, VerifyingKey};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::{invalid, ControlError, Result};
|
||||||
|
|
||||||
|
/// The largest end-to-end frame the Coordinator forwards (a Noise message with its tag fits in 64 KiB; chunks are much smaller).
|
||||||
|
pub const MAX_FRAME_BYTES: usize = 20 * 1024;
|
||||||
|
/// Bytes of the connection number in front of a binary frame.
|
||||||
|
pub const CONN_PREFIX: usize = 4;
|
||||||
|
pub const MAX_CONTROL_TEXT_BYTES: usize = 2048;
|
||||||
|
pub const HELLO_TIMEOUT_SECS: u64 = 10;
|
||||||
|
/// A Hello's timestamp must be this close to the Coordinator's clock.
|
||||||
|
pub const MAX_HELLO_SKEW_SECS: i64 = 120;
|
||||||
|
|
||||||
|
/// Hard limits of the Coordinator (the defaults of its configuration).
|
||||||
|
pub mod limits {
|
||||||
|
/// Simultaneous Player connections routed to one Host.
|
||||||
|
pub const PER_HOST_CONNECTIONS: usize = 16;
|
||||||
|
/// Simultaneous connections from one address.
|
||||||
|
pub const PER_IP_CONNECTIONS: usize = 8;
|
||||||
|
/// New Player connections per minute per realm, and per address.
|
||||||
|
pub const PER_REALM_PER_MINUTE: u32 = 60;
|
||||||
|
pub const PER_IP_PER_MINUTE: u32 = 30;
|
||||||
|
/// Bytes through one connection, in total.
|
||||||
|
pub const BYTES_PER_CONNECTION: usize = 16 * 1024 * 1024;
|
||||||
|
/// Seconds a connection may live, and may be silent.
|
||||||
|
pub const CONNECTION_LIFETIME_SECS: u64 = 600;
|
||||||
|
pub const IDLE_SECS: u64 = 60;
|
||||||
|
/// Seconds the Host has to answer a new connection (the first frame back).
|
||||||
|
pub const HOST_ANSWER_SECS: u64 = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(tag = "t", rename_all = "snake_case", deny_unknown_fields)]
|
||||||
|
pub enum Frame {
|
||||||
|
/// Coordinator -> anyone who connected: prove who you are with this.
|
||||||
|
Challenge {
|
||||||
|
protocol: u32,
|
||||||
|
nonce: String,
|
||||||
|
},
|
||||||
|
/// Host -> Coordinator.
|
||||||
|
HostHello {
|
||||||
|
realm_id: RealmId,
|
||||||
|
ts: i64,
|
||||||
|
sig: String,
|
||||||
|
},
|
||||||
|
/// Player -> Coordinator (the realm it wants is in the URL and is signed).
|
||||||
|
PlayerHello {
|
||||||
|
player_id: Uuid,
|
||||||
|
public_key: String,
|
||||||
|
realm_id: RealmId,
|
||||||
|
ts: i64,
|
||||||
|
sig: String,
|
||||||
|
},
|
||||||
|
/// Coordinator -> Host: the Host is registered and these are the limits.
|
||||||
|
HostReady {
|
||||||
|
max_connections: u32,
|
||||||
|
max_frame: u32,
|
||||||
|
},
|
||||||
|
/// Coordinator -> Host: a Player wants to talk; its frames will carry this number.
|
||||||
|
Open {
|
||||||
|
conn: u32,
|
||||||
|
#[serde(default)]
|
||||||
|
client_ip: Option<String>,
|
||||||
|
},
|
||||||
|
/// Either side of a connection ends it.
|
||||||
|
Close {
|
||||||
|
conn: u32,
|
||||||
|
reason: Option<String>,
|
||||||
|
},
|
||||||
|
/// Coordinator -> Player: the Host accepted the connection; binary frames flow now.
|
||||||
|
PlayerReady {
|
||||||
|
conn: u32,
|
||||||
|
max_frame: u32,
|
||||||
|
},
|
||||||
|
Error {
|
||||||
|
code: ErrorCode,
|
||||||
|
message: String,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum ErrorCode {
|
||||||
|
BadHello,
|
||||||
|
UnknownRealm,
|
||||||
|
HostOffline,
|
||||||
|
HostBusy,
|
||||||
|
RateLimited,
|
||||||
|
TooLarge,
|
||||||
|
Timeout,
|
||||||
|
Internal,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct ProbePayload {
|
||||||
|
pub ports: Vec<u16>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
pub struct ProbeResponse {
|
||||||
|
pub client_ip: String,
|
||||||
|
pub results: std::collections::HashMap<u16, bool>,
|
||||||
|
pub all_reachable: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Coordinator authentication is independent of the encrypted application protocol.
|
||||||
|
/// Changing portable messages must not invalidate deployed v1 host/player proofs.
|
||||||
|
pub const COORDINATOR_PROTOCOL_VERSION: u32 = 1;
|
||||||
|
|
||||||
|
pub fn challenge_nonce() -> String {
|
||||||
|
let mut n = [0u8; 32];
|
||||||
|
n[..16].copy_from_slice(Uuid::new_v4().as_bytes());
|
||||||
|
n[16..].copy_from_slice(Uuid::new_v4().as_bytes());
|
||||||
|
B64.encode(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn host_input(realm: &RealmId, nonce: &str, ts: i64) -> Vec<u8> {
|
||||||
|
format!(
|
||||||
|
"coa-coord-host-v1\n{}\n{realm}\n{nonce}\n{ts}",
|
||||||
|
COORDINATOR_PROTOCOL_VERSION
|
||||||
|
)
|
||||||
|
.into_bytes()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn player_input(player: &Uuid, public_key: &str, realm: &RealmId, nonce: &str, ts: i64) -> Vec<u8> {
|
||||||
|
format!(
|
||||||
|
"coa-coord-player-v1\n{}\n{}\n{public_key}\n{realm}\n{nonce}\n{ts}",
|
||||||
|
COORDINATOR_PROTOCOL_VERSION,
|
||||||
|
player.hyphenated()
|
||||||
|
)
|
||||||
|
.into_bytes()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn sign_host_hello(key: &SigningKey, realm: &RealmId, nonce: &str, ts: i64) -> Frame {
|
||||||
|
Frame::HostHello {
|
||||||
|
realm_id: *realm,
|
||||||
|
ts,
|
||||||
|
sig: B64.encode(key.sign(&host_input(realm, nonce, ts)).to_bytes()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn sign_player_hello(
|
||||||
|
key: &SigningKey,
|
||||||
|
player: &Uuid,
|
||||||
|
realm: &RealmId,
|
||||||
|
nonce: &str,
|
||||||
|
ts: i64,
|
||||||
|
) -> Frame {
|
||||||
|
let public_key = B64.encode(key.verifying_key().as_bytes());
|
||||||
|
let sig = B64.encode(
|
||||||
|
key.sign(&player_input(player, &public_key, realm, nonce, ts))
|
||||||
|
.to_bytes(),
|
||||||
|
);
|
||||||
|
Frame::PlayerHello {
|
||||||
|
player_id: *player,
|
||||||
|
public_key,
|
||||||
|
realm_id: *realm,
|
||||||
|
ts,
|
||||||
|
sig,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decode_sig(sig: &str) -> Result<Signature> {
|
||||||
|
if sig.len() != 86 {
|
||||||
|
return invalid("the signature has the wrong length");
|
||||||
|
}
|
||||||
|
let bytes: [u8; 64] = B64
|
||||||
|
.decode(sig)
|
||||||
|
.map_err(|_| ControlError::Invalid("the signature is not base64url".into()))?
|
||||||
|
.try_into()
|
||||||
|
.map_err(|_| ControlError::Invalid("the signature is not 64 bytes".into()))?;
|
||||||
|
Ok(Signature::from_bytes(&bytes))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A Host's hello checked against the key the Registry holds for the realm.
|
||||||
|
pub fn verify_host_hello(
|
||||||
|
frame: &Frame,
|
||||||
|
realm_key: &VerifyingKey,
|
||||||
|
expect_realm: Option<&RealmId>,
|
||||||
|
nonce: &str,
|
||||||
|
now: i64,
|
||||||
|
) -> Result<RealmId> {
|
||||||
|
let Frame::HostHello { realm_id, ts, sig } = frame else {
|
||||||
|
return Err(ControlError::Auth("not a host hello".into()));
|
||||||
|
};
|
||||||
|
if expect_realm.is_some_and(|r| r != realm_id) {
|
||||||
|
return Err(ControlError::Auth("another realm".into()));
|
||||||
|
}
|
||||||
|
if (ts - now).abs() > MAX_HELLO_SKEW_SECS {
|
||||||
|
return Err(ControlError::Auth(
|
||||||
|
"the timestamp is outside the allowed skew".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
realm_key
|
||||||
|
.verify_strict(&host_input(realm_id, nonce, *ts), &decode_sig(sig)?)
|
||||||
|
.map_err(|_| ControlError::Auth("the signature does not match".into()))?;
|
||||||
|
Ok(*realm_id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A Player's hello checked against the key it presents (proof of possession; the Host decides whether it is a known player).
|
||||||
|
pub fn verify_player_hello(
|
||||||
|
frame: &Frame,
|
||||||
|
nonce: &str,
|
||||||
|
now: i64,
|
||||||
|
) -> Result<(Uuid, RealmId, VerifyingKey)> {
|
||||||
|
let Frame::PlayerHello {
|
||||||
|
player_id,
|
||||||
|
public_key,
|
||||||
|
realm_id,
|
||||||
|
ts,
|
||||||
|
sig,
|
||||||
|
} = frame
|
||||||
|
else {
|
||||||
|
return Err(ControlError::Auth("not a player hello".into()));
|
||||||
|
};
|
||||||
|
if (ts - now).abs() > MAX_HELLO_SKEW_SECS {
|
||||||
|
return Err(ControlError::Auth(
|
||||||
|
"the timestamp is outside the allowed skew".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
let key = decode_public_key(public_key)?;
|
||||||
|
key.verify_strict(
|
||||||
|
&player_input(player_id, public_key, realm_id, nonce, *ts),
|
||||||
|
&decode_sig(sig)?,
|
||||||
|
)
|
||||||
|
.map_err(|_| ControlError::Auth("the signature does not match".into()))?;
|
||||||
|
Ok((*player_id, *realm_id, key))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn decode_public_key(text: &str) -> Result<VerifyingKey> {
|
||||||
|
coa_registry_proto::sign::decode_public_key(text)
|
||||||
|
.map_err(|e| ControlError::Invalid(e.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn encode_public_key(key: &VerifyingKey) -> String {
|
||||||
|
coa_registry_proto::sign::encode_public_key(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `[connection number][end-to-end frame]`
|
||||||
|
pub fn binary(conn: u32, frame: &[u8]) -> Vec<u8> {
|
||||||
|
let mut out = Vec::with_capacity(CONN_PREFIX + frame.len());
|
||||||
|
out.extend_from_slice(&conn.to_be_bytes());
|
||||||
|
out.extend_from_slice(frame);
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn split_binary(data: &[u8]) -> Result<(u32, &[u8])> {
|
||||||
|
if data.len() < CONN_PREFIX || data.len() > CONN_PREFIX + MAX_FRAME_BYTES {
|
||||||
|
return Err(ControlError::Limit(
|
||||||
|
"a frame is too short or too long".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
Ok((
|
||||||
|
u32::from_be_bytes(data[..CONN_PREFIX].try_into().expect("4 bytes")),
|
||||||
|
&data[CONN_PREFIX..],
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse_text(text: &str) -> Result<Frame> {
|
||||||
|
if text.len() > MAX_CONTROL_TEXT_BYTES {
|
||||||
|
return Err(ControlError::Limit("a control message is too long".into()));
|
||||||
|
}
|
||||||
|
serde_json::from_str(text)
|
||||||
|
.map_err(|_| ControlError::Invalid("a control message is not valid".into()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_text(frame: &Frame) -> String {
|
||||||
|
serde_json::to_string(frame).expect("a frame serialises")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deployed_coordinator_proofs_stay_v1_when_application_protocol_changes() {
|
||||||
|
let realm = RealmId::new();
|
||||||
|
let player = Uuid::now_v7();
|
||||||
|
assert_eq!(host_input(&realm, "nonce", 42), format!("coa-coord-host-v1\n1\n{realm}\nnonce\n42").into_bytes());
|
||||||
|
assert_eq!(player_input(&player, "public", &realm, "nonce", 42), format!("coa-coord-player-v1\n1\n{player}\npublic\n{realm}\nnonce\n42").into_bytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn key(n: u8) -> SigningKey {
|
||||||
|
SigningKey::from_bytes(&[n; 32])
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_host_proves_its_realm_key_and_only_that() {
|
||||||
|
let realm = RealmId::new();
|
||||||
|
let nonce = challenge_nonce();
|
||||||
|
let hello = sign_host_hello(&key(1), &realm, &nonce, 1000);
|
||||||
|
assert_eq!(
|
||||||
|
verify_host_hello(&hello, &key(1).verifying_key(), Some(&realm), &nonce, 1010).unwrap(),
|
||||||
|
realm
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
verify_host_hello(&hello, &key(2).verifying_key(), Some(&realm), &nonce, 1010).is_err(),
|
||||||
|
"another key"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
verify_host_hello(
|
||||||
|
&hello,
|
||||||
|
&key(1).verifying_key(),
|
||||||
|
Some(&RealmId::new()),
|
||||||
|
&nonce,
|
||||||
|
1010
|
||||||
|
)
|
||||||
|
.is_err(),
|
||||||
|
"another realm"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
verify_host_hello(
|
||||||
|
&hello,
|
||||||
|
&key(1).verifying_key(),
|
||||||
|
None,
|
||||||
|
&challenge_nonce(),
|
||||||
|
1010
|
||||||
|
)
|
||||||
|
.is_err(),
|
||||||
|
"another challenge: no replay"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
verify_host_hello(&hello, &key(1).verifying_key(), None, &nonce, 5000).is_err(),
|
||||||
|
"too old"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_player_proves_possession_of_its_key() {
|
||||||
|
let (player, realm, nonce) = (Uuid::now_v7(), RealmId::new(), challenge_nonce());
|
||||||
|
let hello = sign_player_hello(&key(3), &player, &realm, &nonce, 50);
|
||||||
|
let (p, r, k) = verify_player_hello(&hello, &nonce, 55).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
(p, r, k.to_bytes()),
|
||||||
|
(player, realm, key(3).verifying_key().to_bytes())
|
||||||
|
);
|
||||||
|
let Frame::PlayerHello {
|
||||||
|
player_id,
|
||||||
|
public_key,
|
||||||
|
realm_id,
|
||||||
|
ts,
|
||||||
|
sig,
|
||||||
|
} = hello.clone()
|
||||||
|
else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
let other_key = encode_public_key(&key(4).verifying_key());
|
||||||
|
assert!(
|
||||||
|
verify_player_hello(
|
||||||
|
&Frame::PlayerHello {
|
||||||
|
player_id,
|
||||||
|
public_key: other_key,
|
||||||
|
realm_id,
|
||||||
|
ts,
|
||||||
|
sig: sig.clone()
|
||||||
|
},
|
||||||
|
&nonce,
|
||||||
|
55
|
||||||
|
)
|
||||||
|
.is_err(),
|
||||||
|
"a key that did not sign"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
verify_player_hello(
|
||||||
|
&Frame::PlayerHello {
|
||||||
|
player_id: Uuid::now_v7(),
|
||||||
|
public_key,
|
||||||
|
realm_id,
|
||||||
|
ts,
|
||||||
|
sig
|
||||||
|
},
|
||||||
|
&nonce,
|
||||||
|
55
|
||||||
|
)
|
||||||
|
.is_err(),
|
||||||
|
"another player id"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn frames_are_strict_and_bounded() {
|
||||||
|
assert!(parse_text(r#"{"t":"close","conn":1,"reason":null,"extra":1}"#).is_err());
|
||||||
|
assert!(parse_text(&"x".repeat(5000)).is_err());
|
||||||
|
assert!(parse_text(r#"{"t":"open","conn":7}"#).is_ok());
|
||||||
|
let b = binary(9, b"abc");
|
||||||
|
assert_eq!(split_binary(&b).unwrap(), (9, b"abc".as_slice()));
|
||||||
|
assert!(split_binary(&[0, 0]).is_err());
|
||||||
|
assert!(split_binary(&vec![0u8; CONN_PREFIX + MAX_FRAME_BYTES + 1]).is_err());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
//! The Player <-> Host control protocol (Phase 12), control plane only.
|
||||||
|
//!
|
||||||
|
//! ```text
|
||||||
|
//! Player Manager --(WebSocket)--> Coordinator <--(WebSocket, opened by the Host)-- Host Manager
|
||||||
|
//! \________ Noise_XX end-to-end channel, authenticated by Ed25519 signatures over its handshake hash ________/
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! * [`coord`]: what the Coordinator sees and decides: who may connect (a Host proves its RealmId key, a Player proves a PlayerId key), how frames are routed, the limits.
|
||||||
|
//! * [`noise`]: the end-to-end channel the Coordinator cannot read: the Noise handshake, the framing of long messages, and the binding of identities to it.
|
||||||
|
//! * [`app`]: the application messages inside the channel (account provisioning, listing and claiming characters, linking an existing account, the route).
|
||||||
|
//!
|
||||||
|
//! The Coordinator never receives plaintext account passwords, character data or database/RA credentials: everything of that kind exists only inside the channel.
|
||||||
|
|
||||||
|
pub mod app;
|
||||||
|
pub mod coord;
|
||||||
|
pub mod noise;
|
||||||
|
pub mod relay;
|
||||||
|
|
||||||
|
pub const CONTROL_PROTOCOL_VERSION: u32 = 2;
|
||||||
|
|
||||||
|
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
|
||||||
|
pub enum ControlError {
|
||||||
|
#[error("{0}")]
|
||||||
|
Invalid(String),
|
||||||
|
#[error("the channel failed: {0}")]
|
||||||
|
Channel(String),
|
||||||
|
#[error("the peer could not prove who it is: {0}")]
|
||||||
|
Auth(String),
|
||||||
|
#[error("a limit was exceeded: {0}")]
|
||||||
|
Limit(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type Result<T> = std::result::Result<T, ControlError>;
|
||||||
|
|
||||||
|
pub(crate) fn invalid<T>(m: impl Into<String>) -> Result<T> {
|
||||||
|
Err(ControlError::Invalid(m.into()))
|
||||||
|
}
|
||||||
@@ -0,0 +1,458 @@
|
|||||||
|
//! The end-to-end channel between a Player Manager and a Host Manager, over whatever carries frames between them (the Coordinator, later perhaps a direct socket).
|
||||||
|
//!
|
||||||
|
//! **Handshake: `Noise_XX_25519_ChaChaPoly_BLAKE2s`** (the Noise Protocol Framework, implemented by the `snow` crate; no primitive is invented here). Both sides use fresh
|
||||||
|
//! random X25519 static keys for each channel, so the Noise layer gives confidentiality, integrity and forward secrecy but no identity. Identity is added the standard way,
|
||||||
|
//! by **channel binding**: after the handshake each side signs the handshake hash `h` (unique to this channel) with its long-lived Ed25519 key.
|
||||||
|
//!
|
||||||
|
//! ```text
|
||||||
|
//! Player -> Host msg1 (e)
|
||||||
|
//! Host -> Player msg2 (e, ee, s, es)
|
||||||
|
//! Player -> Host msg3 (s, se) channel is open; h = the handshake hash
|
||||||
|
//! Host -> Player HostProof Ed25519_realm_key("coa-ctl-host-v1\0" || h || realm_id) the Player checks it against the key the Registry publishes
|
||||||
|
//! Player -> Host PlayerProof Ed25519_player_key("coa-ctl-player-v1\0" || h || realm_id || player_id) sent only after the Host's proof was good
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! A Coordinator that relays the frames can neither read nor alter them (Noise authenticates every message), and cannot impersonate either side: a signature over `h`
|
||||||
|
//! for one channel is useless on another.
|
||||||
|
|
||||||
|
use base64::engine::general_purpose::URL_SAFE_NO_PAD as B64;
|
||||||
|
use base64::Engine;
|
||||||
|
use coa_registry_proto::RealmId;
|
||||||
|
use ed25519_dalek::{Signature, Signer, SigningKey, VerifyingKey};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use snow::{Builder, HandshakeState, TransportState};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::{ControlError, Result};
|
||||||
|
|
||||||
|
pub const NOISE_PARAMS: &str = "Noise_XX_25519_ChaChaPoly_BLAKE2s";
|
||||||
|
/// Plaintext bytes per transport frame (a frame is this plus one flag byte plus the 16-byte tag).
|
||||||
|
pub const CHUNK: usize = 16 * 1024;
|
||||||
|
/// The largest application message (reassembled).
|
||||||
|
pub const MAX_MESSAGE_BYTES: usize = 8 * 1024 * 1024;
|
||||||
|
const MAX_HANDSHAKE_BYTES: usize = 1024;
|
||||||
|
|
||||||
|
fn channel_err(e: snow::Error) -> ControlError {
|
||||||
|
ControlError::Channel(e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn builder() -> Result<Builder<'static>> {
|
||||||
|
Ok(Builder::new(NOISE_PARAMS.parse().map_err(channel_err)?))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The Player's side of the handshake.
|
||||||
|
pub struct Initiator {
|
||||||
|
hs: HandshakeState,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Initiator {
|
||||||
|
/// The state and the first message to send.
|
||||||
|
pub fn start() -> Result<(Self, Vec<u8>)> {
|
||||||
|
let b = builder()?;
|
||||||
|
let key = b.generate_keypair().map_err(channel_err)?;
|
||||||
|
let mut hs = b
|
||||||
|
.local_private_key(&key.private)
|
||||||
|
.build_initiator()
|
||||||
|
.map_err(channel_err)?;
|
||||||
|
let mut buf = vec![0u8; MAX_HANDSHAKE_BYTES];
|
||||||
|
let n = hs.write_message(&[], &mut buf).map_err(channel_err)?;
|
||||||
|
buf.truncate(n);
|
||||||
|
Ok((Self { hs }, buf))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Read the Host's answer; returns the third message to send and the open channel.
|
||||||
|
pub fn finish(mut self, msg2: &[u8]) -> Result<(Vec<u8>, Channel)> {
|
||||||
|
if msg2.len() > MAX_HANDSHAKE_BYTES {
|
||||||
|
return Err(ControlError::Limit(
|
||||||
|
"a handshake message is too long".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
let mut buf = vec![0u8; MAX_HANDSHAKE_BYTES];
|
||||||
|
self.hs.read_message(msg2, &mut buf).map_err(channel_err)?;
|
||||||
|
let n = self.hs.write_message(&[], &mut buf).map_err(channel_err)?;
|
||||||
|
buf.truncate(n);
|
||||||
|
if !self.hs.is_handshake_finished() {
|
||||||
|
return Err(ControlError::Channel("the handshake did not finish".into()));
|
||||||
|
}
|
||||||
|
Ok((buf, Channel::from(self.hs)?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The Host's side of the handshake.
|
||||||
|
pub struct Responder {
|
||||||
|
hs: HandshakeState,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Responder {
|
||||||
|
/// Read the first message; returns the state and the second message to send.
|
||||||
|
pub fn start(msg1: &[u8]) -> Result<(Self, Vec<u8>)> {
|
||||||
|
if msg1.len() > MAX_HANDSHAKE_BYTES {
|
||||||
|
return Err(ControlError::Limit(
|
||||||
|
"a handshake message is too long".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
let b = builder()?;
|
||||||
|
let key = b.generate_keypair().map_err(channel_err)?;
|
||||||
|
let mut hs = b
|
||||||
|
.local_private_key(&key.private)
|
||||||
|
.build_responder()
|
||||||
|
.map_err(channel_err)?;
|
||||||
|
let mut buf = vec![0u8; MAX_HANDSHAKE_BYTES];
|
||||||
|
hs.read_message(msg1, &mut buf).map_err(channel_err)?;
|
||||||
|
let n = hs.write_message(&[], &mut buf).map_err(channel_err)?;
|
||||||
|
buf.truncate(n);
|
||||||
|
Ok((Self { hs }, buf))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn finish(mut self, msg3: &[u8]) -> Result<Channel> {
|
||||||
|
if msg3.len() > MAX_HANDSHAKE_BYTES {
|
||||||
|
return Err(ControlError::Limit(
|
||||||
|
"a handshake message is too long".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
let mut buf = vec![0u8; MAX_HANDSHAKE_BYTES];
|
||||||
|
self.hs.read_message(msg3, &mut buf).map_err(channel_err)?;
|
||||||
|
if !self.hs.is_handshake_finished() {
|
||||||
|
return Err(ControlError::Channel("the handshake did not finish".into()));
|
||||||
|
}
|
||||||
|
Channel::from(self.hs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An open channel: messages go out as one or more encrypted frames and come back reassembled.
|
||||||
|
pub struct Channel {
|
||||||
|
transport: TransportState,
|
||||||
|
hash: Vec<u8>,
|
||||||
|
partial: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Channel {
|
||||||
|
fn from(hs: HandshakeState) -> Result<Self> {
|
||||||
|
let hash = hs.get_handshake_hash().to_vec();
|
||||||
|
Ok(Self {
|
||||||
|
transport: hs.into_transport_mode().map_err(channel_err)?,
|
||||||
|
hash,
|
||||||
|
partial: Vec::new(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The handshake hash: unique to this channel, the same on both ends.
|
||||||
|
pub fn handshake_hash(&self) -> &[u8] {
|
||||||
|
&self.hash
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Encrypt one application message into frames (in order).
|
||||||
|
pub fn seal(&mut self, message: &[u8]) -> Result<Vec<Vec<u8>>> {
|
||||||
|
if message.len() > MAX_MESSAGE_BYTES {
|
||||||
|
return Err(ControlError::Limit("a message is too long".into()));
|
||||||
|
}
|
||||||
|
let chunks: Vec<&[u8]> = if message.is_empty() {
|
||||||
|
vec![&[][..]]
|
||||||
|
} else {
|
||||||
|
message.chunks(CHUNK).collect()
|
||||||
|
};
|
||||||
|
let mut frames = Vec::with_capacity(chunks.len());
|
||||||
|
for (i, chunk) in chunks.iter().enumerate() {
|
||||||
|
let mut plain = Vec::with_capacity(chunk.len() + 1);
|
||||||
|
plain.push(u8::from(i + 1 < chunks.len()));
|
||||||
|
plain.extend_from_slice(chunk);
|
||||||
|
let mut out = vec![0u8; plain.len() + 16];
|
||||||
|
let n = self
|
||||||
|
.transport
|
||||||
|
.write_message(&plain, &mut out)
|
||||||
|
.map_err(channel_err)?;
|
||||||
|
out.truncate(n);
|
||||||
|
frames.push(out);
|
||||||
|
}
|
||||||
|
Ok(frames)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decrypt one frame. `Some(message)` when it completed a message; `None` when more frames follow. A frame that does not authenticate ends the channel.
|
||||||
|
pub fn open_frame(&mut self, frame: &[u8]) -> Result<Option<Vec<u8>>> {
|
||||||
|
if frame.len() < 17 || frame.len() > CHUNK + 17 {
|
||||||
|
return Err(ControlError::Limit(
|
||||||
|
"a frame is too short or too long".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
let mut plain = vec![0u8; frame.len()];
|
||||||
|
let n = self
|
||||||
|
.transport
|
||||||
|
.read_message(frame, &mut plain)
|
||||||
|
.map_err(channel_err)?;
|
||||||
|
plain.truncate(n);
|
||||||
|
let (&more, chunk) = plain
|
||||||
|
.split_first()
|
||||||
|
.ok_or_else(|| ControlError::Channel("an empty frame".into()))?;
|
||||||
|
if self.partial.len() + chunk.len() > MAX_MESSAGE_BYTES {
|
||||||
|
self.partial.clear();
|
||||||
|
return Err(ControlError::Limit("a message is too long".into()));
|
||||||
|
}
|
||||||
|
self.partial.extend_from_slice(chunk);
|
||||||
|
match more {
|
||||||
|
0 => Ok(Some(std::mem::take(&mut self.partial))),
|
||||||
|
1 => Ok(None),
|
||||||
|
_ => {
|
||||||
|
self.partial.clear();
|
||||||
|
Err(ControlError::Channel("a frame has an unknown flag".into()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- identity bound to the channel --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
fn host_input(h: &[u8], realm: &RealmId) -> Vec<u8> {
|
||||||
|
let mut v = b"coa-ctl-host-v1\0".to_vec();
|
||||||
|
v.extend_from_slice(h);
|
||||||
|
v.extend_from_slice(realm.to_string().as_bytes());
|
||||||
|
v
|
||||||
|
}
|
||||||
|
|
||||||
|
fn player_input(h: &[u8], realm: &RealmId, player: &Uuid) -> Vec<u8> {
|
||||||
|
let mut v = b"coa-ctl-player-v1\0".to_vec();
|
||||||
|
v.extend_from_slice(h);
|
||||||
|
v.extend_from_slice(realm.to_string().as_bytes());
|
||||||
|
v.extend_from_slice(player.hyphenated().to_string().as_bytes());
|
||||||
|
v
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct HostProof {
|
||||||
|
pub realm_id: RealmId,
|
||||||
|
pub sig: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct PlayerProof {
|
||||||
|
pub player_id: Uuid,
|
||||||
|
pub public_key: String,
|
||||||
|
pub sig: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decode_sig(sig: &str) -> Result<Signature> {
|
||||||
|
let bytes: [u8; 64] = B64
|
||||||
|
.decode(sig)
|
||||||
|
.ok()
|
||||||
|
.and_then(|b| b.try_into().ok())
|
||||||
|
.ok_or_else(|| ControlError::Auth("a signature is not 64 bytes of base64url".into()))?;
|
||||||
|
Ok(Signature::from_bytes(&bytes))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn host_proof(key: &SigningKey, realm: &RealmId, channel: &Channel) -> HostProof {
|
||||||
|
HostProof {
|
||||||
|
realm_id: *realm,
|
||||||
|
sig: B64.encode(
|
||||||
|
key.sign(&host_input(channel.handshake_hash(), realm))
|
||||||
|
.to_bytes(),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The Player checks that the peer holds the key the Registry publishes for the realm it asked for, on this very channel.
|
||||||
|
pub fn verify_host_proof(
|
||||||
|
proof: &HostProof,
|
||||||
|
realm_key: &VerifyingKey,
|
||||||
|
expected_realm: &RealmId,
|
||||||
|
channel: &Channel,
|
||||||
|
) -> Result<()> {
|
||||||
|
if proof.realm_id != *expected_realm {
|
||||||
|
return Err(ControlError::Auth(
|
||||||
|
"the peer answers for another realm".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
realm_key
|
||||||
|
.verify_strict(
|
||||||
|
&host_input(channel.handshake_hash(), expected_realm),
|
||||||
|
&decode_sig(&proof.sig)?,
|
||||||
|
)
|
||||||
|
.map_err(|_| ControlError::Auth("the peer is not the realm's Host".into()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn player_proof(
|
||||||
|
key: &SigningKey,
|
||||||
|
realm: &RealmId,
|
||||||
|
player: &Uuid,
|
||||||
|
channel: &Channel,
|
||||||
|
) -> PlayerProof {
|
||||||
|
PlayerProof {
|
||||||
|
player_id: *player,
|
||||||
|
public_key: crate::coord::encode_public_key(&key.verifying_key()),
|
||||||
|
sig: B64.encode(
|
||||||
|
key.sign(&player_input(channel.handshake_hash(), realm, player))
|
||||||
|
.to_bytes(),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The Host learns which player key signed this channel; whether that key is the one it knows for the player id is the Host's decision.
|
||||||
|
pub fn verify_player_proof(
|
||||||
|
proof: &PlayerProof,
|
||||||
|
realm: &RealmId,
|
||||||
|
channel: &Channel,
|
||||||
|
) -> Result<VerifyingKey> {
|
||||||
|
let key = crate::coord::decode_public_key(&proof.public_key)?;
|
||||||
|
key.verify_strict(
|
||||||
|
&player_input(channel.handshake_hash(), realm, &proof.player_id),
|
||||||
|
&decode_sig(&proof.sig)?,
|
||||||
|
)
|
||||||
|
.map_err(|_| ControlError::Auth("the player's proof does not match this channel".into()))?;
|
||||||
|
Ok(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn pair() -> (Channel, Channel) {
|
||||||
|
let (init, m1) = Initiator::start().unwrap();
|
||||||
|
let (resp, m2) = Responder::start(&m1).unwrap();
|
||||||
|
let (m3, player) = init.finish(&m2).unwrap();
|
||||||
|
let host = resp.finish(&m3).unwrap();
|
||||||
|
(player, host)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_channel_carries_messages_of_any_size_in_both_directions() {
|
||||||
|
let (mut player, mut host) = pair();
|
||||||
|
assert_eq!(
|
||||||
|
player.handshake_hash(),
|
||||||
|
host.handshake_hash(),
|
||||||
|
"both ends hold the same channel binding"
|
||||||
|
);
|
||||||
|
for len in [
|
||||||
|
0usize,
|
||||||
|
1,
|
||||||
|
100,
|
||||||
|
CHUNK - 1,
|
||||||
|
CHUNK,
|
||||||
|
CHUNK + 1,
|
||||||
|
5 * CHUNK + 7,
|
||||||
|
600_000,
|
||||||
|
] {
|
||||||
|
let msg: Vec<u8> = (0..len).map(|i| (i * 31 % 251) as u8).collect();
|
||||||
|
let frames = player.seal(&msg).unwrap();
|
||||||
|
assert!(
|
||||||
|
frames.iter().all(|f| f.len() <= CHUNK + 17),
|
||||||
|
"every frame fits the coordinator's limit"
|
||||||
|
);
|
||||||
|
let mut got = None;
|
||||||
|
for f in &frames {
|
||||||
|
got = host.open_frame(f).unwrap();
|
||||||
|
}
|
||||||
|
assert_eq!(got.as_deref(), Some(msg.as_slice()), "{len}");
|
||||||
|
let back = host.seal(&msg).unwrap();
|
||||||
|
let mut got = None;
|
||||||
|
for f in &back {
|
||||||
|
got = player.open_frame(f).unwrap();
|
||||||
|
}
|
||||||
|
assert_eq!(got.as_deref(), Some(msg.as_slice()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn what_a_relay_sees_is_not_the_message_and_what_it_changes_is_refused() {
|
||||||
|
let (mut player, mut host) = pair();
|
||||||
|
let secret = b"the password of this account is HUNTER2HUNTER2";
|
||||||
|
let frames = player.seal(secret).unwrap();
|
||||||
|
assert!(
|
||||||
|
!frames[0]
|
||||||
|
.windows(7)
|
||||||
|
.any(|w| w == b"HUNTER2" || w == b"account"),
|
||||||
|
"ciphertext carries no plaintext"
|
||||||
|
);
|
||||||
|
let mut tampered = frames[0].clone();
|
||||||
|
tampered[20] ^= 1;
|
||||||
|
assert!(
|
||||||
|
host.open_frame(&tampered).is_err(),
|
||||||
|
"a changed frame does not authenticate"
|
||||||
|
);
|
||||||
|
let (mut p2, mut h2) = pair();
|
||||||
|
let f = p2.seal(b"x").unwrap();
|
||||||
|
assert!(h2.open_frame(&f[0]).is_ok());
|
||||||
|
assert!(
|
||||||
|
h2.open_frame(&f[0]).is_err(),
|
||||||
|
"a replayed frame is refused (the nonce moved on)"
|
||||||
|
);
|
||||||
|
let (mut p3, mut h3) = pair();
|
||||||
|
let (mut p4, _h4) = pair();
|
||||||
|
let foreign = p4.seal(b"x").unwrap();
|
||||||
|
assert!(
|
||||||
|
h3.open_frame(&foreign[0]).is_err(),
|
||||||
|
"a frame of another channel is refused"
|
||||||
|
);
|
||||||
|
let _ = &mut p3;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_message_that_is_too_long_or_a_frame_that_is_malformed_is_a_limit_error() {
|
||||||
|
let (mut player, mut host) = pair();
|
||||||
|
assert!(player.seal(&vec![0u8; MAX_MESSAGE_BYTES + 1]).is_err());
|
||||||
|
assert!(host.open_frame(&[0u8; 5]).is_err());
|
||||||
|
assert!(host.open_frame(&vec![0u8; CHUNK + 40]).is_err());
|
||||||
|
assert!(Responder::start(&vec![0u8; 5000]).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn identities_are_bound_to_one_channel() {
|
||||||
|
let (player_ch, host_ch) = pair();
|
||||||
|
let (other_player_ch, _other_host_ch) = pair();
|
||||||
|
let realm = RealmId::new();
|
||||||
|
let (realm_key, player_key) = (
|
||||||
|
SigningKey::from_bytes(&[5; 32]),
|
||||||
|
SigningKey::from_bytes(&[6; 32]),
|
||||||
|
);
|
||||||
|
let player_id = Uuid::now_v7();
|
||||||
|
|
||||||
|
let proof = host_proof(&realm_key, &realm, &host_ch);
|
||||||
|
verify_host_proof(&proof, &realm_key.verifying_key(), &realm, &player_ch).unwrap();
|
||||||
|
assert!(
|
||||||
|
verify_host_proof(
|
||||||
|
&proof,
|
||||||
|
&SigningKey::from_bytes(&[9; 32]).verifying_key(),
|
||||||
|
&realm,
|
||||||
|
&player_ch
|
||||||
|
)
|
||||||
|
.is_err(),
|
||||||
|
"an impostor with another key"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
verify_host_proof(
|
||||||
|
&proof,
|
||||||
|
&realm_key.verifying_key(),
|
||||||
|
&RealmId::new(),
|
||||||
|
&player_ch
|
||||||
|
)
|
||||||
|
.is_err(),
|
||||||
|
"another realm"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
verify_host_proof(&proof, &realm_key.verifying_key(), &realm, &other_player_ch)
|
||||||
|
.is_err(),
|
||||||
|
"a proof captured on another channel is useless (no relay can replay it)"
|
||||||
|
);
|
||||||
|
|
||||||
|
let pp = player_proof(&player_key, &realm, &player_id, &player_ch);
|
||||||
|
let key = verify_player_proof(&pp, &realm, &host_ch).unwrap();
|
||||||
|
assert_eq!(key.to_bytes(), player_key.verifying_key().to_bytes());
|
||||||
|
assert!(verify_player_proof(&pp, &RealmId::new(), &host_ch).is_err());
|
||||||
|
assert!(
|
||||||
|
verify_player_proof(
|
||||||
|
&PlayerProof {
|
||||||
|
player_id: Uuid::now_v7(),
|
||||||
|
..pp.clone()
|
||||||
|
},
|
||||||
|
&realm,
|
||||||
|
&host_ch
|
||||||
|
)
|
||||||
|
.is_err(),
|
||||||
|
"another player id under the same signature"
|
||||||
|
);
|
||||||
|
let (_, third_host) = pair();
|
||||||
|
assert!(
|
||||||
|
verify_player_proof(&pp, &realm, &third_host).is_err(),
|
||||||
|
"another channel"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,318 @@
|
|||||||
|
//! Game Relay protocol (Phase 13):
|
||||||
|
//! Host-to-Relay multiplexed tunnel protocol, allocation messaging,
|
||||||
|
//! challenge-response authentication, and WoW 3.3.5 REALM_LIST address rewrite helper.
|
||||||
|
|
||||||
|
use coa_registry_proto::RealmId;
|
||||||
|
use ed25519_dalek::{Signature, Signer, SigningKey, VerifyingKey};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
pub const RELAY_PROTOCOL_VERSION: u32 = 1;
|
||||||
|
|
||||||
|
/// Default local targets that the Host opens for game traffic.
|
||||||
|
pub const LOCAL_AUTH_PORT: u16 = 3724;
|
||||||
|
pub const LOCAL_WORLD_PORT: u16 = 8085;
|
||||||
|
|
||||||
|
/// Predefined targets that the Relay can request over the Host tunnel.
|
||||||
|
/// Arbitrary destinations are strictly forbidden.
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum RelayTarget {
|
||||||
|
Auth,
|
||||||
|
World,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RelayTarget {
|
||||||
|
pub fn local_port(&self) -> u16 {
|
||||||
|
match self {
|
||||||
|
RelayTarget::Auth => std::env::var("COA_OVERRIDE_LOCAL_AUTH_PORT")
|
||||||
|
.ok()
|
||||||
|
.and_then(|p| p.parse().ok())
|
||||||
|
.unwrap_or(LOCAL_AUTH_PORT),
|
||||||
|
RelayTarget::World => std::env::var("COA_OVERRIDE_LOCAL_WORLD_PORT")
|
||||||
|
.ok()
|
||||||
|
.and_then(|p| p.parse().ok())
|
||||||
|
.unwrap_or(LOCAL_WORLD_PORT),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct RelayChallenge {
|
||||||
|
pub nonce: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct HostHello {
|
||||||
|
pub realm_id: RealmId,
|
||||||
|
pub signature: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct RelayWelcome {
|
||||||
|
pub ok: bool,
|
||||||
|
pub message: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Messages multiplexed across the Host <-> Relay tunnel.
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(tag = "cmd", rename_all = "snake_case", deny_unknown_fields)]
|
||||||
|
pub enum TunnelMsg {
|
||||||
|
/// Host asks Relay to allocate a game session for a player.
|
||||||
|
Allocate {
|
||||||
|
request_id: u64,
|
||||||
|
player_id: Uuid,
|
||||||
|
#[serde(default)]
|
||||||
|
expected_client_ip: Option<String>,
|
||||||
|
},
|
||||||
|
/// Relay responds to Host with allocation details.
|
||||||
|
AllocateOk {
|
||||||
|
request_id: u64,
|
||||||
|
token: String,
|
||||||
|
relay_host: String,
|
||||||
|
auth_port: u16,
|
||||||
|
world_port: u16,
|
||||||
|
expires_at: i64,
|
||||||
|
},
|
||||||
|
AllocateErr {
|
||||||
|
request_id: u64,
|
||||||
|
error: String,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// Relay asks Host to open a local connection to `target` (Auth or World) for an incoming player connection.
|
||||||
|
Connect {
|
||||||
|
stream_id: u32,
|
||||||
|
target: RelayTarget,
|
||||||
|
token: String,
|
||||||
|
},
|
||||||
|
/// Host confirms local connection established.
|
||||||
|
ConnectOk {
|
||||||
|
stream_id: u32,
|
||||||
|
},
|
||||||
|
/// Connect failed.
|
||||||
|
ConnectErr {
|
||||||
|
stream_id: u32,
|
||||||
|
error: String,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// Stream data chunk (base64 encoded).
|
||||||
|
Data {
|
||||||
|
stream_id: u32,
|
||||||
|
chunk: String,
|
||||||
|
},
|
||||||
|
/// Stream clean half-close / EOF.
|
||||||
|
Close {
|
||||||
|
stream_id: u32,
|
||||||
|
},
|
||||||
|
/// Stream abrupt abort / error.
|
||||||
|
Reset {
|
||||||
|
stream_id: u32,
|
||||||
|
},
|
||||||
|
/// Keepalive ping.
|
||||||
|
Ping,
|
||||||
|
/// Keepalive pong.
|
||||||
|
Pong,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn relay_input(realm: &RealmId, nonce: &str) -> Vec<u8> {
|
||||||
|
format!(
|
||||||
|
"coa-relay-host-v1\n{}\n{realm}\n{nonce}",
|
||||||
|
RELAY_PROTOCOL_VERSION
|
||||||
|
)
|
||||||
|
.into_bytes()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a signature over (realm_id, nonce) using the realm's signing key.
|
||||||
|
pub fn sign_relay_challenge(key: &SigningKey, realm_id: &RealmId, nonce: &str) -> String {
|
||||||
|
let sig: Signature = key.sign(&relay_input(realm_id, nonce));
|
||||||
|
hex::encode(sig.to_bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Verify a signature over (realm_id, nonce) using the realm's verifying key.
|
||||||
|
pub fn verify_relay_challenge(
|
||||||
|
key: &VerifyingKey,
|
||||||
|
realm_id: &RealmId,
|
||||||
|
nonce: &str,
|
||||||
|
sig_hex: &str,
|
||||||
|
) -> bool {
|
||||||
|
let Ok(sig_bytes) = hex::decode(sig_hex) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
let Ok(sig) = Signature::from_slice(&sig_bytes) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
key.verify_strict(&relay_input(realm_id, nonce), &sig)
|
||||||
|
.is_ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Rewrites the realm address in a WoW 3.3.5 REALM_LIST response packet (Opcode 0x10).
|
||||||
|
///
|
||||||
|
/// In WoW 3.3.5 client protocol:
|
||||||
|
/// - Byte 0: 0x10 (REALM_LIST)
|
||||||
|
/// - Bytes 1..2: uint16 LE payload length (total size after byte 2)
|
||||||
|
/// - Bytes 3..6: uint32 LE unused (0)
|
||||||
|
/// - Bytes 7..8: uint16 LE realm count
|
||||||
|
/// - For each realm:
|
||||||
|
/// - uint8 type (1 byte)
|
||||||
|
/// - uint8 lock (1 byte)
|
||||||
|
/// - uint8 flag (1 byte)
|
||||||
|
/// - name: null-terminated C string
|
||||||
|
/// - address: null-terminated C string ("host:port\0")
|
||||||
|
/// - population: 4 bytes float
|
||||||
|
/// - characters: 1 byte uint8
|
||||||
|
/// - timezone: 1 byte uint8
|
||||||
|
/// - realm_id: 1 byte uint8
|
||||||
|
/// - if flag & 0x04 (SPECIFYBUILD): 5 bytes build info
|
||||||
|
/// - Footer: 2 bytes (0x10, 0x00)
|
||||||
|
///
|
||||||
|
/// Replaces the address of the first realm (or matches) with `new_host_port` and adjusts
|
||||||
|
/// the uint16 length at bytes 1..2 by the byte length delta.
|
||||||
|
pub fn rewrite_realm_list_address(
|
||||||
|
pkt: &[u8],
|
||||||
|
new_host_port: &str,
|
||||||
|
) -> Result<Option<Vec<u8>>, String> {
|
||||||
|
if pkt.is_empty() || pkt[0] != 0x10 {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
if pkt.len() < 9 {
|
||||||
|
return Err("packet too short for REALM_LIST header".into());
|
||||||
|
}
|
||||||
|
let body_len = u16::from_le_bytes([pkt[1], pkt[2]]) as usize;
|
||||||
|
if pkt.len() < 3 + body_len {
|
||||||
|
return Err("truncated REALM_LIST packet".into());
|
||||||
|
}
|
||||||
|
let realm_count = u16::from_le_bytes([pkt[7], pkt[8]]) as usize;
|
||||||
|
if realm_count == 0 {
|
||||||
|
return Ok(Some(pkt.to_vec()));
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut pos = 9;
|
||||||
|
if pos + 3 > pkt.len() {
|
||||||
|
return Err("malformed realm header".into());
|
||||||
|
}
|
||||||
|
pos += 3; // type, lock, flag
|
||||||
|
|
||||||
|
let name_end = pkt[pos..]
|
||||||
|
.iter()
|
||||||
|
.position(|&b| b == 0)
|
||||||
|
.ok_or("unterminated realm name")?
|
||||||
|
+ pos;
|
||||||
|
pos = name_end + 1;
|
||||||
|
|
||||||
|
let addr_start = pos;
|
||||||
|
let addr_end = pkt[pos..]
|
||||||
|
.iter()
|
||||||
|
.position(|&b| b == 0)
|
||||||
|
.ok_or("unterminated realm address")?
|
||||||
|
+ pos;
|
||||||
|
let old_addr = &pkt[addr_start..addr_end];
|
||||||
|
|
||||||
|
if new_host_port.len() > 255 {
|
||||||
|
return Err("new host:port exceeds maximum address length".into());
|
||||||
|
}
|
||||||
|
let diff = new_host_port.len() as isize - old_addr.len() as isize;
|
||||||
|
let new_body_len_isize = body_len as isize + diff;
|
||||||
|
if !(0..=u16::MAX as isize).contains(&new_body_len_isize) {
|
||||||
|
return Err("adjusted body length out of bounds".into());
|
||||||
|
}
|
||||||
|
let new_body_len = new_body_len_isize as u16;
|
||||||
|
|
||||||
|
let mut out = Vec::with_capacity(pkt.len() + new_host_port.len() + 1);
|
||||||
|
out.extend_from_slice(&pkt[..addr_start]);
|
||||||
|
out.extend_from_slice(new_host_port.as_bytes());
|
||||||
|
out.extend_from_slice(&pkt[addr_end..]);
|
||||||
|
out[1..3].copy_from_slice(&new_body_len.to_le_bytes());
|
||||||
|
|
||||||
|
Ok(Some(out))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn challenge_signature_roundtrip() {
|
||||||
|
let seed = [42u8; 32];
|
||||||
|
let key = SigningKey::from_bytes(&seed);
|
||||||
|
|
||||||
|
let realm = RealmId::new();
|
||||||
|
let nonce = "test-challenge-nonce-123";
|
||||||
|
|
||||||
|
let sig = sign_relay_challenge(&key, &realm, nonce);
|
||||||
|
assert!(verify_relay_challenge(
|
||||||
|
&key.verifying_key(),
|
||||||
|
&realm,
|
||||||
|
nonce,
|
||||||
|
&sig
|
||||||
|
));
|
||||||
|
|
||||||
|
// Wrong nonce
|
||||||
|
assert!(!verify_relay_challenge(
|
||||||
|
&key.verifying_key(),
|
||||||
|
&realm,
|
||||||
|
"other-nonce",
|
||||||
|
&sig
|
||||||
|
));
|
||||||
|
// Wrong realm
|
||||||
|
assert!(!verify_relay_challenge(
|
||||||
|
&key.verifying_key(),
|
||||||
|
&RealmId::new(),
|
||||||
|
nonce,
|
||||||
|
&sig
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rewrite_realm_list_address_works() {
|
||||||
|
// Build a mock REALM_LIST packet for WoW 3.3.5
|
||||||
|
let mut pkt = Vec::new();
|
||||||
|
pkt.push(0x10); // Opcode
|
||||||
|
pkt.extend_from_slice(&[0, 0]); // Placeholder for body_len
|
||||||
|
pkt.extend_from_slice(&[0, 0, 0, 0]); // Unused uint32
|
||||||
|
pkt.extend_from_slice(&1u16.to_le_bytes()); // Realm count = 1
|
||||||
|
|
||||||
|
// Realm 0
|
||||||
|
pkt.push(1); // Type
|
||||||
|
pkt.push(0); // Lock
|
||||||
|
pkt.push(0); // Flags
|
||||||
|
pkt.extend_from_slice(b"CoA Test Realm\0"); // Name
|
||||||
|
pkt.extend_from_slice(b"127.0.0.1:8085\0"); // Old Address
|
||||||
|
pkt.extend_from_slice(&0.5f32.to_le_bytes()); // Population
|
||||||
|
pkt.push(1); // Characters
|
||||||
|
pkt.push(1); // Timezone
|
||||||
|
pkt.push(1); // Realm ID
|
||||||
|
|
||||||
|
// Footer
|
||||||
|
pkt.push(0x10);
|
||||||
|
pkt.push(0x00);
|
||||||
|
|
||||||
|
let body_len = (pkt.len() - 3) as u16;
|
||||||
|
pkt[1..3].copy_from_slice(&body_len.to_le_bytes());
|
||||||
|
|
||||||
|
// Rewrite
|
||||||
|
let new_target = "coa-manager.duckdns.org:40005";
|
||||||
|
let res = rewrite_realm_list_address(&pkt, new_target)
|
||||||
|
.unwrap()
|
||||||
|
.expect("rewritten");
|
||||||
|
|
||||||
|
assert_eq!(res[0], 0x10);
|
||||||
|
let new_len = u16::from_le_bytes([res[1], res[2]]) as usize;
|
||||||
|
assert_eq!(res.len(), 3 + new_len);
|
||||||
|
|
||||||
|
// Address in res must be new_target
|
||||||
|
let old_addr = b"127.0.0.1:8085";
|
||||||
|
let new_addr = b"coa-manager.duckdns.org:40005";
|
||||||
|
assert!(!res.windows(old_addr.len()).any(|w| w == old_addr));
|
||||||
|
assert!(res.windows(new_addr.len()).any(|w| w == new_addr));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn non_realm_list_ignored() {
|
||||||
|
let pkt = vec![0x00, 0x01, 0x02];
|
||||||
|
assert_eq!(rewrite_realm_list_address(&pkt, "test:8085"), Ok(None));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,280 @@
|
|||||||
|
//! Adversarial, property and hostile-input fuzz tests for Phase 15.
|
||||||
|
//! Verifies that malformed or malicious inputs never panic, integer operations
|
||||||
|
//! do not wrap, allocations remain bounded, and invalid states fail closed.
|
||||||
|
|
||||||
|
use coa_control_proto::app::{
|
||||||
|
decode_request, decode_response, encode_request, Request, MAX_TRANSFER_REQUEST_BYTES,
|
||||||
|
};
|
||||||
|
use coa_control_proto::coord::{
|
||||||
|
parse_text, split_binary, Frame, ProbePayload, CONN_PREFIX, MAX_FRAME_BYTES,
|
||||||
|
};
|
||||||
|
use coa_control_proto::noise::{Initiator, Responder, CHUNK};
|
||||||
|
use coa_control_proto::relay::{
|
||||||
|
rewrite_realm_list_address, sign_relay_challenge, verify_relay_challenge, TunnelMsg,
|
||||||
|
};
|
||||||
|
use coa_registry_proto::sign::RealmId;
|
||||||
|
use ed25519_dalek::SigningKey;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cmd_realm_list_rewriter_adversarial_and_bounds() {
|
||||||
|
let dummy_target = "127.0.0.1:8085";
|
||||||
|
|
||||||
|
// 1. Truncated inputs
|
||||||
|
assert!(rewrite_realm_list_address(&[], dummy_target)
|
||||||
|
.unwrap()
|
||||||
|
.is_none());
|
||||||
|
assert!(rewrite_realm_list_address(&[0x10], dummy_target).is_err());
|
||||||
|
assert!(rewrite_realm_list_address(&[0x10, 0x05, 0x00], dummy_target).is_err());
|
||||||
|
assert!(
|
||||||
|
rewrite_realm_list_address(&[0x10, 0x10, 0x00, 0, 0, 0, 0, 1, 0], dummy_target).is_err()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 2. Non-0x10 opcodes ignored safely
|
||||||
|
assert!(rewrite_realm_list_address(&[0x00, 0x01], dummy_target)
|
||||||
|
.unwrap()
|
||||||
|
.is_none());
|
||||||
|
assert!(rewrite_realm_list_address(&[0xFF; 20], dummy_target)
|
||||||
|
.unwrap()
|
||||||
|
.is_none());
|
||||||
|
|
||||||
|
// 3. Zero realms handled safely
|
||||||
|
let zero_realms = [
|
||||||
|
0x10, // Opcode
|
||||||
|
0x06, 0x00, // Length: 6 bytes follow
|
||||||
|
0x00, 0x00, 0x00, 0x00, // Unused
|
||||||
|
0x00, 0x00, // Realm count: 0
|
||||||
|
];
|
||||||
|
let res = rewrite_realm_list_address(&zero_realms, dummy_target).unwrap();
|
||||||
|
assert_eq!(res.unwrap(), zero_realms);
|
||||||
|
|
||||||
|
// 4. Missing null terminators in realm string
|
||||||
|
let unterminated_name = [
|
||||||
|
0x10, 0x20, 0x00, 0, 0, 0, 0, 1, 0, // Header (count = 1)
|
||||||
|
1, 0, 0, // type, lock, flag
|
||||||
|
b'R', b'e', b'a', b'l', b'm', // no null byte!
|
||||||
|
];
|
||||||
|
assert!(rewrite_realm_list_address(&unterminated_name, dummy_target).is_err());
|
||||||
|
|
||||||
|
// 5. Excessive new address (> 255 bytes) rejected
|
||||||
|
let giant_addr = "a".repeat(256);
|
||||||
|
let valid_packet = make_valid_realm_list_pkt("1.2.3.4:1234");
|
||||||
|
assert!(rewrite_realm_list_address(&valid_packet, &giant_addr).is_err());
|
||||||
|
|
||||||
|
// 6. Valid rewrite preserves packet structure
|
||||||
|
let rewritten = rewrite_realm_list_address(&valid_packet, "99.88.77.66:30000")
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(rewritten[0], 0x10);
|
||||||
|
let s = String::from_utf8_lossy(&rewritten);
|
||||||
|
assert!(s.contains("99.88.77.66:30000"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_app_request_hostile_limits_and_validation() {
|
||||||
|
// 1. Oversized control request (> 4096 bytes)
|
||||||
|
let big_client = "A".repeat(5000);
|
||||||
|
let big_hello = format!(r#"{{"op":"hello","protocol":1,"client":"{big_client}"}}"#);
|
||||||
|
assert!(decode_request(big_hello.as_bytes()).is_err());
|
||||||
|
|
||||||
|
// 2. Unknown fields rejected
|
||||||
|
let extra_field = r#"{"op":"claim","token":1,"unknown_admin_flag":true}"#;
|
||||||
|
assert!(decode_request(extra_field.as_bytes()).is_err());
|
||||||
|
|
||||||
|
// 3. Giant collection count in TransferOffer rejected
|
||||||
|
let mut collections = BTreeMap::new();
|
||||||
|
for i in 0..1500 {
|
||||||
|
collections.insert(format!("cat_{i}"), vec![1, 2, 3]);
|
||||||
|
}
|
||||||
|
let offer = Request::TransferOffer {
|
||||||
|
transfer_id: Uuid::now_v7(),
|
||||||
|
character_id: Uuid::now_v7(),
|
||||||
|
ruleset: "coa".into(),
|
||||||
|
canonical_revision: 1,
|
||||||
|
content_hash: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into(),
|
||||||
|
total_size: 1024,
|
||||||
|
collections,
|
||||||
|
};
|
||||||
|
let offer_bytes = encode_request(&offer);
|
||||||
|
assert!(
|
||||||
|
decode_request(&offer_bytes).is_err(),
|
||||||
|
"offers with > 1000 categories must be rejected"
|
||||||
|
);
|
||||||
|
|
||||||
|
// 4. Invalid content hash (not 64 hex chars)
|
||||||
|
let bad_hash_offer = Request::TransferOffer {
|
||||||
|
transfer_id: Uuid::now_v7(),
|
||||||
|
character_id: Uuid::now_v7(),
|
||||||
|
ruleset: "coa".into(),
|
||||||
|
canonical_revision: 1,
|
||||||
|
content_hash: "not_a_valid_hex_hash".into(),
|
||||||
|
total_size: 1024,
|
||||||
|
collections: BTreeMap::new(),
|
||||||
|
};
|
||||||
|
assert!(decode_request(&encode_request(&bad_hash_offer)).is_err());
|
||||||
|
|
||||||
|
// 4b. Invalid ruleset rejected
|
||||||
|
let bad_ruleset_offer = Request::TransferOffer {
|
||||||
|
transfer_id: Uuid::now_v7(),
|
||||||
|
character_id: Uuid::now_v7(),
|
||||||
|
ruleset: "invalid_ruleset".into(),
|
||||||
|
canonical_revision: 1,
|
||||||
|
content_hash: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into(),
|
||||||
|
total_size: 1024,
|
||||||
|
collections: BTreeMap::new(),
|
||||||
|
};
|
||||||
|
assert!(decode_request(&encode_request(&bad_ruleset_offer)).is_err());
|
||||||
|
|
||||||
|
// 5. TransferChunk offset out of bounds
|
||||||
|
let bad_offset_chunk = Request::TransferChunk {
|
||||||
|
transfer_id: Uuid::now_v7(),
|
||||||
|
offset: MAX_TRANSFER_REQUEST_BYTES + 1,
|
||||||
|
data: "abc".into(),
|
||||||
|
};
|
||||||
|
assert!(decode_request(&encode_request(&bad_offset_chunk)).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_coordinator_text_and_binary_adversarial() {
|
||||||
|
// 1. Oversized text frame (> 2048 bytes)
|
||||||
|
let giant_text = format!(
|
||||||
|
r#"{{"t":"close","conn":1,"reason":"{}"}}"#,
|
||||||
|
"x".repeat(3000)
|
||||||
|
);
|
||||||
|
assert!(parse_text(&giant_text).is_err());
|
||||||
|
|
||||||
|
// 2. Binary frame bounds
|
||||||
|
assert!(split_binary(&[]).is_err());
|
||||||
|
assert!(split_binary(&[0, 1, 2]).is_err()); // less than 4 bytes
|
||||||
|
let max_allowed = vec![0u8; CONN_PREFIX + MAX_FRAME_BYTES];
|
||||||
|
assert!(split_binary(&max_allowed).is_ok());
|
||||||
|
let too_large = vec![0u8; CONN_PREFIX + MAX_FRAME_BYTES + 1];
|
||||||
|
assert!(split_binary(&too_large).is_err());
|
||||||
|
|
||||||
|
// 3. ProbePayload unknown fields rejected
|
||||||
|
let bad_probe = r#"{"ports":[8085],"admin":true}"#;
|
||||||
|
assert!(serde_json::from_str::<ProbePayload>(bad_probe).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_noise_frame_reassembly_adversarial() {
|
||||||
|
let (init, msg1) = Initiator::start().unwrap();
|
||||||
|
let (resp, msg2) = Responder::start(&msg1).unwrap();
|
||||||
|
let (msg3, mut client_chan) = init.finish(&msg2).unwrap();
|
||||||
|
let mut server_chan = resp.finish(&msg3).unwrap();
|
||||||
|
|
||||||
|
// 1. Normal message seals and opens
|
||||||
|
let frames = client_chan.seal(b"hello world").unwrap();
|
||||||
|
assert_eq!(frames.len(), 1);
|
||||||
|
let opened = server_chan.open_frame(&frames[0]).unwrap().unwrap();
|
||||||
|
assert_eq!(opened, b"hello world");
|
||||||
|
|
||||||
|
// 2. Corrupted ciphertext ends/fails without panicking
|
||||||
|
let mut corrupted = frames[0].clone();
|
||||||
|
corrupted[10] ^= 0xFF;
|
||||||
|
assert!(server_chan.open_frame(&corrupted).is_err());
|
||||||
|
|
||||||
|
// 3. Truncated frame (< 17 bytes)
|
||||||
|
assert!(server_chan.open_frame(&[0u8; 16]).is_err());
|
||||||
|
|
||||||
|
// 4. Oversized frame (> CHUNK + 17)
|
||||||
|
let giant_frame = vec![0u8; CHUNK + 18];
|
||||||
|
assert!(server_chan.open_frame(&giant_frame).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_relay_protocol_adversarial() {
|
||||||
|
let key = SigningKey::from_bytes(&[42u8; 32]);
|
||||||
|
let realm_id = RealmId::new();
|
||||||
|
let nonce = "challenge_nonce_12345";
|
||||||
|
|
||||||
|
let sig = sign_relay_challenge(&key, &realm_id, nonce);
|
||||||
|
assert!(verify_relay_challenge(
|
||||||
|
&key.verifying_key(),
|
||||||
|
&realm_id,
|
||||||
|
nonce,
|
||||||
|
&sig
|
||||||
|
));
|
||||||
|
|
||||||
|
// Tampered nonce
|
||||||
|
assert!(!verify_relay_challenge(
|
||||||
|
&key.verifying_key(),
|
||||||
|
&realm_id,
|
||||||
|
"different_nonce",
|
||||||
|
&sig
|
||||||
|
));
|
||||||
|
// Tampered realm_id
|
||||||
|
assert!(!verify_relay_challenge(
|
||||||
|
&key.verifying_key(),
|
||||||
|
&RealmId::new(),
|
||||||
|
nonce,
|
||||||
|
&sig
|
||||||
|
));
|
||||||
|
// Corrupted signature
|
||||||
|
assert!(!verify_relay_challenge(
|
||||||
|
&key.verifying_key(),
|
||||||
|
&realm_id,
|
||||||
|
nonce,
|
||||||
|
"not_valid_hex"
|
||||||
|
));
|
||||||
|
|
||||||
|
// TunnelMsg unknown fields rejected
|
||||||
|
let bad_tunnel = r#"{"cmd":"close","stream_id":1,"extra":true}"#;
|
||||||
|
assert!(serde_json::from_str::<TunnelMsg>(bad_tunnel).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_fuzz_smoke_never_panics_on_arbitrary_bytes() {
|
||||||
|
// Deterministic pseudo-random bytes
|
||||||
|
let mut seed: u64 = 0xDEADBEEFCAFEBABE;
|
||||||
|
let mut next_bytes = |len: usize| -> Vec<u8> {
|
||||||
|
let mut v = Vec::with_capacity(len);
|
||||||
|
for _ in 0..len {
|
||||||
|
seed = seed.wrapping_mul(6364136223846793005).wrapping_add(1);
|
||||||
|
v.push((seed >> 33) as u8);
|
||||||
|
}
|
||||||
|
v
|
||||||
|
};
|
||||||
|
|
||||||
|
for len in [0, 1, 2, 3, 4, 8, 16, 32, 64, 128, 256, 1024, 4096] {
|
||||||
|
for _ in 0..50 {
|
||||||
|
let sample = next_bytes(len);
|
||||||
|
// Must not panic on any random input:
|
||||||
|
let _ = decode_request(&sample);
|
||||||
|
let _ = decode_response(&sample);
|
||||||
|
let _ = split_binary(&sample);
|
||||||
|
let _ = rewrite_realm_list_address(&sample, "127.0.0.1:8085");
|
||||||
|
if let Ok(s) = std::str::from_utf8(&sample) {
|
||||||
|
let _ = parse_text(s);
|
||||||
|
let _ = serde_json::from_str::<TunnelMsg>(s);
|
||||||
|
let _ = serde_json::from_str::<Frame>(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn make_valid_realm_list_pkt(addr: &str) -> Vec<u8> {
|
||||||
|
let name = b"CoA Realm\0";
|
||||||
|
let addr_bytes = format!("{addr}\0").into_bytes();
|
||||||
|
let body_len = 4 + 2 + 3 + name.len() + addr_bytes.len() + 4 + 1 + 1 + 1 + 2;
|
||||||
|
|
||||||
|
let mut pkt = Vec::new();
|
||||||
|
pkt.push(0x10); // Opcode
|
||||||
|
pkt.extend_from_slice(&(body_len as u16).to_le_bytes()); // Length
|
||||||
|
pkt.extend_from_slice(&0u32.to_le_bytes()); // Unused
|
||||||
|
pkt.extend_from_slice(&1u16.to_le_bytes()); // Realm count = 1
|
||||||
|
|
||||||
|
// Realm info:
|
||||||
|
pkt.extend_from_slice(&[1, 0, 0]); // type, lock, flag
|
||||||
|
pkt.extend_from_slice(name);
|
||||||
|
pkt.extend_from_slice(&addr_bytes);
|
||||||
|
pkt.extend_from_slice(&[0, 0, 0, 0]); // pop
|
||||||
|
pkt.extend_from_slice(&[0]); // chars
|
||||||
|
pkt.extend_from_slice(&[1]); // timezone
|
||||||
|
pkt.extend_from_slice(&[1]); // realm id
|
||||||
|
|
||||||
|
// Footer:
|
||||||
|
pkt.extend_from_slice(&[0x10, 0x00]);
|
||||||
|
pkt
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ serde_json = "1"
|
|||||||
sha2 = "0.10"
|
sha2 = "0.10"
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
thiserror = "2"
|
thiserror = "2"
|
||||||
uuid = { version = "1", features = ["v4", "serde"] }
|
uuid = { version = "1", features = ["v4", "v7", "serde"] }
|
||||||
chrono = { version = "0.4", default-features = false, features = ["clock", "serde", "std"] }
|
chrono = { version = "0.4", default-features = false, features = ["clock", "serde", "std"] }
|
||||||
dunce = "1"
|
dunce = "1"
|
||||||
fs4 = "0.13"
|
fs4 = "0.13"
|
||||||
@@ -22,17 +22,22 @@ reqwest = { version = "0.12", default-features = false, features = ["blocking",
|
|||||||
tar = "0.4"
|
tar = "0.4"
|
||||||
num-bigint = "0.4"
|
num-bigint = "0.4"
|
||||||
zip = { version = "2", default-features = false, features = ["deflate"] }
|
zip = { version = "2", default-features = false, features = ["deflate"] }
|
||||||
|
flate2 = "1.0"
|
||||||
sha1 = "0.10"
|
sha1 = "0.10"
|
||||||
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "std"] }
|
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "std"] }
|
||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
|
rusqlite = { version = "0.40.2", features = ["bundled"] }
|
||||||
if-addrs = "0.15"
|
if-addrs = "0.15"
|
||||||
|
coa-registry-proto = { path = "../coa-registry-proto" }
|
||||||
|
coa-control-proto = { path = "../coa-control-proto" }
|
||||||
|
tungstenite = { version = "0.26", default-features = false, features = ["handshake", "native-tls"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand_core = { version = "0.6", features = ["getrandom"] }
|
rand_core = { version = "0.6", features = ["getrandom"] }
|
||||||
ed25519-dalek = { version = "2", features = ["rand_core"] }
|
ed25519-dalek = { version = "2", features = ["rand_core"] }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
windows-sys = { version = "0.60", features = ["Win32_Foundation", "Win32_Storage_FileSystem", "Win32_System_Threading", "Win32_System_SystemInformation", "Win32_System_Diagnostics_ToolHelp", "Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock"] }
|
windows-sys = { version = "0.60", features = ["Win32_Foundation", "Win32_Storage_FileSystem", "Win32_System_Threading", "Win32_System_SystemInformation", "Win32_System_Diagnostics_ToolHelp", "Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock", "Win32_Security_Cryptography", "Win32_UI_Shell", "Win32_System_Registry", "Win32_UI_WindowsAndMessaging"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
testkit = []
|
testkit = []
|
||||||
@@ -3,15 +3,37 @@ use coa_core::backup::{self, Kind, Trigger};
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let root = std::env::args().nth(1).expect("usage: backup_e2e <fixture folder>");
|
let root = std::env::args()
|
||||||
assert!(root.to_lowercase().contains("fixture"), "refusing: not a fixture folder");
|
.nth(1)
|
||||||
|
.expect("usage: backup_e2e <fixture folder>");
|
||||||
|
assert!(
|
||||||
|
root.to_lowercase().contains("fixture"),
|
||||||
|
"refusing: not a fixture folder"
|
||||||
|
);
|
||||||
let root = Path::new(&root);
|
let root = Path::new(&root);
|
||||||
let meta = coa_core::registry::metadata_dir_for(root).unwrap();
|
let meta = coa_core::registry::metadata_dir_for(root).unwrap();
|
||||||
std::fs::create_dir_all(&meta).unwrap();
|
std::fs::create_dir_all(&meta).unwrap();
|
||||||
|
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
let point = backup::create(root, &meta, Kind::Quick, Trigger::Manual, Some("e2e".into()), &|s| println!(" .. {s}")).expect("backup");
|
let point = backup::create(
|
||||||
println!("quick backup {} in {:?}: {:?}", point.id, t.elapsed(), point.components.iter().map(|c| (&c.name, c.bytes, c.tables)).collect::<Vec<_>>());
|
root,
|
||||||
|
&meta,
|
||||||
|
Kind::Quick,
|
||||||
|
Trigger::Manual,
|
||||||
|
Some("e2e".into()),
|
||||||
|
&|s| println!(" .. {s}"),
|
||||||
|
)
|
||||||
|
.expect("backup");
|
||||||
|
println!(
|
||||||
|
"quick backup {} in {:?}: {:?}",
|
||||||
|
point.id,
|
||||||
|
t.elapsed(),
|
||||||
|
point
|
||||||
|
.components
|
||||||
|
.iter()
|
||||||
|
.map(|c| (&c.name, c.bytes, c.tables))
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
);
|
||||||
assert!(backup::verify(&meta, &point.id).unwrap().ok);
|
assert!(backup::verify(&meta, &point.id).unwrap().ok);
|
||||||
|
|
||||||
// Change live state after the backup.
|
// Change live state after the backup.
|
||||||
@@ -23,22 +45,44 @@ fn main() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let r = backup::restore_database(root, &meta, &point.id, "characters").expect("restore");
|
let r = backup::restore_database(root, &meta, &point.id, "characters").expect("restore");
|
||||||
println!("restored {} tables; previous database kept as {}; safety backup {}", r.tables_restored, r.previous_schema, r.safety_backup);
|
println!(
|
||||||
|
"restored {} tables; previous database kept as {}; safety backup {}",
|
||||||
|
r.tables_restored, r.previous_schema, r.safety_backup
|
||||||
|
);
|
||||||
|
|
||||||
backup::with_database(root, |db| {
|
backup::with_database(root, |db| {
|
||||||
let live = db.tables("acore_characters")?;
|
let live = db.tables("acore_characters")?;
|
||||||
assert!(!live.contains(&"manager_marker".to_string()), "marker must be gone from the restored database");
|
assert!(
|
||||||
|
!live.contains(&"manager_marker".to_string()),
|
||||||
|
"marker must be gone from the restored database"
|
||||||
|
);
|
||||||
let old = db.tables(&r.previous_schema)?;
|
let old = db.tables(&r.previous_schema)?;
|
||||||
assert!(old.contains(&"manager_marker".to_string()), "the replaced database keeps the marker");
|
assert!(
|
||||||
assert_eq!(db.query(&format!("SELECT id FROM {}.manager_marker;", r.previous_schema))?, "42");
|
old.contains(&"manager_marker".to_string()),
|
||||||
|
"the replaced database keeps the marker"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
db.query(&format!(
|
||||||
|
"SELECT id FROM {}.manager_marker;",
|
||||||
|
r.previous_schema
|
||||||
|
))?,
|
||||||
|
"42"
|
||||||
|
);
|
||||||
assert_eq!(live.len(), r.tables_restored);
|
assert_eq!(live.len(), r.tables_restored);
|
||||||
println!("OK: live tables {}, old schema tables {}", live.len(), old.len());
|
println!(
|
||||||
|
"OK: live tables {}, old schema tables {}",
|
||||||
|
live.len(),
|
||||||
|
old.len()
|
||||||
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// A rejected restore (server "running" is simulated by a damaged backup) must change nothing.
|
// A rejected restore (server "running" is simulated by a damaged backup) must change nothing.
|
||||||
let victim = meta.join("backups").join(&point.id).join("characters.sql.zst");
|
let victim = meta
|
||||||
|
.join("backups")
|
||||||
|
.join(&point.id)
|
||||||
|
.join("characters.sql.zst");
|
||||||
let mut bytes = std::fs::read(&victim).unwrap();
|
let mut bytes = std::fs::read(&victim).unwrap();
|
||||||
bytes[10] ^= 0xFF;
|
bytes[10] ^= 0xFF;
|
||||||
std::fs::write(&victim, bytes).unwrap();
|
std::fs::write(&victim, bytes).unwrap();
|
||||||
|
|||||||
@@ -7,25 +7,69 @@ use coa_core::download::{Cancel, HttpTransport};
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let full = clientdl::fetch_latest().expect("manifest");
|
let full = clientdl::fetch_latest().expect("manifest");
|
||||||
println!("version {} · {} files · {:.1} GB", full.version, full.files.len(), full.total_bytes() as f64 / 1e9);
|
println!(
|
||||||
|
"version {} · {} files · {:.1} GB",
|
||||||
|
full.version,
|
||||||
|
full.files.len(),
|
||||||
|
full.total_bytes() as f64 / 1e9
|
||||||
|
);
|
||||||
let mut small = full.files.clone();
|
let mut small = full.files.clone();
|
||||||
small.sort_by_key(|f| f.size);
|
small.sort_by_key(|f| f.size);
|
||||||
let skip: usize = std::env::var("PROBE_SKIP").ok().and_then(|v| v.parse().ok()).unwrap_or(0);
|
let skip: usize = std::env::var("PROBE_SKIP")
|
||||||
|
.ok()
|
||||||
|
.and_then(|v| v.parse().ok())
|
||||||
|
.unwrap_or(0);
|
||||||
let small: Vec<_> = small.into_iter().skip(skip).take(6).collect();
|
let small: Vec<_> = small.into_iter().skip(skip).take(6).collect();
|
||||||
let manifest = Manifest { version: full.version.clone(), published_at: None, files: small };
|
let manifest = Manifest {
|
||||||
|
version: full.version.clone(),
|
||||||
|
published_at: None,
|
||||||
|
files: small,
|
||||||
|
};
|
||||||
|
|
||||||
let dir = std::env::temp_dir().join(format!("coa-client-probe-{}", std::process::id()));
|
let dir = std::env::temp_dir().join(format!("coa-client-probe-{}", std::process::id()));
|
||||||
std::fs::create_dir_all(&dir).unwrap();
|
std::fs::create_dir_all(&dir).unwrap();
|
||||||
let cancel = Cancel::default();
|
let cancel = Cancel::default();
|
||||||
let plan = clientdl::plan(&dir, &manifest, &Default::default(), &cancel, &|_| {}).unwrap();
|
let plan = clientdl::plan(&dir, &manifest, &Default::default(), &cancel, &|_| {}).unwrap();
|
||||||
println!("plan: {} files, {} bytes", plan.items.len(), plan.download_bytes);
|
println!(
|
||||||
|
"plan: {} files, {} bytes",
|
||||||
|
plan.items.len(),
|
||||||
|
plan.download_bytes
|
||||||
|
);
|
||||||
let transport = HttpTransport::new().unwrap();
|
let transport = HttpTransport::new().unwrap();
|
||||||
clientdl::apply(
|
clientdl::apply(
|
||||||
&Apply { client: &dir, manifest: &manifest, plan: &plan, keep_modified: false, transport: &transport, objects_url: clientdl::OBJECTS_URL, cancel: &cancel },
|
&Apply {
|
||||||
&|s| println!("{} {}/{} {}", s.phase, s.done, s.total, s.file.unwrap_or_default()),
|
client: &dir,
|
||||||
|
manifest: &manifest,
|
||||||
|
plan: &plan,
|
||||||
|
keep_modified: false,
|
||||||
|
transport: &transport,
|
||||||
|
objects_url: clientdl::OBJECTS_URL,
|
||||||
|
cancel: &cancel,
|
||||||
|
},
|
||||||
|
&|s| {
|
||||||
|
println!(
|
||||||
|
"{} {}/{} {}",
|
||||||
|
s.phase,
|
||||||
|
s.done,
|
||||||
|
s.total,
|
||||||
|
s.file.unwrap_or_default()
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.expect("apply");
|
.expect("apply");
|
||||||
let again = clientdl::plan(&dir, &manifest, &clientdl::load_state(&dir).unwrap(), &cancel, &|_| {}).unwrap();
|
let again = clientdl::plan(
|
||||||
println!("second plan: {} to do, {} up to date, version {:?}", again.items.len(), again.up_to_date_files, clientdl::local(&dir).version);
|
&dir,
|
||||||
|
&manifest,
|
||||||
|
&clientdl::load_state(&dir).unwrap(),
|
||||||
|
&cancel,
|
||||||
|
&|_| {},
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
println!(
|
||||||
|
"second plan: {} to do, {} up to date, version {:?}",
|
||||||
|
again.items.len(),
|
||||||
|
again.up_to_date_files,
|
||||||
|
clientdl::local(&dir).version
|
||||||
|
);
|
||||||
std::fs::remove_dir_all(&dir).unwrap();
|
std::fs::remove_dir_all(&dir).unwrap();
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let p = std::env::args().nth(1).expect("client folder");
|
let p = std::env::args().nth(1).expect("client folder");
|
||||||
println!("{}", serde_json::to_string_pretty(&coa_core::client::detect(std::path::Path::new(&p), None)).unwrap());
|
println!(
|
||||||
|
"{}",
|
||||||
|
serde_json::to_string_pretty(&coa_core::client::detect(std::path::Path::new(&p), None))
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -5,12 +5,24 @@ use coa_core::db::{Account, Db};
|
|||||||
fn main() {
|
fn main() {
|
||||||
let a: Vec<String> = std::env::args().skip(1).collect();
|
let a: Vec<String> = std::env::args().skip(1).collect();
|
||||||
let root = std::path::PathBuf::from(&a[0]);
|
let root = std::path::PathBuf::from(&a[0]);
|
||||||
assert!(a[0].to_lowercase().contains("installtest"), "refusing to touch a server that is not a disposable test install");
|
assert!(
|
||||||
|
a[0].to_lowercase().contains("installtest"),
|
||||||
|
"refusing to touch a server that is not a disposable test install"
|
||||||
|
);
|
||||||
let count: u32 = a[1].parse().unwrap();
|
let count: u32 = a[1].parse().unwrap();
|
||||||
let db = Db::from_repack(&root, Account::Admin).expect("db");
|
let db = Db::from_repack(&root, Account::Admin).expect("db");
|
||||||
println!("templates before: {}", coa_core::companions::template_count(&db).unwrap());
|
println!(
|
||||||
println!("added: {}", coa_core::companions::ensure_templates(&db).unwrap());
|
"templates before: {}",
|
||||||
println!("templates after: {}", coa_core::companions::template_count(&db).unwrap());
|
coa_core::companions::template_count(&db).unwrap()
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"added: {}",
|
||||||
|
coa_core::companions::ensure_templates(&db).unwrap()
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"templates after: {}",
|
||||||
|
coa_core::companions::template_count(&db).unwrap()
|
||||||
|
);
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
match coa_core::companions::offline_create(&root, &root.join("companions-e2e.log"), count) {
|
match coa_core::companions::offline_create(&root, &root.join("companions-e2e.log"), count) {
|
||||||
Ok(tail) => println!("offline create ok in {:?}:\n{tail}", t.elapsed()),
|
Ok(tail) => println!("offline create ok in {:?}:\n{tail}", t.elapsed()),
|
||||||
|
|||||||
@@ -3,12 +3,16 @@ use coa_core::config::{self, parser::ConfFile, Scope};
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let root = std::env::args().nth(1).expect("usage: config_check <server folder>");
|
let root = std::env::args()
|
||||||
|
.nth(1)
|
||||||
|
.expect("usage: config_check <server folder>");
|
||||||
let root = Path::new(&root);
|
let root = Path::new(&root);
|
||||||
|
|
||||||
let mut files = 0;
|
let mut files = 0;
|
||||||
for dir in ["Core/configs", "Core/configs/modules", "Settings"] {
|
for dir in ["Core/configs", "Core/configs/modules", "Settings"] {
|
||||||
let Ok(rd) = std::fs::read_dir(root.join(dir)) else { continue };
|
let Ok(rd) = std::fs::read_dir(root.join(dir)) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
for e in rd.flatten() {
|
for e in rd.flatten() {
|
||||||
let p = e.path();
|
let p = e.path();
|
||||||
let name = p.file_name().unwrap().to_string_lossy().to_lowercase();
|
let name = p.file_name().unwrap().to_string_lossy().to_lowercase();
|
||||||
@@ -18,7 +22,12 @@ fn main() {
|
|||||||
let bytes = std::fs::read(&p).unwrap();
|
let bytes = std::fs::read(&p).unwrap();
|
||||||
match ConfFile::parse_bytes(&bytes) {
|
match ConfFile::parse_bytes(&bytes) {
|
||||||
Ok(c) => {
|
Ok(c) => {
|
||||||
assert_eq!(c.to_text().as_bytes(), &bytes[..], "round-trip mismatch: {}", p.display());
|
assert_eq!(
|
||||||
|
c.to_text().as_bytes(),
|
||||||
|
&bytes[..],
|
||||||
|
"round-trip mismatch: {}",
|
||||||
|
p.display()
|
||||||
|
);
|
||||||
files += 1;
|
files += 1;
|
||||||
}
|
}
|
||||||
Err(e) => println!("skipped {}: {e}", p.display()),
|
Err(e) => println!("skipped {}: {e}", p.display()),
|
||||||
@@ -31,16 +40,34 @@ fn main() {
|
|||||||
match config::load(root, scope) {
|
match config::load(root, scope) {
|
||||||
Ok(v) => {
|
Ok(v) => {
|
||||||
let present = v.settings.iter().filter(|s| s.present).count();
|
let present = v.settings.iter().filter(|s| s.present).count();
|
||||||
let problems: Vec<_> = v.settings.iter().filter(|s| s.problem.is_some()).map(|s| (&s.meta.key, s.problem.clone().unwrap())).collect();
|
let problems: Vec<_> = v
|
||||||
let missing: Vec<_> = v.settings.iter().filter(|s| !s.present).map(|s| s.meta.key.as_str()).collect();
|
.settings
|
||||||
let non_default = v.settings.iter().filter(|s| s.present && !s.is_default).count();
|
.iter()
|
||||||
|
.filter(|s| s.problem.is_some())
|
||||||
|
.map(|s| (&s.meta.key, s.problem.clone().unwrap()))
|
||||||
|
.collect();
|
||||||
|
let missing: Vec<_> = v
|
||||||
|
.settings
|
||||||
|
.iter()
|
||||||
|
.filter(|s| !s.present)
|
||||||
|
.map(|s| s.meta.key.as_str())
|
||||||
|
.collect();
|
||||||
|
let non_default = v
|
||||||
|
.settings
|
||||||
|
.iter()
|
||||||
|
.filter(|s| s.present && !s.is_default)
|
||||||
|
.count();
|
||||||
println!(
|
println!(
|
||||||
"{scope:?}: {} settings, {present} present, {non_default} non-default, {} unknown keys, drift {:?}\n problems {:?}\n missing {:?}",
|
"{scope:?}: {} settings, {present} present, {non_default} non-default, {} unknown keys, drift {:?}\n problems {:?}\n missing {:?}",
|
||||||
v.settings.len(), v.unknown_keys, v.drift_keys, problems, missing
|
v.settings.len(), v.unknown_keys, v.drift_keys, problems, missing
|
||||||
);
|
);
|
||||||
for p in scope.presets() {
|
for p in scope.presets() {
|
||||||
let pv = config::preview_preset(root, scope, &p.id).unwrap();
|
let pv = config::preview_preset(root, scope, &p.id).unwrap();
|
||||||
println!(" preset {:<14} would change {} settings", p.id, pv.changes.len());
|
println!(
|
||||||
|
" preset {:<14} would change {} settings",
|
||||||
|
p.id,
|
||||||
|
pv.changes.len()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => println!("{scope:?}: {e}"),
|
Err(e) => println!("{scope:?}: {e}"),
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
use coa_core::{
|
||||||
|
manifest::{Kind, Manifest},
|
||||||
|
package::{self, BuildOptions},
|
||||||
|
pkgsource::{self, Source},
|
||||||
|
release, signing, Result,
|
||||||
|
};
|
||||||
use std::{fs, path::PathBuf};
|
use std::{fs, path::PathBuf};
|
||||||
use coa_core::{manifest::{Kind, Manifest}, package::{self, BuildOptions}, pkgsource::{self, Source}, release, signing, Result};
|
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||||
@@ -9,30 +14,61 @@ fn main() -> Result<()> {
|
|||||||
if args[0] == "extract" {
|
if args[0] == "extract" {
|
||||||
assert!(!tree.exists(), "Use a new release tree");
|
assert!(!tree.exists(), "Use a new release tree");
|
||||||
package::extract(&PathBuf::from(&args[1]), &previous, &tree, &|_, _| {})?;
|
package::extract(&PathBuf::from(&args[1]), &previous, &tree, &|_, _| {})?;
|
||||||
println!("Verified and extracted {}: {} historical migrations", previous.version, previous.migrations.len());
|
println!(
|
||||||
|
"Verified and extracted {}: {} historical migrations",
|
||||||
|
previous.version,
|
||||||
|
previous.migrations.len()
|
||||||
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
assert_eq!(args[0], "pack");
|
assert_eq!(args[0], "pack");
|
||||||
let out = PathBuf::from(&args[3]);
|
let out = PathBuf::from(&args[3]);
|
||||||
assert!(!out.exists(), "Release addresses must be immutable");
|
assert!(!out.exists(), "Release addresses must be immutable");
|
||||||
for migration in &previous.migrations {
|
for migration in &previous.migrations {
|
||||||
let entry = previous.files.iter().find(|file| file.path.starts_with("_migrations/") && file.sha256 == migration.sha256).expect("Historical SQL entry");
|
let entry = previous
|
||||||
assert_eq!(coa_core::fsx::sha256_file(&tree.join(&entry.path))?, entry.sha256, "Historical SQL changed: {}", migration.id);
|
.files
|
||||||
|
.iter()
|
||||||
|
.find(|file| file.path.starts_with("_migrations/") && file.sha256 == migration.sha256)
|
||||||
|
.expect("Historical SQL entry");
|
||||||
|
assert_eq!(
|
||||||
|
coa_core::fsx::sha256_file(&tree.join(&entry.path))?,
|
||||||
|
entry.sha256,
|
||||||
|
"Historical SQL changed: {}",
|
||||||
|
migration.id
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let mut manifest = package::build(&tree, &out, &BuildOptions {
|
let mut manifest = package::build(
|
||||||
kind: Kind::Update, version: args[4].clone(), core_commit: Some(args[5].clone()),
|
&tree,
|
||||||
bots_commit: previous.bots.and_then(|revision| revision.commit),
|
&out,
|
||||||
built_at: chrono::Utc::now().to_rfc3339(), part_size: package::DEFAULT_PART_SIZE,
|
&BuildOptions {
|
||||||
migrations: previous.migrations.clone(),
|
kind: Kind::Update,
|
||||||
}, &|line| println!("{line}"))?;
|
version: args[4].clone(),
|
||||||
|
core_commit: Some(args[5].clone()),
|
||||||
|
bots_commit: previous.bots.and_then(|revision| revision.commit),
|
||||||
|
built_at: chrono::Utc::now().to_rfc3339(),
|
||||||
|
part_size: package::DEFAULT_PART_SIZE,
|
||||||
|
migrations: previous.migrations.clone(),
|
||||||
|
},
|
||||||
|
&|line| println!("{line}"),
|
||||||
|
)?;
|
||||||
manifest.min_manager_version = "0.6.5".into();
|
manifest.min_manager_version = "0.6.5".into();
|
||||||
manifest.validate()?;
|
manifest.validate()?;
|
||||||
coa_core::fsx::atomic_write(&out.join("manifest.json"), &serde_json::to_vec_pretty(&manifest)?)?;
|
coa_core::fsx::atomic_write(
|
||||||
let key_path = PathBuf::from(std::env::var("USERPROFILE").unwrap()).join(".coa-manager/signing/manifest-signing.key");
|
&out.join("manifest.json"),
|
||||||
|
&serde_json::to_vec_pretty(&manifest)?,
|
||||||
|
)?;
|
||||||
|
let key_path = PathBuf::from(std::env::var("USERPROFILE").unwrap())
|
||||||
|
.join(".coa-manager/signing/manifest-signing.key");
|
||||||
release::sign_manifest(&out, &fs::read_to_string(key_path)?)?;
|
release::sign_manifest(&out, &fs::read_to_string(key_path)?)?;
|
||||||
coa_core::release_schema::verify_package(&out, signing::EMBEDDED_PUBLIC_KEY)?;
|
coa_core::release_schema::verify_package(&out, signing::EMBEDDED_PUBLIC_KEY)?;
|
||||||
let reread: Manifest = serde_json::from_slice(&fs::read(out.join("manifest.json"))?)?;
|
let reread: Manifest = serde_json::from_slice(&fs::read(out.join("manifest.json"))?)?;
|
||||||
assert_eq!(serde_json::to_value(reread.migrations)?, serde_json::to_value(previous.migrations)?);
|
assert_eq!(
|
||||||
println!("PASS: signed {}; all historical migration bytes, checksums, aliases and order preserved", manifest.version);
|
serde_json::to_value(reread.migrations)?,
|
||||||
|
serde_json::to_value(previous.migrations)?
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"PASS: signed {}; all historical migration bytes, checksums, aliases and order preserved",
|
||||||
|
manifest.version
|
||||||
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1,64 +1,131 @@
|
|||||||
use std::path::{Path, PathBuf};
|
|
||||||
use coa_core::{backup, driver, fsx, Result};
|
use coa_core::{backup, driver, fsx, Result};
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
fn set(root: &Path, filename: &str, values: &[(&str, &str)]) -> Result<()> {
|
fn set(root: &Path, filename: &str, values: &[(&str, &str)]) -> Result<()> {
|
||||||
let path = root.join("Core/configs/modules").join(filename);
|
let path = root.join("Core/configs/modules").join(filename);
|
||||||
let mut config = coa_core::config::parser::ConfFile::parse_bytes(&std::fs::read(&path)?)?;
|
let mut config = coa_core::config::parser::ConfFile::parse_bytes(&std::fs::read(&path)?)?;
|
||||||
for (key, value) in values { config.set(key, value, &[]); }
|
for (key, value) in values {
|
||||||
|
config.set(key, value, &[]);
|
||||||
|
}
|
||||||
fsx::atomic_write(&path, config.to_text().as_bytes())
|
fsx::atomic_write(&path, config.to_text().as_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ledgers(root: &Path) -> Result<Vec<String>> {
|
fn ledgers(root: &Path) -> Result<Vec<String>> {
|
||||||
backup::with_database(root, |db| ["acore_playerbots", "acore_world", "acore_characters"].into_iter()
|
backup::with_database(root, |db| {
|
||||||
.map(|schema| db.query(&format!("SELECT path,sha256 FROM `{schema}`.coa_squid_migrations ORDER BY path;"))).collect())
|
["acore_playerbots", "acore_world", "acore_characters"]
|
||||||
|
.into_iter()
|
||||||
|
.map(|schema| {
|
||||||
|
db.query(&format!(
|
||||||
|
"SELECT path,sha256 FROM `{schema}`.coa_squid_migrations ORDER BY path;"
|
||||||
|
))
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exercise(root: &Path) -> Result<()> {
|
fn exercise(root: &Path) -> Result<()> {
|
||||||
let meta = coa_core::registry::metadata_dir_for(root)?;
|
let meta = coa_core::registry::metadata_dir_for(root)?;
|
||||||
let point = backup::create(root, &meta, backup::Kind::Full, backup::Trigger::Manual, Some("Disposable SQUID acceptance".into()), &|stage| println!("{stage}"))?;
|
let point = backup::create(
|
||||||
|
root,
|
||||||
|
&meta,
|
||||||
|
backup::Kind::Full,
|
||||||
|
backup::Trigger::Manual,
|
||||||
|
Some("Disposable SQUID acceptance".into()),
|
||||||
|
&|stage| println!("{stage}"),
|
||||||
|
)?;
|
||||||
assert!(backup::verify(&meta, &point.id)?.ok);
|
assert!(backup::verify(&meta, &point.id)?.ok);
|
||||||
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| -> Result<()> {
|
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| -> Result<()> {
|
||||||
backup::with_database(root, |db| db.query("DROP DATABASE IF EXISTS acore_playerbots;").map(|_| ()))?;
|
backup::with_database(root, |db| {
|
||||||
assert!(driver::run(root, driver::Verb::StartAll)?.ok, "Disabled SQUID must start without its database");
|
db.query("DROP DATABASE IF EXISTS acore_playerbots;")
|
||||||
|
.map(|_| ())
|
||||||
|
})?;
|
||||||
|
assert!(
|
||||||
|
driver::run(root, driver::Verb::StartAll)?.ok,
|
||||||
|
"Disabled SQUID must start without its database"
|
||||||
|
);
|
||||||
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
||||||
coa_core::multiworld::set_enabled(root, false)?;
|
coa_core::multiworld::set_enabled(root, false)?;
|
||||||
coa_core::realms::select(root, coa_core::realms::Mode::Coa)?;
|
coa_core::realms::select(root, coa_core::realms::Mode::Coa)?;
|
||||||
set(root, "mod_coa_playerbots.conf", &[("CoaBots.Enable", "0")])?;
|
set(root, "mod_coa_playerbots.conf", &[("CoaBots.Enable", "0")])?;
|
||||||
set(root, "playerbots.conf", &[("AiPlayerbot.Enabled", "1"), ("AiPlayerbot.RandomBotAutologin", "0"), ("AiPlayerbot.MinRandomBots", "0"), ("AiPlayerbot.MaxRandomBots", "0"), ("AiPlayerbot.RandomBotGuildCount", "0"), ("AiPlayerbot.RandomBotAccountCount", "0")])?;
|
set(
|
||||||
|
root,
|
||||||
|
"playerbots.conf",
|
||||||
|
&[
|
||||||
|
("AiPlayerbot.Enabled", "1"),
|
||||||
|
("AiPlayerbot.RandomBotAutologin", "0"),
|
||||||
|
("AiPlayerbot.MinRandomBots", "0"),
|
||||||
|
("AiPlayerbot.MaxRandomBots", "0"),
|
||||||
|
("AiPlayerbot.RandomBotGuildCount", "0"),
|
||||||
|
("AiPlayerbot.RandomBotAccountCount", "0"),
|
||||||
|
],
|
||||||
|
)?;
|
||||||
let started = driver::run(root, driver::Verb::StartAll)?;
|
let started = driver::run(root, driver::Verb::StartAll)?;
|
||||||
assert!(started.ok, "Fresh SQUID startup: {}", coa_core::diag::redact(&started.output));
|
assert!(
|
||||||
|
started.ok,
|
||||||
|
"Fresh SQUID startup: {}",
|
||||||
|
coa_core::diag::redact(&started.output)
|
||||||
|
);
|
||||||
let before = ledgers(root)?;
|
let before = ledgers(root)?;
|
||||||
assert!(!before[0].is_empty(), "Fresh SQUID history missing");
|
assert!(!before[0].is_empty(), "Fresh SQUID history missing");
|
||||||
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
||||||
let started = driver::run(root, driver::Verb::StartAll)?;
|
let started = driver::run(root, driver::Verb::StartAll)?;
|
||||||
assert!(started.ok, "Repeated SQUID startup: {}", coa_core::diag::redact(&started.output));
|
assert!(
|
||||||
assert_eq!(ledgers(root)?, before, "SQUID replay changed its migration history");
|
started.ok,
|
||||||
|
"Repeated SQUID startup: {}",
|
||||||
|
coa_core::diag::redact(&started.output)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
ledgers(root)?,
|
||||||
|
before,
|
||||||
|
"SQUID replay changed its migration history"
|
||||||
|
);
|
||||||
println!("PASS: SQUID-disabled dual startup without its database; fresh enabled SQUID import and startup; repeated startup preserves all three histories");
|
println!("PASS: SQUID-disabled dual startup without its database; fresh enabled SQUID import and startup; repeated startup preserves all three histories");
|
||||||
Ok(())
|
Ok(())
|
||||||
}));
|
}));
|
||||||
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
||||||
restore(root, &meta, &point)?;
|
restore(root, &meta, &point)?;
|
||||||
result.map_err(|_| coa_core::Error::Invalid("SQUID acceptance failed; disposable databases and configurations restored".into()))?
|
result.map_err(|_| {
|
||||||
|
coa_core::Error::Invalid(
|
||||||
|
"SQUID acceptance failed; disposable databases and configurations restored".into(),
|
||||||
|
)
|
||||||
|
})?
|
||||||
}
|
}
|
||||||
|
|
||||||
fn restore(root: &Path, meta: &Path, point: &backup::RecoveryPoint) -> Result<()> {
|
fn restore(root: &Path, meta: &Path, point: &backup::RecoveryPoint) -> Result<()> {
|
||||||
assert!(backup::verify(meta, &point.id)?.ok);
|
assert!(backup::verify(meta, &point.id)?.ok);
|
||||||
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
||||||
coa_core::realms::select(root, point.realm)?;
|
coa_core::realms::select(root, point.realm)?;
|
||||||
for component in point.components.iter().filter(|component| component.name != "configs") {
|
for component in point
|
||||||
|
.components
|
||||||
|
.iter()
|
||||||
|
.filter(|component| component.name != "configs")
|
||||||
|
{
|
||||||
backup::restore_database(root, meta, &point.id, &component.name)?;
|
backup::restore_database(root, meta, &point.id, &component.name)?;
|
||||||
}
|
}
|
||||||
backup::restore_configs(root, meta, &point.id)?;
|
backup::restore_configs(root, meta, &point.id)?;
|
||||||
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
||||||
println!("PASS: disposable SQUID acceptance databases and original realm configurations restored");
|
println!(
|
||||||
|
"PASS: disposable SQUID acceptance databases and original realm configurations restored"
|
||||||
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let root = PathBuf::from(std::env::args().nth(1).unwrap());
|
let root = PathBuf::from(std::env::args().nth(1).unwrap());
|
||||||
assert!(root.file_name().unwrap().to_string_lossy().starts_with("coa-schema-fixture-chaos-064-transition-"));
|
assert!(root
|
||||||
assert_eq!(std::fs::read(root.join(".transition-fixture"))?, b"disposable published-064 transition fixture");
|
.file_name()
|
||||||
assert!(!root.join("Data").symlink_metadata()?.file_type().is_symlink());
|
.unwrap()
|
||||||
|
.to_string_lossy()
|
||||||
|
.starts_with("coa-schema-fixture-chaos-064-transition-"));
|
||||||
|
assert_eq!(
|
||||||
|
std::fs::read(root.join(".transition-fixture"))?,
|
||||||
|
b"disposable published-064 transition fixture"
|
||||||
|
);
|
||||||
|
assert!(!root
|
||||||
|
.join("Data")
|
||||||
|
.symlink_metadata()?
|
||||||
|
.file_type()
|
||||||
|
.is_symlink());
|
||||||
assert!(driver::run(&root, driver::Verb::StopAll)?.ok);
|
assert!(driver::run(&root, driver::Verb::StopAll)?.ok);
|
||||||
if let Some(id) = std::env::args().nth(2) {
|
if let Some(id) = std::env::args().nth(2) {
|
||||||
let meta = coa_core::registry::metadata_dir_for(&root)?;
|
let meta = coa_core::registry::metadata_dir_for(&root)?;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
use coa_core::{
|
||||||
|
backup, driver,
|
||||||
|
registry::MetaDir,
|
||||||
|
update::{self, RepackEnv},
|
||||||
|
Result,
|
||||||
|
};
|
||||||
use std::{collections::BTreeMap, path::PathBuf};
|
use std::{collections::BTreeMap, path::PathBuf};
|
||||||
use coa_core::{backup, driver, registry::MetaDir, update::{self, RepackEnv}, Result};
|
|
||||||
|
|
||||||
fn players(db: &coa_core::db::Db) -> Result<String> {
|
fn players(db: &coa_core::db::Db) -> Result<String> {
|
||||||
db.query("SELECT CONCAT(id,':',username,':',HEX(salt),':',HEX(verifier)) FROM acore_auth.account WHERE id=900001; SELECT CONCAT(guid,':',account,':',name,':',level,':',money) FROM acore_characters.characters WHERE guid=900001; SELECT CONCAT(guid,':',itemEntry,':',owner_guid,':',enchantments) FROM acore_characters.item_instance WHERE guid=900001; SELECT CONCAT(guid,':',bag,':',slot,':',item) FROM acore_characters.character_inventory WHERE guid=900001;")
|
db.query("SELECT CONCAT(id,':',username,':',HEX(salt),':',HEX(verifier)) FROM acore_auth.account WHERE id=900001; SELECT CONCAT(guid,':',account,':',name,':',level,':',money) FROM acore_characters.characters WHERE guid=900001; SELECT CONCAT(guid,':',itemEntry,':',owner_guid,':',enchantments) FROM acore_characters.item_instance WHERE guid=900001; SELECT CONCAT(guid,':',bag,':',slot,':',item) FROM acore_characters.character_inventory WHERE guid=900001;")
|
||||||
@@ -8,22 +13,73 @@ fn players(db: &coa_core::db::Db) -> Result<String> {
|
|||||||
fn exercise(root: &std::path::Path, package: &str) -> Result<()> {
|
fn exercise(root: &std::path::Path, package: &str) -> Result<()> {
|
||||||
let meta_dir = coa_core::registry::metadata_dir_for(root)?;
|
let meta_dir = coa_core::registry::metadata_dir_for(root)?;
|
||||||
let (_, meta) = MetaDir::open(&meta_dir)?;
|
let (_, meta) = MetaDir::open(&meta_dir)?;
|
||||||
let expected = backup::with_database(root, |db| [coa_core::realms::Mode::Coa, coa_core::realms::Mode::Wildcard].into_iter().map(|mode| players(&db.clone().for_realm(mode))).collect::<Result<Vec<_>>>())?;
|
let expected = backup::with_database(root, |db| {
|
||||||
|
[
|
||||||
|
coa_core::realms::Mode::Coa,
|
||||||
|
coa_core::realms::Mode::Wildcard,
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.map(|mode| players(&db.clone().for_realm(mode)))
|
||||||
|
.collect::<Result<Vec<_>>>()
|
||||||
|
})?;
|
||||||
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
||||||
let source = coa_core::pkgsource::Source::Dir(package.into());
|
let source = coa_core::pkgsource::Source::Dir(package.into());
|
||||||
let preview = update::preview(root, &meta, &source, coa_core::signing::EMBEDDED_PUBLIC_KEY, &BTreeMap::new())?;
|
let preview = update::preview(
|
||||||
assert_eq!(preview.pending_migrations, 0, "Historical SQL must not replay");
|
root,
|
||||||
assert!(!preview.items.iter().any(|item| item.action == update::Action::Conflict), "Unresolved candidate files: {:?}", preview.items);
|
&meta,
|
||||||
let environment = RepackEnv { root, meta_dir: &meta_dir };
|
&source,
|
||||||
let outcome = update::apply(&update::Params {
|
coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
root, meta_dir: &meta_dir, source, trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
&BTreeMap::new(),
|
||||||
resolutions: BTreeMap::new(), cancel: Default::default(), env: &environment, fail_after_ops: None,
|
)?;
|
||||||
}, &|stage, progress| println!("{progress}% {stage}"))?;
|
assert_eq!(
|
||||||
assert_eq!(outcome.txn.state, update::State::Committed, "{:?}", outcome.txn);
|
preview.pending_migrations, 0,
|
||||||
|
"Historical SQL must not replay"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!preview
|
||||||
|
.items
|
||||||
|
.iter()
|
||||||
|
.any(|item| item.action == update::Action::Conflict),
|
||||||
|
"Unresolved candidate files: {:?}",
|
||||||
|
preview.items
|
||||||
|
);
|
||||||
|
let environment = RepackEnv {
|
||||||
|
root,
|
||||||
|
meta_dir: &meta_dir,
|
||||||
|
};
|
||||||
|
let outcome = update::apply(
|
||||||
|
&update::Params {
|
||||||
|
root,
|
||||||
|
meta_dir: &meta_dir,
|
||||||
|
source,
|
||||||
|
trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
|
resolutions: BTreeMap::new(),
|
||||||
|
cancel: Default::default(),
|
||||||
|
env: &environment,
|
||||||
|
fail_after_ops: None,
|
||||||
|
},
|
||||||
|
&|stage, progress| println!("{progress}% {stage}"),
|
||||||
|
)?;
|
||||||
|
assert_eq!(
|
||||||
|
outcome.txn.state,
|
||||||
|
update::State::Committed,
|
||||||
|
"{:?}",
|
||||||
|
outcome.txn
|
||||||
|
);
|
||||||
backup::with_database(root, |db| {
|
backup::with_database(root, |db| {
|
||||||
for (index, mode) in [coa_core::realms::Mode::Coa, coa_core::realms::Mode::Wildcard].into_iter().enumerate() {
|
for (index, mode) in [
|
||||||
|
coa_core::realms::Mode::Coa,
|
||||||
|
coa_core::realms::Mode::Wildcard,
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.enumerate()
|
||||||
|
{
|
||||||
let realm = db.clone().for_realm(mode);
|
let realm = db.clone().for_realm(mode);
|
||||||
assert_eq!(players(&realm)?, expected[index], "Player data changed in {mode:?}");
|
assert_eq!(
|
||||||
|
players(&realm)?,
|
||||||
|
expected[index],
|
||||||
|
"Player data changed in {mode:?}"
|
||||||
|
);
|
||||||
let problems = coa_core::schema_check::check(&realm, root)?;
|
let problems = coa_core::schema_check::check(&realm, root)?;
|
||||||
assert!(problems.is_empty(), "{problems:?}");
|
assert!(problems.is_empty(), "{problems:?}");
|
||||||
}
|
}
|
||||||
@@ -33,9 +89,22 @@ fn exercise(root: &std::path::Path, package: &str) -> Result<()> {
|
|||||||
println!("SQUID metadata: {release:?}");
|
println!("SQUID metadata: {release:?}");
|
||||||
assert_eq!(coa_core::squid::fields(root)?.len(), 40);
|
assert_eq!(coa_core::squid::fields(root)?.len(), 40);
|
||||||
let (_, installed) = MetaDir::open(&meta_dir)?;
|
let (_, installed) = MetaDir::open(&meta_dir)?;
|
||||||
let repeated = update::preview(root, &installed, &coa_core::pkgsource::Source::Dir(package.into()), coa_core::signing::EMBEDDED_PUBLIC_KEY, &BTreeMap::new())?;
|
let repeated = update::preview(
|
||||||
|
root,
|
||||||
|
&installed,
|
||||||
|
&coa_core::pkgsource::Source::Dir(package.into()),
|
||||||
|
coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
|
&BTreeMap::new(),
|
||||||
|
)?;
|
||||||
assert_eq!(repeated.pending_migrations, 0);
|
assert_eq!(repeated.pending_migrations, 0);
|
||||||
assert!(repeated.items.iter().all(|item| item.action == update::Action::Skip), "{:?}", repeated.items);
|
assert!(
|
||||||
|
repeated
|
||||||
|
.items
|
||||||
|
.iter()
|
||||||
|
.all(|item| item.action == update::Action::Skip),
|
||||||
|
"{:?}",
|
||||||
|
repeated.items
|
||||||
|
);
|
||||||
println!("PASS: coordinated update committed, both realms started, player fields preserved, historical SQL skipped, repeated preview clean");
|
println!("PASS: coordinated update committed, both realms started, player fields preserved, historical SQL skipped, repeated preview clean");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -43,12 +112,30 @@ fn exercise(root: &std::path::Path, package: &str) -> Result<()> {
|
|||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||||
let root = PathBuf::from(&args[0]);
|
let root = PathBuf::from(&args[0]);
|
||||||
assert!(root.file_name().unwrap().to_string_lossy().starts_with("coa-schema-fixture-chaos-064-transition-"));
|
assert!(root
|
||||||
assert_eq!(std::fs::read(root.join(".transition-fixture"))?, b"disposable published-064 transition fixture");
|
.file_name()
|
||||||
assert_eq!(std::fs::read(root.join(".release-schema-fixture"))?, b"disposable release-schema fixture");
|
.unwrap()
|
||||||
assert!(!root.join("Data").symlink_metadata()?.file_type().is_symlink());
|
.to_string_lossy()
|
||||||
|
.starts_with("coa-schema-fixture-chaos-064-transition-"));
|
||||||
|
assert_eq!(
|
||||||
|
std::fs::read(root.join(".transition-fixture"))?,
|
||||||
|
b"disposable published-064 transition fixture"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
std::fs::read(root.join(".release-schema-fixture"))?,
|
||||||
|
b"disposable release-schema fixture"
|
||||||
|
);
|
||||||
|
assert!(!root
|
||||||
|
.join("Data")
|
||||||
|
.symlink_metadata()?
|
||||||
|
.file_type()
|
||||||
|
.is_symlink());
|
||||||
assert!(driver::run(&root, driver::Verb::StopAll)?.ok);
|
assert!(driver::run(&root, driver::Verb::StopAll)?.ok);
|
||||||
let outcome = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| exercise(&root, &args[1])));
|
let outcome =
|
||||||
assert!(driver::run(&root, driver::Verb::StopAll)?.ok, "Fixture shutdown failed");
|
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| exercise(&root, &args[1])));
|
||||||
|
assert!(
|
||||||
|
driver::run(&root, driver::Verb::StopAll)?.ok,
|
||||||
|
"Fixture shutdown failed"
|
||||||
|
);
|
||||||
outcome.map_err(|_| coa_core::Error::Invalid("Disposable coordinated acceptance failed; stopped services and retained recovery copies".into()))?
|
outcome.map_err(|_| coa_core::Error::Invalid("Disposable coordinated acceptance failed; stopped services and retained recovery copies".into()))?
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,14 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let a: Vec<String> = std::env::args().skip(1).collect();
|
let a: Vec<String> = std::env::args().skip(1).collect();
|
||||||
let job = coa_core::download::Job { url: a[0].clone(), dest: a[1].clone().into(), sha256: a[2].clone(), size: a[3].parse().unwrap() };
|
let job = coa_core::download::Job {
|
||||||
|
url: a[0].clone(),
|
||||||
|
dest: a[1].clone().into(),
|
||||||
|
sha256: a[2].clone(),
|
||||||
|
size: a[3].parse().unwrap(),
|
||||||
|
};
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
let r = coa_core::download::fetch(&job, &Default::default(), &|p| eprintln!("{}/{}", p.downloaded, p.total));
|
let r = coa_core::download::fetch(&job, &Default::default(), &|p| {
|
||||||
|
eprintln!("{}/{}", p.downloaded, p.total)
|
||||||
|
});
|
||||||
println!("{r:?} in {:?}", t.elapsed());
|
println!("{r:?} in {:?}", t.elapsed());
|
||||||
}
|
}
|
||||||
@@ -9,13 +9,35 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a: Vec<String> = std::env::args().skip(1).collect();
|
let a: Vec<String> = std::env::args().skip(1).collect();
|
||||||
assert!(a.len() == 4, "usage: docker_install <package folder> <destination> <game data folder> <public key>");
|
assert!(
|
||||||
|
a.len() == 4,
|
||||||
|
"usage: docker_install <package folder> <destination> <game data folder> <public key>"
|
||||||
|
);
|
||||||
let registry = Registry::at(std::env::temp_dir().join("coa-docker-install/installs.json"));
|
let registry = Registry::at(std::env::temp_dir().join("coa-docker-install/installs.json"));
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
let done = install(
|
let done = install(
|
||||||
&Params { source: Source::Dir(PathBuf::from(&a[0])), dest: PathBuf::from(&a[1]), data_dir: PathBuf::from(&a[2]), trusted_key: &a[3], registry: ®istry, cancel: Cancel::default() },
|
&Params {
|
||||||
&|s| eprintln!(" {:>3}% {} {}", s.percent, s.step, s.detail.unwrap_or_default()),
|
source: Source::Dir(PathBuf::from(&a[0])),
|
||||||
|
dest: PathBuf::from(&a[1]),
|
||||||
|
data_dir: PathBuf::from(&a[2]),
|
||||||
|
trusted_key: &a[3],
|
||||||
|
registry: ®istry,
|
||||||
|
cancel: Cancel::default(),
|
||||||
|
},
|
||||||
|
&|s| {
|
||||||
|
eprintln!(
|
||||||
|
" {:>3}% {} {}",
|
||||||
|
s.percent,
|
||||||
|
s.step,
|
||||||
|
s.detail.unwrap_or_default()
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| panic!("install failed: {e}"));
|
.unwrap_or_else(|e| panic!("install failed: {e}"));
|
||||||
println!("installed {} at {} in {:?}", done.version, done.path, t.elapsed());
|
println!(
|
||||||
|
"installed {} at {} in {:?}",
|
||||||
|
done.version,
|
||||||
|
done.path,
|
||||||
|
t.elapsed()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,9 @@ use std::path::Path;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut args = std::env::args().skip(1);
|
let mut args = std::env::args().skip(1);
|
||||||
let root = args.next().expect("usage: drive <server folder> <start|stop>");
|
let root = args
|
||||||
|
.next()
|
||||||
|
.expect("usage: drive <server folder> <start|stop>");
|
||||||
let verb = match args.next().as_deref() {
|
let verb = match args.next().as_deref() {
|
||||||
Some("start") => coa_core::driver::Verb::StartAll,
|
Some("start") => coa_core::driver::Verb::StartAll,
|
||||||
Some("mysql") => coa_core::driver::Verb::StartMysql,
|
Some("mysql") => coa_core::driver::Verb::StartMysql,
|
||||||
|
|||||||
@@ -1,11 +1,27 @@
|
|||||||
//! Verify published checksum compatibility on a disposable real database, without running SQL migrations.
|
//! Verify published checksum compatibility on a disposable real database, without running SQL migrations.
|
||||||
use std::{path::{Path, PathBuf}, sync::atomic::{AtomicUsize, Ordering}};
|
use coa_core::{
|
||||||
use coa_core::{backup, db::Db, migrations::{self, LedgerRow, Status, Store}, pkgsource::{self, Source}, Result};
|
backup,
|
||||||
|
db::Db,
|
||||||
|
migrations::{self, LedgerRow, Status, Store},
|
||||||
|
pkgsource::{self, Source},
|
||||||
|
Result,
|
||||||
|
};
|
||||||
|
use std::{
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
sync::atomic::{AtomicUsize, Ordering},
|
||||||
|
};
|
||||||
|
|
||||||
struct Observed<'a> { db: &'a Db, executions: AtomicUsize }
|
struct Observed<'a> {
|
||||||
|
db: &'a Db,
|
||||||
|
executions: AtomicUsize,
|
||||||
|
}
|
||||||
impl Store for Observed<'_> {
|
impl Store for Observed<'_> {
|
||||||
fn load(&self) -> Result<Vec<LedgerRow>> { self.db.load() }
|
fn load(&self) -> Result<Vec<LedgerRow>> {
|
||||||
fn put(&self, row: &LedgerRow) -> Result<()> { self.db.put(row) }
|
self.db.load()
|
||||||
|
}
|
||||||
|
fn put(&self, row: &LedgerRow) -> Result<()> {
|
||||||
|
self.db.put(row)
|
||||||
|
}
|
||||||
fn run_file(&self, _: &str, _: &Path) -> Result<()> {
|
fn run_file(&self, _: &str, _: &Path) -> Result<()> {
|
||||||
self.executions.fetch_add(1, Ordering::SeqCst);
|
self.executions.fetch_add(1, Ordering::SeqCst);
|
||||||
panic!("Historical SQL must never be replayed");
|
panic!("Historical SQL must never be replayed");
|
||||||
@@ -15,62 +31,149 @@ impl Store for Observed<'_> {
|
|||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let args: Vec<_> = std::env::args().skip(1).collect();
|
let args: Vec<_> = std::env::args().skip(1).collect();
|
||||||
let root = PathBuf::from(&args[0]);
|
let root = PathBuf::from(&args[0]);
|
||||||
assert!(root.file_name().unwrap().to_string_lossy().starts_with("coa-schema-fixture-chaos-"));
|
assert!(root
|
||||||
assert_eq!(std::fs::read(root.join(".coa-chaos-fixture"))?, b"disposable update chaos fixture");
|
.file_name()
|
||||||
assert_eq!(std::fs::read(root.join(".release-schema-fixture"))?, b"disposable release-schema fixture");
|
.unwrap()
|
||||||
|
.to_string_lossy()
|
||||||
|
.starts_with("coa-schema-fixture-chaos-"));
|
||||||
|
assert_eq!(
|
||||||
|
std::fs::read(root.join(".coa-chaos-fixture"))?,
|
||||||
|
b"disposable update chaos fixture"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
std::fs::read(root.join(".release-schema-fixture"))?,
|
||||||
|
b"disposable release-schema fixture"
|
||||||
|
);
|
||||||
let source = Source::Dir(PathBuf::from(&args[1]));
|
let source = Source::Dir(PathBuf::from(&args[1]));
|
||||||
let package = pkgsource::fetch_manifest(&source, coa_core::signing::EMBEDDED_PUBLIC_KEY)?.0;
|
let package = pkgsource::fetch_manifest(&source, coa_core::signing::EMBEDDED_PUBLIC_KEY)?.0;
|
||||||
let staging = tempfile::tempdir()?;
|
let staging = tempfile::tempdir()?;
|
||||||
let parts = pkgsource::fetch_parts(&source, &package, &staging.path().join("download"), &Default::default(), &|_, _| {})?;
|
let parts = pkgsource::fetch_parts(
|
||||||
|
&source,
|
||||||
|
&package,
|
||||||
|
&staging.path().join("download"),
|
||||||
|
&Default::default(),
|
||||||
|
&|_, _| {},
|
||||||
|
)?;
|
||||||
coa_core::package::extract(&parts, &package, &staging.path().join("tree"), &|_, _| {})?;
|
coa_core::package::extract(&parts, &package, &staging.path().join("tree"), &|_, _| {})?;
|
||||||
migrations::verify_files(&package.migrations, &staging.path().join("tree/_migrations"))?;
|
migrations::verify_files(
|
||||||
println!("PASS: all {} signed-package SQL artifacts verified before any database mutation", package.migrations.len());
|
&package.migrations,
|
||||||
let migration = package.migrations.iter().find(|m| m.id == "manager_repair__20261005_missing_wildcard_tables").unwrap();
|
&staging.path().join("tree/_migrations"),
|
||||||
let hashes = ["c1d8dbf2271234283a48a39e4b4aea1106b83b70581f1e3c4aa9fff438e8e4d2", "9e4a36245c3f83255415c122c01f08ceb3e3b83898d3d427ac4e2fbcf61e9638"];
|
)?;
|
||||||
for hash in hashes { assert!(migration.sha256 == hash || migration.compatible_sha256.iter().any(|h| h == hash)); }
|
println!(
|
||||||
|
"PASS: all {} signed-package SQL artifacts verified before any database mutation",
|
||||||
|
package.migrations.len()
|
||||||
|
);
|
||||||
|
let migration = package
|
||||||
|
.migrations
|
||||||
|
.iter()
|
||||||
|
.find(|m| m.id == "manager_repair__20261005_missing_wildcard_tables")
|
||||||
|
.unwrap();
|
||||||
|
let hashes = [
|
||||||
|
"c1d8dbf2271234283a48a39e4b4aea1106b83b70581f1e3c4aa9fff438e8e4d2",
|
||||||
|
"9e4a36245c3f83255415c122c01f08ceb3e3b83898d3d427ac4e2fbcf61e9638",
|
||||||
|
];
|
||||||
|
for hash in hashes {
|
||||||
|
assert!(migration.sha256 == hash || migration.compatible_sha256.iter().any(|h| h == hash));
|
||||||
|
}
|
||||||
let fixture_meta = coa_core::registry::metadata_dir_for(&root)?;
|
let fixture_meta = coa_core::registry::metadata_dir_for(&root)?;
|
||||||
let test_meta = tempfile::tempdir()?;
|
let test_meta = tempfile::tempdir()?;
|
||||||
coa_core::fsx::atomic_write(&test_meta.path().join("install.json"), &std::fs::read(fixture_meta.join("install.json"))?)?;
|
coa_core::fsx::atomic_write(
|
||||||
|
&test_meta.path().join("install.json"),
|
||||||
|
&std::fs::read(fixture_meta.join("install.json"))?,
|
||||||
|
)?;
|
||||||
coa_core::registry::MetaDir::open(test_meta.path())?;
|
coa_core::registry::MetaDir::open(test_meta.path())?;
|
||||||
std::fs::create_dir_all(test_meta.path().join("updates"))?;
|
std::fs::create_dir_all(test_meta.path().join("updates"))?;
|
||||||
let result = backup::with_database(&root, |db| {
|
let result = backup::with_database(&root, |db| {
|
||||||
let mut modes = vec![coa_core::realms::Mode::Coa];
|
let mut modes = vec![coa_core::realms::Mode::Coa];
|
||||||
if coa_core::realms::state(&root)?.wildcard_created { modes.push(coa_core::realms::Mode::Wildcard); }
|
if coa_core::realms::state(&root)?.wildcard_created {
|
||||||
|
modes.push(coa_core::realms::Mode::Wildcard);
|
||||||
|
}
|
||||||
for mode in modes {
|
for mode in modes {
|
||||||
let db = db.clone().for_realm(mode);
|
let db = db.clone().for_realm(mode);
|
||||||
let saved = db.load()?.into_iter().find(|row| row.id == migration.id && row.db == migration.db).expect("Published repair must already be applied");
|
let saved = db
|
||||||
|
.load()?
|
||||||
|
.into_iter()
|
||||||
|
.find(|row| row.id == migration.id && row.db == migration.db)
|
||||||
|
.expect("Published repair must already be applied");
|
||||||
assert_eq!(saved.status, Status::Applied);
|
assert_eq!(saved.status, Status::Applied);
|
||||||
let counts = db.query("SELECT CONCAT((SELECT COUNT(*) FROM acore_characters.characters),':',(SELECT COUNT(*) FROM acore_characters.item_instance),':',(SELECT COUNT(*) FROM acore_auth.account));")?;
|
let counts = db.query("SELECT CONCAT((SELECT COUNT(*) FROM acore_characters.characters),':',(SELECT COUNT(*) FROM acore_characters.item_instance),':',(SELECT COUNT(*) FROM acore_auth.account));")?;
|
||||||
let check = || -> Result<()> {
|
let check = || -> Result<()> {
|
||||||
for hash in hashes {
|
for hash in hashes {
|
||||||
db.put(&LedgerRow { sha256: hash.into(), ..saved.clone() })?;
|
db.put(&LedgerRow {
|
||||||
let observed = Observed { db: &db, executions: AtomicUsize::new(0) };
|
sha256: hash.into(),
|
||||||
|
..saved.clone()
|
||||||
|
})?;
|
||||||
|
let observed = Observed {
|
||||||
|
db: &db,
|
||||||
|
executions: AtomicUsize::new(0),
|
||||||
|
};
|
||||||
migrations::preflight(&db, std::slice::from_ref(migration))?;
|
migrations::preflight(&db, std::slice::from_ref(migration))?;
|
||||||
let report = migrations::apply_pending(&observed, std::slice::from_ref(migration), &root.join(".unused-hotfix-sql"), &|| panic!("Already applied SQL needs no snapshot"))?;
|
let report = migrations::apply_pending(
|
||||||
|
&observed,
|
||||||
|
std::slice::from_ref(migration),
|
||||||
|
&root.join(".unused-hotfix-sql"),
|
||||||
|
&|| panic!("Already applied SQL needs no snapshot"),
|
||||||
|
)?;
|
||||||
assert!(report.applied.is_empty());
|
assert!(report.applied.is_empty());
|
||||||
assert_eq!(observed.executions.load(Ordering::SeqCst), 0);
|
assert_eq!(observed.executions.load(Ordering::SeqCst), 0);
|
||||||
assert_eq!(db.load()?.into_iter().find(|r| r.id == migration.id && r.db == migration.db).unwrap().sha256, hash);
|
assert_eq!(
|
||||||
|
db.load()?
|
||||||
|
.into_iter()
|
||||||
|
.find(|r| r.id == migration.id && r.db == migration.db)
|
||||||
|
.unwrap()
|
||||||
|
.sha256,
|
||||||
|
hash
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let meta = test_meta.path();
|
let meta = test_meta.path();
|
||||||
let file_hash = coa_core::fsx::sha256_file(&root.join("Core/worldserver.exe"))?;
|
let file_hash = coa_core::fsx::sha256_file(&root.join("Core/worldserver.exe"))?;
|
||||||
let install_hash = coa_core::fsx::sha256_file(&meta.join("install.json"))?;
|
let install_hash = coa_core::fsx::sha256_file(&meta.join("install.json"))?;
|
||||||
let transaction_count = std::fs::read_dir(meta.join("updates"))?.count();
|
let transaction_count = std::fs::read_dir(meta.join("updates"))?.count();
|
||||||
for status in [Status::Running, Status::Failed] {
|
for status in [Status::Running, Status::Failed] {
|
||||||
db.put(&LedgerRow { status, ..saved.clone() })?;
|
db.put(&LedgerRow {
|
||||||
let env = coa_core::update::RepackEnv { root: &root, meta_dir: meta };
|
status,
|
||||||
let rejected = coa_core::update::apply(&coa_core::update::Params {
|
..saved.clone()
|
||||||
root: &root, meta_dir: meta, source: Source::Dir(PathBuf::from(&args[1])),
|
})?;
|
||||||
trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY, cancel: Default::default(),
|
let env = coa_core::update::RepackEnv {
|
||||||
resolutions: Default::default(), env: &env, fail_after_ops: None,
|
root: &root,
|
||||||
}, &|_, _| {});
|
meta_dir: meta,
|
||||||
|
};
|
||||||
|
let rejected = coa_core::update::apply(
|
||||||
|
&coa_core::update::Params {
|
||||||
|
root: &root,
|
||||||
|
meta_dir: meta,
|
||||||
|
source: Source::Dir(PathBuf::from(&args[1])),
|
||||||
|
trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
|
cancel: Default::default(),
|
||||||
|
resolutions: Default::default(),
|
||||||
|
env: &env,
|
||||||
|
fail_after_ops: None,
|
||||||
|
},
|
||||||
|
&|_, _| {},
|
||||||
|
);
|
||||||
let message = rejected.unwrap_err().to_string();
|
let message = rejected.unwrap_err().to_string();
|
||||||
assert!(message.contains("partially applied"), "Unexpected rejection: {message}");
|
assert!(
|
||||||
assert_eq!(std::fs::read_dir(meta.join("updates"))?.count(), transaction_count);
|
message.contains("partially applied"),
|
||||||
assert_eq!(coa_core::fsx::sha256_file(&root.join("Core/worldserver.exe"))?, file_hash);
|
"Unexpected rejection: {message}"
|
||||||
assert_eq!(coa_core::fsx::sha256_file(&meta.join("install.json"))?, install_hash);
|
);
|
||||||
|
assert_eq!(
|
||||||
|
std::fs::read_dir(meta.join("updates"))?.count(),
|
||||||
|
transaction_count
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
coa_core::fsx::sha256_file(&root.join("Core/worldserver.exe"))?,
|
||||||
|
file_hash
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
coa_core::fsx::sha256_file(&meta.join("install.json"))?,
|
||||||
|
install_hash
|
||||||
|
);
|
||||||
}
|
}
|
||||||
db.put(&saved)?;
|
db.put(&saved)?;
|
||||||
let env = coa_core::update::RepackEnv { root: &root, meta_dir: meta };
|
let env = coa_core::update::RepackEnv {
|
||||||
|
root: &root,
|
||||||
|
meta_dir: meta,
|
||||||
|
};
|
||||||
let pending_before = env.pending_migrations(&package)?;
|
let pending_before = env.pending_migrations(&package)?;
|
||||||
db.query("DELETE FROM acore_world.coa_manager_migrations WHERE db='characters' AND id='manager_repair__20261005_missing_wildcard_tables';")?;
|
db.query("DELETE FROM acore_world.coa_manager_migrations WHERE db='characters' AND id='manager_repair__20261005_missing_wildcard_tables';")?;
|
||||||
assert_eq!(env.pending_migrations(&package)?, pending_before + 1,
|
assert_eq!(env.pending_migrations(&package)?, pending_before + 1,
|
||||||
@@ -81,7 +184,12 @@ fn main() -> Result<()> {
|
|||||||
};
|
};
|
||||||
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(check));
|
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(check));
|
||||||
db.put(&saved)?;
|
db.put(&saved)?;
|
||||||
result.map_err(|_| coa_core::Error::Invalid("History regression assertion failed; the injected ledger row was restored.".into()))??;
|
result.map_err(|_| {
|
||||||
|
coa_core::Error::Invalid(
|
||||||
|
"History regression assertion failed; the injected ledger row was restored."
|
||||||
|
.into(),
|
||||||
|
)
|
||||||
|
})??;
|
||||||
assert_eq!(db.query("SELECT CONCAT((SELECT COUNT(*) FROM acore_characters.characters),':',(SELECT COUNT(*) FROM acore_characters.item_instance),':',(SELECT COUNT(*) FROM acore_auth.account));")?, counts);
|
assert_eq!(db.query("SELECT CONCAT((SELECT COUNT(*) FROM acore_characters.characters),':',(SELECT COUNT(*) FROM acore_characters.item_instance),':',(SELECT COUNT(*) FROM acore_auth.account));")?, counts);
|
||||||
println!("PASS: {} published checksums; Running/Failed rejected before staging; missing migration counted; zero SQL replays; history and player counts preserved", mode.name());
|
println!("PASS: {} published checksums; Running/Failed rejected before staging; missing migration counted; zero SQL replays; history and player counts preserved", mode.name());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,43 @@
|
|||||||
//! Read-only update preview against the marked disposable acceptance fixture.
|
//! Read-only update preview against the marked disposable acceptance fixture.
|
||||||
use std::{collections::BTreeMap,path::PathBuf};
|
use std::{collections::BTreeMap, path::PathBuf};
|
||||||
fn main()->coa_core::Result<()> {
|
fn main() -> coa_core::Result<()> {
|
||||||
let args:Vec<_>=std::env::args().skip(1).collect();
|
let args: Vec<_> = std::env::args().skip(1).collect();
|
||||||
let root=PathBuf::from(&args[0]);
|
let root = PathBuf::from(&args[0]);
|
||||||
assert!(root.file_name().unwrap().to_string_lossy().starts_with("coa-schema-fixture-chaos-064-transition-"));
|
assert!(root
|
||||||
assert_eq!(std::fs::read(root.join(".transition-fixture"))?,b"disposable published-064 transition fixture");
|
.file_name()
|
||||||
let meta_dir=coa_core::registry::metadata_dir_for(&root)?;
|
.unwrap()
|
||||||
let (_,meta)=coa_core::registry::MetaDir::open(&meta_dir)?;
|
.to_string_lossy()
|
||||||
let preview=coa_core::update::preview(&root,&meta,&coa_core::pkgsource::Source::Dir(args[1].clone().into()),coa_core::signing::EMBEDDED_PUBLIC_KEY,&BTreeMap::new())?;
|
.starts_with("coa-schema-fixture-chaos-064-transition-"));
|
||||||
assert_eq!(preview.from_version.as_deref(),Some(preview.to_version.as_str()));
|
assert_eq!(
|
||||||
assert_eq!(preview.pending_migrations,0);
|
std::fs::read(root.join(".transition-fixture"))?,
|
||||||
assert!(preview.items.iter().all(|item|item.action==coa_core::update::Action::Skip),"{:?}",preview.items.iter().filter(|item|item.action!=coa_core::update::Action::Skip).collect::<Vec<_>>());
|
b"disposable published-064 transition fixture"
|
||||||
|
);
|
||||||
|
let meta_dir = coa_core::registry::metadata_dir_for(&root)?;
|
||||||
|
let (_, meta) = coa_core::registry::MetaDir::open(&meta_dir)?;
|
||||||
|
let preview = coa_core::update::preview(
|
||||||
|
&root,
|
||||||
|
&meta,
|
||||||
|
&coa_core::pkgsource::Source::Dir(args[1].clone().into()),
|
||||||
|
coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
|
&BTreeMap::new(),
|
||||||
|
)?;
|
||||||
|
assert_eq!(
|
||||||
|
preview.from_version.as_deref(),
|
||||||
|
Some(preview.to_version.as_str())
|
||||||
|
);
|
||||||
|
assert_eq!(preview.pending_migrations, 0);
|
||||||
|
assert!(
|
||||||
|
preview
|
||||||
|
.items
|
||||||
|
.iter()
|
||||||
|
.all(|item| item.action == coa_core::update::Action::Skip),
|
||||||
|
"{:?}",
|
||||||
|
preview
|
||||||
|
.items
|
||||||
|
.iter()
|
||||||
|
.filter(|item| item.action != coa_core::update::Action::Skip)
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
);
|
||||||
println!("PASS: real fixture repeated preview: {} files unchanged, zero pending SQL, no update offered",preview.items.len());
|
println!("PASS: real fixture repeated preview: {} files unchanged, zero pending SQL, no update offered",preview.items.len());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,48 @@
|
|||||||
//! Real signed-package transition on an independent, explicitly marked disposable copy.
|
//! Real signed-package transition on an independent, explicitly marked disposable copy.
|
||||||
//! The Env wrapper instruments only launcher isolation; migration/backup/update code is production code.
|
//! The Env wrapper instruments only launcher isolation; migration/backup/update code is production code.
|
||||||
use std::{collections::BTreeMap, path::{Path, PathBuf}};
|
use coa_core::{
|
||||||
use coa_core::{backup, driver, fsx, migrations, pkgsource::{self, Source}, registry::{InstallMeta, MetaDir}, update::{self, Env, RepackEnv}, Result};
|
backup, driver, fsx, migrations,
|
||||||
|
pkgsource::{self, Source},
|
||||||
|
registry::{InstallMeta, MetaDir},
|
||||||
|
update::{self, Env, RepackEnv},
|
||||||
|
Result,
|
||||||
|
};
|
||||||
|
use std::{
|
||||||
|
collections::BTreeMap,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
struct Offline<'a>(RepackEnv<'a>);
|
struct Offline<'a>(RepackEnv<'a>);
|
||||||
impl Env for Offline<'_> {
|
impl Env for Offline<'_> {
|
||||||
fn ensure_stopped(&self) -> Result<()> { self.0.ensure_stopped() }
|
fn ensure_stopped(&self) -> Result<()> {
|
||||||
fn preflight(&self, m: &coa_core::manifest::Manifest) -> Result<()> { self.0.preflight(m) }
|
self.0.ensure_stopped()
|
||||||
fn verify_snapshot(&self, id: &str) -> Result<()> { self.0.verify_snapshot(id) }
|
}
|
||||||
fn snapshot(&self) -> Result<String> { self.0.snapshot() }
|
fn preflight(&self, m: &coa_core::manifest::Manifest) -> Result<()> {
|
||||||
fn restore_snapshot(&self, id: &str) -> Result<()> { self.0.restore_snapshot(id) }
|
self.0.preflight(m)
|
||||||
fn migrate(&self, m: &coa_core::manifest::Manifest, p: &Path) -> Result<migrations::ApplyReport> { self.0.migrate(m,p) }
|
}
|
||||||
|
fn verify_snapshot(&self, id: &str) -> Result<()> {
|
||||||
|
self.0.verify_snapshot(id)
|
||||||
|
}
|
||||||
|
fn snapshot(&self) -> Result<String> {
|
||||||
|
self.0.snapshot()
|
||||||
|
}
|
||||||
|
fn restore_snapshot(&self, id: &str) -> Result<()> {
|
||||||
|
self.0.restore_snapshot(id)
|
||||||
|
}
|
||||||
|
fn migrate(
|
||||||
|
&self,
|
||||||
|
m: &coa_core::manifest::Manifest,
|
||||||
|
p: &Path,
|
||||||
|
) -> Result<migrations::ApplyReport> {
|
||||||
|
self.0.migrate(m, p)
|
||||||
|
}
|
||||||
fn validate(&self) -> Result<()> {
|
fn validate(&self) -> Result<()> {
|
||||||
let path=self.0.root.join("Scripts/manage.py");
|
let path = self.0.root.join("Scripts/manage.py");
|
||||||
let source=std::fs::read_to_string(&path)?.replace("\r\n", "\n");
|
let source = std::fs::read_to_string(&path)?.replace("\r\n", "\n");
|
||||||
// Explicit test instrumentation prevents relay transmissions and binds services locally.
|
// Explicit test instrumentation prevents relay transmissions and binds services locally.
|
||||||
let guarded=source.replace("def spawn(name, command, cwd, log):\n", "def spawn(name, command, cwd, log):\n for filename in ('worldserver.conf', 'authserver.conf'):\n path = ROOT / 'Core/configs' / filename\n if path.exists():\n text = path.read_text(encoding='utf-8-sig')\n for key, value in (('BindIP', '\"127.0.0.1\"'), ('Ra.IP', '\"127.0.0.1\"'), ('SOAP.Enabled', '0')):\n text = re.sub(r'(?m)^\\s*' + re.escape(key) + r'\\s*=.*$', '', text)\n text += '\\n' + key + ' = ' + value + '\\n'\n path.write_text(text, encoding='utf-8')\n").replace("def relay_worker():\n", "def relay_worker():\n save_process('relay-ready', os.getpid())\n while not (STATE / 'stop-relay').exists():\n time.sleep(0.5)\n return\n");
|
let guarded=source.replace("def spawn(name, command, cwd, log):\n", "def spawn(name, command, cwd, log):\n for filename in ('worldserver.conf', 'authserver.conf'):\n path = ROOT / 'Core/configs' / filename\n if path.exists():\n text = path.read_text(encoding='utf-8-sig')\n for key, value in (('BindIP', '\"127.0.0.1\"'), ('Ra.IP', '\"127.0.0.1\"'), ('SOAP.Enabled', '0')):\n text = re.sub(r'(?m)^\\s*' + re.escape(key) + r'\\s*=.*$', '', text)\n text += '\\n' + key + ' = ' + value + '\\n'\n path.write_text(text, encoding='utf-8')\n").replace("def relay_worker():\n", "def relay_worker():\n save_process('relay-ready', os.getpid())\n while not (STATE / 'stop-relay').exists():\n time.sleep(0.5)\n return\n");
|
||||||
assert_ne!(source,guarded,"Fixture launcher isolation failed");
|
assert_ne!(source, guarded, "Fixture launcher isolation failed");
|
||||||
fsx::atomic_write(&path,guarded.as_bytes())?;
|
fsx::atomic_write(&path, guarded.as_bytes())?;
|
||||||
self.0.validate()
|
self.0.validate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,138 +50,261 @@ fn players(db: &coa_core::db::Db) -> Result<String> {
|
|||||||
db.query("SELECT CONCAT(id,':',username,':',HEX(salt),':',HEX(verifier)) FROM acore_auth.account WHERE id=900001; SELECT CONCAT(guid,':',account,':',name,':',level,':',money) FROM acore_characters.characters WHERE guid=900001; SELECT CONCAT(guid,':',itemEntry,':',owner_guid,':',enchantments) FROM acore_characters.item_instance WHERE guid=900001; SELECT CONCAT(guid,':',bag,':',slot,':',item) FROM acore_characters.character_inventory WHERE guid=900001;")
|
db.query("SELECT CONCAT(id,':',username,':',HEX(salt),':',HEX(verifier)) FROM acore_auth.account WHERE id=900001; SELECT CONCAT(guid,':',account,':',name,':',level,':',money) FROM acore_characters.characters WHERE guid=900001; SELECT CONCAT(guid,':',itemEntry,':',owner_guid,':',enchantments) FROM acore_characters.item_instance WHERE guid=900001; SELECT CONCAT(guid,':',bag,':',slot,':',item) FROM acore_characters.character_inventory WHERE guid=900001;")
|
||||||
}
|
}
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let args:Vec<_>=std::env::args().skip(1).collect();
|
let args: Vec<_> = std::env::args().skip(1).collect();
|
||||||
let root=PathBuf::from(&args[0]);
|
let root = PathBuf::from(&args[0]);
|
||||||
assert!(root.file_name().unwrap().to_string_lossy().starts_with("coa-schema-fixture-chaos-064-transition-"));
|
assert!(root
|
||||||
assert_eq!(std::fs::read(root.join(".transition-fixture"))?,b"disposable published-064 transition fixture");
|
.file_name()
|
||||||
if args.get(3).is_some_and(|mode| mode=="legacy-recovery") {
|
.unwrap()
|
||||||
return run_fixture(&root,||legacy_recovery(&root));
|
.to_string_lossy()
|
||||||
|
.starts_with("coa-schema-fixture-chaos-064-transition-"));
|
||||||
|
assert_eq!(
|
||||||
|
std::fs::read(root.join(".transition-fixture"))?,
|
||||||
|
b"disposable published-064 transition fixture"
|
||||||
|
);
|
||||||
|
if args.get(3).is_some_and(|mode| mode == "legacy-recovery") {
|
||||||
|
return run_fixture(&root, || legacy_recovery(&root));
|
||||||
}
|
}
|
||||||
assert!(!root.join(".transition-started").exists(),"Use a new independent fixture");
|
assert!(
|
||||||
fsx::atomic_write(&root.join(".transition-started"),b"started")?;
|
!root.join(".transition-started").exists(),
|
||||||
let meta=coa_core::registry::metadata_dir_for(&root)?;
|
"Use a new independent fixture"
|
||||||
assert!(!meta.exists(),"Do not reuse experimental or user metadata");
|
);
|
||||||
run_fixture(&root,||exercise(&root,&meta,&args[1],&args[2]))
|
fsx::atomic_write(&root.join(".transition-started"), b"started")?;
|
||||||
|
let meta = coa_core::registry::metadata_dir_for(&root)?;
|
||||||
|
assert!(!meta.exists(), "Do not reuse experimental or user metadata");
|
||||||
|
run_fixture(&root, || exercise(&root, &meta, &args[1], &args[2]))
|
||||||
}
|
}
|
||||||
fn run_fixture(root:&Path,operation:impl FnOnce()->Result<()>)->Result<()> {
|
fn run_fixture(root: &Path, operation: impl FnOnce() -> Result<()>) -> Result<()> {
|
||||||
let result=std::panic::catch_unwind(std::panic::AssertUnwindSafe(operation));
|
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(operation));
|
||||||
assert!(driver::run(root,driver::Verb::StopAll)?.ok,"Fixture shutdown failed");
|
assert!(
|
||||||
|
driver::run(root, driver::Verb::StopAll)?.ok,
|
||||||
|
"Fixture shutdown failed"
|
||||||
|
);
|
||||||
result.map_err(|_|coa_core::Error::Invalid("Disposable acceptance assertion failed; services were stopped and recovery copies retained.".into()))?
|
result.map_err(|_|coa_core::Error::Invalid("Disposable acceptance assertion failed; services were stopped and recovery copies retained.".into()))?
|
||||||
}
|
}
|
||||||
fn legacy_recovery(root:&Path)->Result<()> {
|
fn legacy_recovery(root: &Path) -> Result<()> {
|
||||||
let meta=coa_core::registry::metadata_dir_for(root)?;
|
let meta = coa_core::registry::metadata_dir_for(root)?;
|
||||||
assert!(driver::run(root,driver::Verb::StopAll)?.ok);
|
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
||||||
let expected=backup::with_database(root,|db| [coa_core::realms::Mode::Coa,coa_core::realms::Mode::Wildcard].into_iter().map(|mode|players(&db.clone().for_realm(mode))).collect::<Result<Vec<_>>>())?;
|
let expected = backup::with_database(root, |db| {
|
||||||
assert!(driver::run(root,driver::Verb::StopAll)?.ok);
|
[
|
||||||
let dirs=std::fs::read_dir(meta.join("updates"))?.collect::<std::io::Result<Vec<_>>>()?;
|
coa_core::realms::Mode::Coa,
|
||||||
assert_eq!(dirs.len(),1,"Requires exactly the preceding successful disposable transition");
|
coa_core::realms::Mode::Wildcard,
|
||||||
let txn_dir=dirs[0].path();
|
]
|
||||||
let journal=txn_dir.join("txn.json");
|
.into_iter()
|
||||||
let mut legacy:serde_json::Value=fsx::read_json(&journal)?;
|
.map(|mode| players(&db.clone().for_realm(mode)))
|
||||||
assert_eq!(legacy["state"],"committed");
|
.collect::<Result<Vec<_>>>()
|
||||||
let point=legacy["recovery_point"].as_str().unwrap().to_string();
|
})?;
|
||||||
let point_path=meta.join("backups").join(&point).join("backup.json");
|
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
||||||
let mut point_json:serde_json::Value=fsx::read_json(&point_path)?;
|
let dirs = std::fs::read_dir(meta.join("updates"))?.collect::<std::io::Result<Vec<_>>>()?;
|
||||||
point_json["manager_version"]="0.6.4".into();
|
assert_eq!(
|
||||||
for component in point_json["components"].as_array_mut().unwrap() { component.as_object_mut().unwrap().remove("file_sha256"); }
|
dirs.len(),
|
||||||
fsx::atomic_write_json(&point_path,&point_json)?;
|
1,
|
||||||
|
"Requires exactly the preceding successful disposable transition"
|
||||||
|
);
|
||||||
|
let txn_dir = dirs[0].path();
|
||||||
|
let journal = txn_dir.join("txn.json");
|
||||||
|
let mut legacy: serde_json::Value = fsx::read_json(&journal)?;
|
||||||
|
assert_eq!(legacy["state"], "committed");
|
||||||
|
let point = legacy["recovery_point"].as_str().unwrap().to_string();
|
||||||
|
let point_path = meta.join("backups").join(&point).join("backup.json");
|
||||||
|
let mut point_json: serde_json::Value = fsx::read_json(&point_path)?;
|
||||||
|
point_json["manager_version"] = "0.6.4".into();
|
||||||
|
for component in point_json["components"].as_array_mut().unwrap() {
|
||||||
|
component.as_object_mut().unwrap().remove("file_sha256");
|
||||||
|
}
|
||||||
|
fsx::atomic_write_json(&point_path, &point_json)?;
|
||||||
legacy.as_object_mut().unwrap().remove("recovery_hashes");
|
legacy.as_object_mut().unwrap().remove("recovery_hashes");
|
||||||
legacy.as_object_mut().unwrap().remove("databases_started");
|
legacy.as_object_mut().unwrap().remove("databases_started");
|
||||||
legacy["state"]="applied".into();
|
legacy["state"] = "applied".into();
|
||||||
fsx::atomic_write_json(&journal,&legacy)?;
|
fsx::atomic_write_json(&journal, &legacy)?;
|
||||||
assert!(update::ensure_recovered(&meta).is_err(),"Legacy unfinished update must block startup");
|
assert!(
|
||||||
let id=legacy["id"].as_str().unwrap();
|
update::ensure_recovered(&meta).is_err(),
|
||||||
let env=RepackEnv {root,meta_dir:&meta};
|
"Legacy unfinished update must block startup"
|
||||||
|
);
|
||||||
|
let id = legacy["id"].as_str().unwrap();
|
||||||
|
let env = RepackEnv {
|
||||||
|
root,
|
||||||
|
meta_dir: &meta,
|
||||||
|
};
|
||||||
println!("Recovering legacy-format transaction and recovery point on disposable installation");
|
println!("Recovering legacy-format transaction and recovery point on disposable installation");
|
||||||
assert_eq!(update::rollback(root,&meta,id,&env)?.state,update::State::RolledBack);
|
assert_eq!(
|
||||||
|
update::rollback(root, &meta, id, &env)?.state,
|
||||||
|
update::State::RolledBack
|
||||||
|
);
|
||||||
for op in legacy["ops"].as_array().unwrap() {
|
for op in legacy["ops"].as_array().unwrap() {
|
||||||
let relative=op["path"].as_str().unwrap();
|
let relative = op["path"].as_str().unwrap();
|
||||||
if op["had_previous"]==true {
|
if op["had_previous"] == true {
|
||||||
assert_eq!(fsx::sha256_file(&fsx::safe_join(root,relative)?)?,fsx::sha256_file(&fsx::safe_join(&txn_dir.join("before"),relative)?)?,"Legacy file restoration mismatch: {relative}");
|
assert_eq!(
|
||||||
} else { assert!(!fsx::safe_join(root,relative)?.exists()); }
|
fsx::sha256_file(&fsx::safe_join(root, relative)?)?,
|
||||||
|
fsx::sha256_file(&fsx::safe_join(&txn_dir.join("before"), relative)?)?,
|
||||||
|
"Legacy file restoration mismatch: {relative}"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
assert!(!fsx::safe_join(root, relative)?.exists());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_eq!(std::fs::read(meta.join("install.json"))?,std::fs::read(txn_dir.join("before/manager-install.json"))?);
|
assert_eq!(
|
||||||
backup::with_database(root,|db| {
|
std::fs::read(meta.join("install.json"))?,
|
||||||
for (index,mode) in [coa_core::realms::Mode::Coa,coa_core::realms::Mode::Wildcard].into_iter().enumerate() {
|
std::fs::read(txn_dir.join("before/manager-install.json"))?
|
||||||
let db=db.clone().for_realm(mode);
|
);
|
||||||
assert_eq!(players(&db)?,expected[index]);
|
backup::with_database(root, |db| {
|
||||||
|
for (index, mode) in [
|
||||||
|
coa_core::realms::Mode::Coa,
|
||||||
|
coa_core::realms::Mode::Wildcard,
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.enumerate()
|
||||||
|
{
|
||||||
|
let db = db.clone().for_realm(mode);
|
||||||
|
assert_eq!(players(&db)?, expected[index]);
|
||||||
assert_eq!(db.query("SELECT COUNT(*) FROM acore_world.coa_manager_migrations WHERE id IN ('manager_repair__20261005_reconcile_wildcard_tables','manager_repair__20261005_reconcile_missing_class_starts');")?,"0");
|
assert_eq!(db.query("SELECT COUNT(*) FROM acore_world.coa_manager_migrations WHERE id IN ('manager_repair__20261005_reconcile_wildcard_tables','manager_repair__20261005_reconcile_missing_class_starts');")?,"0");
|
||||||
assert_eq!(db.query("SELECT sha256 FROM acore_world.coa_manager_migrations WHERE id='manager_repair__20261005_missing_wildcard_tables';")?,"9e4a36245c3f83255415c122c01f08ceb3e3b83898d3d427ac4e2fbcf61e9638");
|
assert_eq!(db.query("SELECT sha256 FROM acore_world.coa_manager_migrations WHERE id='manager_repair__20261005_missing_wildcard_tables';")?,"9e4a36245c3f83255415c122c01f08ceb3e3b83898d3d427ac4e2fbcf61e9638");
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
assert!(driver::run(root,driver::Verb::StopAll)?.ok);
|
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
||||||
assert!(update::pending_checked(&meta)?.is_none());
|
assert!(update::pending_checked(&meta)?.is_none());
|
||||||
assert!(update::rollback(root,&meta,id,&env).is_err(),"Completed recovery must not run again");
|
assert!(
|
||||||
|
update::rollback(root, &meta, id, &env).is_err(),
|
||||||
|
"Completed recovery must not run again"
|
||||||
|
);
|
||||||
println!("PASS: legacy journal blocked startup; old files, metadata, migration histories and player fields restored; completed recovery rejects replay. Original baseline had a missing table, so healthy startup is not claimed after rollback.");
|
println!("PASS: legacy journal blocked startup; old files, metadata, migration histories and player fields restored; completed recovery rejects replay. Original baseline had a missing table, so healthy startup is not claimed after rollback.");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn exercise(root:&Path,meta:&Path,baseline:&str,candidate:&str)->Result<()> {
|
fn exercise(root: &Path, meta: &Path, baseline: &str, candidate: &str) -> Result<()> {
|
||||||
let mut install:InstallMeta=fsx::read_json(&PathBuf::from("C:/games/coa-schema-fixture-chaos-20261005-v1.manager/install.json"))?;
|
let mut install: InstallMeta = fsx::read_json(&PathBuf::from(
|
||||||
install.server_path=root.to_string_lossy().into_owned();
|
"C:/games/coa-schema-fixture-chaos-20261005-v1.manager/install.json",
|
||||||
install.id=uuid::Uuid::new_v4().to_string();
|
))?;
|
||||||
install.manager_version="0.6.4".into();
|
install.server_path = root.to_string_lossy().into_owned();
|
||||||
MetaDir::create(root,&install)?;
|
install.id = uuid::Uuid::new_v4().to_string();
|
||||||
|
install.manager_version = "0.6.4".into();
|
||||||
|
MetaDir::create(root, &install)?;
|
||||||
// Private ports, and no inherited PID records or paths to the source database.
|
// Private ports, and no inherited PID records or paths to the source database.
|
||||||
let mut cfg:serde_json::Value=fsx::read_json(&root.join("Settings/repack.json"))?;
|
let mut cfg: serde_json::Value = fsx::read_json(&root.join("Settings/repack.json"))?;
|
||||||
let mut listeners=Vec::new();
|
let mut listeners = Vec::new();
|
||||||
for key in ["mysqlPort","authPort","worldPort","raPort"] {
|
for key in ["mysqlPort", "authPort", "worldPort", "raPort"] {
|
||||||
let listener=std::net::TcpListener::bind("127.0.0.1:0")?;
|
let listener = std::net::TcpListener::bind("127.0.0.1:0")?;
|
||||||
cfg[key]=listener.local_addr()?.port().into(); listeners.push(listener);
|
cfg[key] = listener.local_addr()?.port().into();
|
||||||
|
listeners.push(listener);
|
||||||
}
|
}
|
||||||
fsx::atomic_write_json(&root.join("Settings/repack.json"),&cfg)?;
|
fsx::atomic_write_json(&root.join("Settings/repack.json"), &cfg)?;
|
||||||
let mut profile:serde_json::Value=fsx::read_json(&root.join("Settings/realm-profile.json"))?;
|
let mut profile: serde_json::Value = fsx::read_json(&root.join("Settings/realm-profile.json"))?;
|
||||||
for key in ["secondary_world_port","secondary_ra_port"] {
|
for key in ["secondary_world_port", "secondary_ra_port"] {
|
||||||
let listener=std::net::TcpListener::bind("127.0.0.1:0")?;
|
let listener = std::net::TcpListener::bind("127.0.0.1:0")?;
|
||||||
profile[key]=listener.local_addr()?.port().into(); listeners.push(listener);
|
profile[key] = listener.local_addr()?.port().into();
|
||||||
|
listeners.push(listener);
|
||||||
}
|
}
|
||||||
fsx::atomic_write_json(&root.join("Settings/realm-profile.json"),&profile)?;
|
fsx::atomic_write_json(&root.join("Settings/realm-profile.json"), &profile)?;
|
||||||
drop(listeners);
|
drop(listeners);
|
||||||
let state=root.join(".state");
|
let state = root.join(".state");
|
||||||
if state.exists() { std::fs::remove_dir_all(&state)?; }
|
if state.exists() {
|
||||||
let secondary_state=root.join(".realms/secondary/.state");
|
std::fs::remove_dir_all(&state)?;
|
||||||
if secondary_state.exists() { std::fs::remove_dir_all(&secondary_state)?; }
|
}
|
||||||
let source=Source::Dir(baseline.into());
|
let secondary_state = root.join(".realms/secondary/.state");
|
||||||
let (manifest,_)=pkgsource::fetch_manifest(&source,coa_core::signing::EMBEDDED_PUBLIC_KEY)?;
|
if secondary_state.exists() {
|
||||||
let temp=tempfile::tempdir()?;
|
std::fs::remove_dir_all(&secondary_state)?;
|
||||||
let parts=pkgsource::fetch_parts(&source,&manifest,&temp.path().join("download"),&Default::default(),&|_,_|{})?;
|
}
|
||||||
let tree=temp.path().join("tree");
|
let source = Source::Dir(baseline.into());
|
||||||
coa_core::package::extract(&parts,&manifest,&tree,&|_,_|{})?;
|
let (manifest, _) = pkgsource::fetch_manifest(&source, coa_core::signing::EMBEDDED_PUBLIC_KEY)?;
|
||||||
|
let temp = tempfile::tempdir()?;
|
||||||
|
let parts = pkgsource::fetch_parts(
|
||||||
|
&source,
|
||||||
|
&manifest,
|
||||||
|
&temp.path().join("download"),
|
||||||
|
&Default::default(),
|
||||||
|
&|_, _| {},
|
||||||
|
)?;
|
||||||
|
let tree = temp.path().join("tree");
|
||||||
|
coa_core::package::extract(&parts, &manifest, &tree, &|_, _| {})?;
|
||||||
for file in &manifest.files {
|
for file in &manifest.files {
|
||||||
if file.path.starts_with("_migrations/") {continue;}
|
if file.path.starts_with("_migrations/") {
|
||||||
fsx::atomic_write(&fsx::safe_join(root,&file.path)?,&std::fs::read(fsx::safe_join(&tree,&file.path)?)?)?;
|
continue;
|
||||||
install.original_hashes.insert(file.path.clone(),file.sha256.clone());
|
}
|
||||||
|
fsx::atomic_write(
|
||||||
|
&fsx::safe_join(root, &file.path)?,
|
||||||
|
&std::fs::read(fsx::safe_join(&tree, &file.path)?)?,
|
||||||
|
)?;
|
||||||
|
install
|
||||||
|
.original_hashes
|
||||||
|
.insert(file.path.clone(), file.sha256.clone());
|
||||||
}
|
}
|
||||||
install.core.version=Some(manifest.version);
|
install.core.version = Some(manifest.version);
|
||||||
fsx::atomic_write_json(&meta.join("install.json"),&install)?;
|
fsx::atomic_write_json(&meta.join("install.json"), &install)?;
|
||||||
// Both worlds must remain local, including generated secondary configuration.
|
// Both worlds must remain local, including generated secondary configuration.
|
||||||
for relative in ["Settings/worldserver.conf.template","Settings/authserver.conf.template"] {
|
for relative in [
|
||||||
let p=root.join(relative);
|
"Settings/worldserver.conf.template",
|
||||||
let mut conf=coa_core::config::parser::ConfFile::parse_bytes(&std::fs::read(&p)?)?;
|
"Settings/authserver.conf.template",
|
||||||
conf.set("BindIP","\"127.0.0.1\"",&[]); conf.set("Ra.IP","\"127.0.0.1\"",&[]); conf.set("SOAP.Enabled","0",&[]);
|
] {
|
||||||
fsx::atomic_write(&p,conf.to_text().as_bytes())?;
|
let p = root.join(relative);
|
||||||
|
let mut conf = coa_core::config::parser::ConfFile::parse_bytes(&std::fs::read(&p)?)?;
|
||||||
|
conf.set("BindIP", "\"127.0.0.1\"", &[]);
|
||||||
|
conf.set("Ra.IP", "\"127.0.0.1\"", &[]);
|
||||||
|
conf.set("SOAP.Enabled", "0", &[]);
|
||||||
|
fsx::atomic_write(&p, conf.to_text().as_bytes())?;
|
||||||
}
|
}
|
||||||
let expected=backup::with_database(root,|db| {
|
let expected = backup::with_database(root, |db| {
|
||||||
let mut saved=Vec::new();
|
let mut saved = Vec::new();
|
||||||
for mode in [coa_core::realms::Mode::Coa,coa_core::realms::Mode::Wildcard] {
|
for mode in [
|
||||||
let db=db.clone().for_realm(mode);
|
coa_core::realms::Mode::Coa,
|
||||||
|
coa_core::realms::Mode::Wildcard,
|
||||||
|
] {
|
||||||
|
let db = db.clone().for_realm(mode);
|
||||||
saved.push(players(&db)?);
|
saved.push(players(&db)?);
|
||||||
db.query("DROP TABLE IF EXISTS acore_characters.coa_wildcard_skill_card; DELETE FROM acore_world.coa_manager_migrations WHERE id IN ('manager_repair__20261005_reconcile_wildcard_tables','manager_repair__20261005_reconcile_missing_class_starts'); UPDATE acore_world.coa_manager_migrations SET sha256='9e4a36245c3f83255415c122c01f08ceb3e3b83898d3d427ac4e2fbcf61e9638' WHERE id='manager_repair__20261005_missing_wildcard_tables' AND status='applied';")?;
|
db.query("DROP TABLE IF EXISTS acore_characters.coa_wildcard_skill_card; DELETE FROM acore_world.coa_manager_migrations WHERE id IN ('manager_repair__20261005_reconcile_wildcard_tables','manager_repair__20261005_reconcile_missing_class_starts'); UPDATE acore_world.coa_manager_migrations SET sha256='9e4a36245c3f83255415c122c01f08ceb3e3b83898d3d427ac4e2fbcf61e9638' WHERE id='manager_repair__20261005_missing_wildcard_tables' AND status='applied';")?;
|
||||||
}
|
}
|
||||||
Ok(saved)
|
Ok(saved)
|
||||||
})?;
|
})?;
|
||||||
let source=Source::Dir(candidate.into());
|
let source = Source::Dir(candidate.into());
|
||||||
let candidate_manifest=pkgsource::fetch_manifest(&source,coa_core::signing::EMBEDDED_PUBLIC_KEY)?.0;
|
let candidate_manifest =
|
||||||
let choices:BTreeMap<_,_>=update::plan(root,&install,&candidate_manifest,&BTreeMap::new(),None)?.into_iter().filter(|p|p.action==update::Action::Conflict).map(|p|(p.path,update::Resolution::Replace)).collect();
|
pkgsource::fetch_manifest(&source, coa_core::signing::EMBEDDED_PUBLIC_KEY)?.0;
|
||||||
let env=Offline(RepackEnv{root,meta_dir:meta});
|
let choices: BTreeMap<_, _> =
|
||||||
let outcome=update::apply(&update::Params {root,meta_dir:meta,source,trusted_key:coa_core::signing::EMBEDDED_PUBLIC_KEY,cancel:Default::default(),resolutions:choices,env:&env,fail_after_ops:None},&|stage,pct|println!("{pct}% {stage}"))?;
|
update::plan(root, &install, &candidate_manifest, &BTreeMap::new(), None)?
|
||||||
assert_eq!(outcome.txn.state,update::State::Committed,"{:?}",outcome.txn.message);
|
.into_iter()
|
||||||
backup::with_database(root,|db| {
|
.filter(|p| p.action == update::Action::Conflict)
|
||||||
for (index,mode) in [coa_core::realms::Mode::Coa,coa_core::realms::Mode::Wildcard].into_iter().enumerate() {
|
.map(|p| (p.path, update::Resolution::Replace))
|
||||||
let db=db.clone().for_realm(mode);
|
.collect();
|
||||||
assert_eq!(players(&db)?,expected[index],"Player data changed in {}",mode.name());
|
let env = Offline(RepackEnv {
|
||||||
assert!(coa_core::schema_check::check(&db,root)?.is_empty());
|
root,
|
||||||
assert_eq!(migrations::pending_count(&db,&candidate_manifest.migrations)?,0);
|
meta_dir: meta,
|
||||||
|
});
|
||||||
|
let outcome = update::apply(
|
||||||
|
&update::Params {
|
||||||
|
root,
|
||||||
|
meta_dir: meta,
|
||||||
|
source,
|
||||||
|
trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
|
cancel: Default::default(),
|
||||||
|
resolutions: choices,
|
||||||
|
env: &env,
|
||||||
|
fail_after_ops: None,
|
||||||
|
},
|
||||||
|
&|stage, pct| println!("{pct}% {stage}"),
|
||||||
|
)?;
|
||||||
|
assert_eq!(
|
||||||
|
outcome.txn.state,
|
||||||
|
update::State::Committed,
|
||||||
|
"{:?}",
|
||||||
|
outcome.txn.message
|
||||||
|
);
|
||||||
|
backup::with_database(root, |db| {
|
||||||
|
for (index, mode) in [
|
||||||
|
coa_core::realms::Mode::Coa,
|
||||||
|
coa_core::realms::Mode::Wildcard,
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.enumerate()
|
||||||
|
{
|
||||||
|
let db = db.clone().for_realm(mode);
|
||||||
|
assert_eq!(
|
||||||
|
players(&db)?,
|
||||||
|
expected[index],
|
||||||
|
"Player data changed in {}",
|
||||||
|
mode.name()
|
||||||
|
);
|
||||||
|
assert!(coa_core::schema_check::check(&db, root)?.is_empty());
|
||||||
|
assert_eq!(
|
||||||
|
migrations::pending_count(&db, &candidate_manifest.migrations)?,
|
||||||
|
0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
@@ -11,47 +11,123 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a: Vec<String> = std::env::args().skip(1).collect();
|
let a: Vec<String> = std::env::args().skip(1).collect();
|
||||||
let (fixture, out, dest) = (PathBuf::from(&a[0]), PathBuf::from(&a[1]), PathBuf::from(&a[2]));
|
let (fixture, out, dest) = (
|
||||||
assert!(a[0].to_lowercase().contains("fixture"), "refusing: source is not a fixture");
|
PathBuf::from(&a[0]),
|
||||||
assert!(std::fs::symlink_metadata(fixture.join("Data")).unwrap().file_type().is_symlink(), "Data junction must be skipped by the packager");
|
PathBuf::from(&a[1]),
|
||||||
|
PathBuf::from(&a[2]),
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
a[0].to_lowercase().contains("fixture"),
|
||||||
|
"refusing: source is not a fixture"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
std::fs::symlink_metadata(fixture.join("Data"))
|
||||||
|
.unwrap()
|
||||||
|
.file_type()
|
||||||
|
.is_symlink(),
|
||||||
|
"Data junction must be skipped by the packager"
|
||||||
|
);
|
||||||
|
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
let m = build(&fixture, &out, &BuildOptions { kind: coa_core::manifest::Kind::Base, version: "0.1.0".into(), core_commit: None, built_at: chrono::Utc::now().to_rfc3339(), part_size: 256 * 1024 * 1024, bots_commit: None, migrations: vec![] }, &|s| eprintln!(" pack: {s}")).expect("build");
|
let m = build(
|
||||||
|
&fixture,
|
||||||
|
&out,
|
||||||
|
&BuildOptions {
|
||||||
|
kind: coa_core::manifest::Kind::Base,
|
||||||
|
version: "0.1.0".into(),
|
||||||
|
core_commit: None,
|
||||||
|
built_at: chrono::Utc::now().to_rfc3339(),
|
||||||
|
part_size: 256 * 1024 * 1024,
|
||||||
|
bots_commit: None,
|
||||||
|
migrations: vec![],
|
||||||
|
},
|
||||||
|
&|s| eprintln!(" pack: {s}"),
|
||||||
|
)
|
||||||
|
.expect("build");
|
||||||
let arch = m.archive.as_ref().unwrap();
|
let arch = m.archive.as_ref().unwrap();
|
||||||
println!("packaged {} files, {:.2} GB -> {} parts, {:.2} GB in {:?}", m.files.len(), arch.unpacked_size as f64 / 1e9, arch.parts.len(), arch.parts.iter().map(|p| p.size).sum::<u64>() as f64 / 1e9, t.elapsed());
|
println!(
|
||||||
|
"packaged {} files, {:.2} GB -> {} parts, {:.2} GB in {:?}",
|
||||||
|
m.files.len(),
|
||||||
|
arch.unpacked_size as f64 / 1e9,
|
||||||
|
arch.parts.len(),
|
||||||
|
arch.parts.iter().map(|p| p.size).sum::<u64>() as f64 / 1e9,
|
||||||
|
t.elapsed()
|
||||||
|
);
|
||||||
|
|
||||||
let key_path = format!("{}/.coa-manager/signing/manifest-signing.key", std::env::var("USERPROFILE").unwrap());
|
let key_path = format!(
|
||||||
let seed: [u8; 32] = STANDARD.decode(std::fs::read_to_string(key_path).unwrap().trim()).unwrap().try_into().unwrap();
|
"{}/.coa-manager/signing/manifest-signing.key",
|
||||||
let sig = SigningKey::from_bytes(&seed).sign(&std::fs::read(out.join("manifest.json")).unwrap());
|
std::env::var("USERPROFILE").unwrap()
|
||||||
std::fs::write(out.join("manifest.json.sig"), STANDARD.encode(sig.to_bytes())).unwrap();
|
);
|
||||||
|
let seed: [u8; 32] = STANDARD
|
||||||
|
.decode(std::fs::read_to_string(key_path).unwrap().trim())
|
||||||
|
.unwrap()
|
||||||
|
.try_into()
|
||||||
|
.unwrap();
|
||||||
|
let sig =
|
||||||
|
SigningKey::from_bytes(&seed).sign(&std::fs::read(out.join("manifest.json")).unwrap());
|
||||||
|
std::fs::write(
|
||||||
|
out.join("manifest.json.sig"),
|
||||||
|
STANDARD.encode(sig.to_bytes()),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let reg_dir = std::env::temp_dir().join("coa-install-e2e");
|
let reg_dir = std::env::temp_dir().join("coa-install-e2e");
|
||||||
let _ = std::fs::remove_dir_all(®_dir);
|
let _ = std::fs::remove_dir_all(®_dir);
|
||||||
let registry = Registry::at(reg_dir.join("installs.json"));
|
let registry = Registry::at(reg_dir.join("installs.json"));
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
let installed = install_base(
|
let installed = install_base(
|
||||||
&Params { source: Source::Dir(out.clone()), dest: dest.clone(), trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY, registry: ®istry, cancel: Cancel::default() },
|
&Params {
|
||||||
&|s| eprintln!(" install: {:>3}% {} {}", s.percent, s.step, s.detail.unwrap_or_default()),
|
source: Source::Dir(out.clone()),
|
||||||
|
dest: dest.clone(),
|
||||||
|
trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
|
registry: ®istry,
|
||||||
|
cancel: Cancel::default(),
|
||||||
|
},
|
||||||
|
&|s| {
|
||||||
|
eprintln!(
|
||||||
|
" install: {:>3}% {} {}",
|
||||||
|
s.percent,
|
||||||
|
s.step,
|
||||||
|
s.detail.unwrap_or_default()
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| panic!("install failed: {e:?}"));
|
.unwrap_or_else(|e| panic!("install failed: {e:?}"));
|
||||||
println!("installed {} at {} in {:?}", installed.version, installed.path, t.elapsed());
|
println!(
|
||||||
|
"installed {} at {} in {:?}",
|
||||||
|
installed.version,
|
||||||
|
installed.path,
|
||||||
|
t.elapsed()
|
||||||
|
);
|
||||||
|
|
||||||
assert!(!dest.with_file_name("coa-installtest.installing").exists());
|
assert!(!dest.with_file_name("coa-installtest.installing").exists());
|
||||||
assert!(!dest.join("Settings/database.bootstrap.json").exists(), "bootstrap credentials are removed");
|
assert!(
|
||||||
|
!dest.join("Settings/database.bootstrap.json").exists(),
|
||||||
|
"bootstrap credentials are removed"
|
||||||
|
);
|
||||||
assert!(dest.join("Core/worldserver.exe").is_file());
|
assert!(dest.join("Core/worldserver.exe").is_file());
|
||||||
assert!(dest.with_file_name("coa-installtest.manager/install.json").is_file());
|
assert!(dest
|
||||||
|
.with_file_name("coa-installtest.manager/install.json")
|
||||||
|
.is_file());
|
||||||
assert_eq!(registry.list().unwrap().len(), 1);
|
assert_eq!(registry.list().unwrap().len(), 1);
|
||||||
|
|
||||||
// The rotated credentials must differ from the packaged ones and work.
|
// The rotated credentials must differ from the packaged ones and work.
|
||||||
let packaged: serde_json::Value = serde_json::from_slice(&std::fs::read(fixture.join("Settings/database.json")).unwrap()).unwrap();
|
let packaged: serde_json::Value =
|
||||||
let now: serde_json::Value = serde_json::from_slice(&std::fs::read(dest.join("Settings/database.json")).unwrap()).unwrap();
|
serde_json::from_slice(&std::fs::read(fixture.join("Settings/database.json")).unwrap())
|
||||||
|
.unwrap();
|
||||||
|
let now: serde_json::Value =
|
||||||
|
serde_json::from_slice(&std::fs::read(dest.join("Settings/database.json")).unwrap())
|
||||||
|
.unwrap();
|
||||||
assert_ne!(packaged["rootPassword"], now["rootPassword"]);
|
assert_ne!(packaged["rootPassword"], now["rootPassword"]);
|
||||||
assert_ne!(packaged["appPassword"], now["appPassword"]);
|
assert_ne!(packaged["appPassword"], now["appPassword"]);
|
||||||
coa_core::backup::with_database(&dest, |db: &Db| {
|
coa_core::backup::with_database(&dest, |db: &Db| {
|
||||||
assert!(db.ping());
|
assert!(db.ping());
|
||||||
assert_eq!(db.tables("acore_auth")?.len() > 10, true);
|
assert!(db.tables("acore_auth")?.len() > 10);
|
||||||
let app = Db::from_repack(&dest, Account::App)?;
|
let app = Db::from_repack(&dest, Account::App)?;
|
||||||
assert!(app.query("SELECT 1;")? == "1", "the game account works with the new password");
|
assert!(
|
||||||
|
app.query("SELECT 1;")? == "1",
|
||||||
|
"the game account works with the new password"
|
||||||
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.expect("database after install");
|
.expect("database after install");
|
||||||
|
|||||||
@@ -5,9 +5,23 @@ use coa_core::registry::Registry;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a: Vec<String> = std::env::args().skip(1).collect();
|
let a: Vec<String> = std::env::args().skip(1).collect();
|
||||||
let reg = Registry::at(std::env::temp_dir().join("coa-install-pkg").join("installs.json"));
|
let reg = Registry::at(
|
||||||
|
std::env::temp_dir()
|
||||||
|
.join("coa-install-pkg")
|
||||||
|
.join("installs.json"),
|
||||||
|
);
|
||||||
let _ = std::fs::remove_dir_all(std::env::temp_dir().join("coa-install-pkg"));
|
let _ = std::fs::remove_dir_all(std::env::temp_dir().join("coa-install-pkg"));
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
let r = install_base(&Params { source: Source::Dir(a[0].clone().into()), dest: a[1].clone().into(), trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY, registry: ®, cancel: Cancel::default() }, &|s| eprintln!(" {:>3}% {}", s.percent, s.step)).unwrap_or_else(|e| panic!("install failed: {e:?}"));
|
let r = install_base(
|
||||||
|
&Params {
|
||||||
|
source: Source::Dir(a[0].clone().into()),
|
||||||
|
dest: a[1].clone().into(),
|
||||||
|
trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
|
registry: ®,
|
||||||
|
cancel: Cancel::default(),
|
||||||
|
},
|
||||||
|
&|s| eprintln!(" {:>3}% {}", s.percent, s.step),
|
||||||
|
)
|
||||||
|
.unwrap_or_else(|e| panic!("install failed: {e:?}"));
|
||||||
println!("installed {} at {} in {:?}", r.version, r.path, t.elapsed());
|
println!("installed {} at {} in {:?}", r.version, r.path, t.elapsed());
|
||||||
}
|
}
|
||||||
@@ -5,9 +5,23 @@ use coa_core::registry::Registry;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a: Vec<String> = std::env::args().skip(1).collect();
|
let a: Vec<String> = std::env::args().skip(1).collect();
|
||||||
let reg = Registry::at(std::env::temp_dir().join("coa-install-url").join("installs.json"));
|
let reg = Registry::at(
|
||||||
|
std::env::temp_dir()
|
||||||
|
.join("coa-install-url")
|
||||||
|
.join("installs.json"),
|
||||||
|
);
|
||||||
let _ = std::fs::remove_dir_all(std::env::temp_dir().join("coa-install-url"));
|
let _ = std::fs::remove_dir_all(std::env::temp_dir().join("coa-install-url"));
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
let r = install_base(&Params { source: Source::Url(a[0].clone()), dest: a[1].clone().into(), trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY, registry: ®, cancel: Cancel::default() }, &|s| eprintln!(" {:>3}% {}", s.percent, s.step)).unwrap_or_else(|e| panic!("install failed: {e:?}"));
|
let r = install_base(
|
||||||
|
&Params {
|
||||||
|
source: Source::Url(a[0].clone()),
|
||||||
|
dest: a[1].clone().into(),
|
||||||
|
trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
|
registry: ®,
|
||||||
|
cancel: Cancel::default(),
|
||||||
|
},
|
||||||
|
&|s| eprintln!(" {:>3}% {}", s.percent, s.step),
|
||||||
|
)
|
||||||
|
.unwrap_or_else(|e| panic!("install failed: {e:?}"));
|
||||||
println!("installed {} at {} in {:?}", r.version, r.path, t.elapsed());
|
println!("installed {} at {} in {:?}", r.version, r.path, t.elapsed());
|
||||||
}
|
}
|
||||||
@@ -5,14 +5,27 @@ use ed25519_dalek::SigningKey;
|
|||||||
use std::{fs, path::PathBuf};
|
use std::{fs, path::PathBuf};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let private = PathBuf::from(std::env::var("USERPROFILE").expect("USERPROFILE")).join(".coa-manager/signing/manifest-signing.key");
|
let private = PathBuf::from(std::env::var("USERPROFILE").expect("USERPROFILE"))
|
||||||
let public = PathBuf::from(std::env::args().nth(1).unwrap_or_else(|| "keys/manifest-signing.pub".into()));
|
.join(".coa-manager/signing/manifest-signing.key");
|
||||||
|
let public = PathBuf::from(
|
||||||
|
std::env::args()
|
||||||
|
.nth(1)
|
||||||
|
.unwrap_or_else(|| "keys/manifest-signing.pub".into()),
|
||||||
|
);
|
||||||
if private.exists() || public.exists() {
|
if private.exists() || public.exists() {
|
||||||
panic!("a key already exists; refusing to overwrite");
|
panic!("a key already exists; refusing to overwrite");
|
||||||
}
|
}
|
||||||
fs::create_dir_all(private.parent().unwrap()).unwrap();
|
fs::create_dir_all(private.parent().unwrap()).unwrap();
|
||||||
let sk = SigningKey::generate(&mut rand_core::OsRng);
|
let sk = SigningKey::generate(&mut rand_core::OsRng);
|
||||||
fs::write(&private, STANDARD.encode(sk.to_bytes())).unwrap();
|
fs::write(&private, STANDARD.encode(sk.to_bytes())).unwrap();
|
||||||
fs::write(&public, format!("{}\n", STANDARD.encode(sk.verifying_key().to_bytes()))).unwrap();
|
fs::write(
|
||||||
println!("private key: {}\npublic key: {}", private.display(), public.display());
|
&public,
|
||||||
|
format!("{}\n", STANDARD.encode(sk.verifying_key().to_bytes())),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
println!(
|
||||||
|
"private key: {}\npublic key: {}",
|
||||||
|
private.display(),
|
||||||
|
public.display()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -8,14 +8,24 @@ use coa_core::migrations::{apply_pending, status, Status};
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
fn sql_files(dir: &Path) -> Vec<PathBuf> {
|
fn sql_files(dir: &Path) -> Vec<PathBuf> {
|
||||||
let mut v: Vec<PathBuf> = std::fs::read_dir(dir).map(|rd| rd.flatten().map(|e| e.path()).filter(|p| p.extension().map(|e| e == "sql").unwrap_or(false)).collect()).unwrap_or_default();
|
let mut v: Vec<PathBuf> = std::fs::read_dir(dir)
|
||||||
|
.map(|rd| {
|
||||||
|
rd.flatten()
|
||||||
|
.map(|e| e.path())
|
||||||
|
.filter(|p| p.extension().map(|e| e == "sql").unwrap_or(false))
|
||||||
|
.collect()
|
||||||
|
})
|
||||||
|
.unwrap_or_default();
|
||||||
v.sort();
|
v.sort();
|
||||||
v
|
v
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a: Vec<String> = std::env::args().skip(1).collect();
|
let a: Vec<String> = std::env::args().skip(1).collect();
|
||||||
assert!(a[0].to_lowercase().contains("fixture"), "refusing: not a fixture folder");
|
assert!(
|
||||||
|
a[0].to_lowercase().contains("fixture"),
|
||||||
|
"refusing: not a fixture folder"
|
||||||
|
);
|
||||||
let (root, core) = (PathBuf::from(&a[0]), PathBuf::from(&a[1]));
|
let (root, core) = (PathBuf::from(&a[0]), PathBuf::from(&a[1]));
|
||||||
let staging = std::env::temp_dir().join("coa-migrate-e2e");
|
let staging = std::env::temp_dir().join("coa-migrate-e2e");
|
||||||
let _ = std::fs::remove_dir_all(&staging);
|
let _ = std::fs::remove_dir_all(&staging);
|
||||||
@@ -24,17 +34,37 @@ fn main() {
|
|||||||
let mut list: Vec<Migration> = Vec::new();
|
let mut list: Vec<Migration> = Vec::new();
|
||||||
let mut origin: std::collections::HashMap<(String, String), String> = Default::default();
|
let mut origin: std::collections::HashMap<(String, String), String> = Default::default();
|
||||||
let mut add = |db: &str, id: String, src: &Path| {
|
let mut add = |db: &str, id: String, src: &Path| {
|
||||||
origin.insert((db.to_string(), id.clone()), src.strip_prefix(&core).unwrap().to_string_lossy().replace('\\', "/"));
|
origin.insert(
|
||||||
|
(db.to_string(), id.clone()),
|
||||||
|
src.strip_prefix(&core)
|
||||||
|
.unwrap()
|
||||||
|
.to_string_lossy()
|
||||||
|
.replace('\\', "/"),
|
||||||
|
);
|
||||||
let bytes = std::fs::read(src).unwrap();
|
let bytes = std::fs::read(src).unwrap();
|
||||||
let dst = staging.join(db).join(format!("{id}.sql"));
|
let dst = staging.join(db).join(format!("{id}.sql"));
|
||||||
std::fs::create_dir_all(dst.parent().unwrap()).unwrap();
|
std::fs::create_dir_all(dst.parent().unwrap()).unwrap();
|
||||||
std::fs::write(&dst, &bytes).unwrap();
|
std::fs::write(&dst, &bytes).unwrap();
|
||||||
list.push(Migration { compatible_sha256: vec![], id, db: db.into(), sha256: fsx::sha256_bytes(&bytes), destructive: false });
|
list.push(Migration {
|
||||||
|
compatible_sha256: vec![],
|
||||||
|
id,
|
||||||
|
db: db.into(),
|
||||||
|
sha256: fsx::sha256_bytes(&bytes),
|
||||||
|
destructive: false,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
for (kind, dirs) in [("auth", ["db_auth", "pending_db_auth"]), ("characters", ["db_characters", "pending_db_characters"]), ("world", ["db_world", "pending_db_world"])] {
|
for (kind, dirs) in [
|
||||||
|
("auth", ["db_auth", "pending_db_auth"]),
|
||||||
|
("characters", ["db_characters", "pending_db_characters"]),
|
||||||
|
("world", ["db_world", "pending_db_world"]),
|
||||||
|
] {
|
||||||
for d in dirs {
|
for d in dirs {
|
||||||
for f in sql_files(&core.join("data/sql/updates").join(d)) {
|
for f in sql_files(&core.join("data/sql/updates").join(d)) {
|
||||||
add(kind, f.file_stem().unwrap().to_string_lossy().into_owned(), &f);
|
add(
|
||||||
|
kind,
|
||||||
|
f.file_stem().unwrap().to_string_lossy().into_owned(),
|
||||||
|
&f,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,10 +73,21 @@ fn main() {
|
|||||||
for kind in ["auth", "characters", "world"] {
|
for kind in ["auth", "characters", "world"] {
|
||||||
let base = m.path().join(format!("data/sql/db-{kind}"));
|
let base = m.path().join(format!("data/sql/db-{kind}"));
|
||||||
for f in sql_files(&base.join("base")) {
|
for f in sql_files(&base.join("base")) {
|
||||||
add(kind, format!("mod_{mname}__base__{}", f.file_stem().unwrap().to_string_lossy()), &f);
|
add(
|
||||||
|
kind,
|
||||||
|
format!(
|
||||||
|
"mod_{mname}__base__{}",
|
||||||
|
f.file_stem().unwrap().to_string_lossy()
|
||||||
|
),
|
||||||
|
&f,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
for f in sql_files(&base) {
|
for f in sql_files(&base) {
|
||||||
add(kind, format!("mod_{mname}__{}", f.file_stem().unwrap().to_string_lossy()), &f);
|
add(
|
||||||
|
kind,
|
||||||
|
format!("mod_{mname}__{}", f.file_stem().unwrap().to_string_lossy()),
|
||||||
|
&f,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,29 +95,68 @@ fn main() {
|
|||||||
// table created by a module script that arrived earlier). The release pipeline computes exactly this.
|
// table created by a module script that arrived earlier). The release pipeline computes exactly this.
|
||||||
let out = std::process::Command::new("git")
|
let out = std::process::Command::new("git")
|
||||||
.current_dir(&core)
|
.current_dir(&core)
|
||||||
.args(["log", "--reverse", "--diff-filter=A", "--name-only", "--pretty=format:", "--", "data/sql/updates", "modules"])
|
.args([
|
||||||
|
"log",
|
||||||
|
"--reverse",
|
||||||
|
"--diff-filter=A",
|
||||||
|
"--name-only",
|
||||||
|
"--pretty=format:",
|
||||||
|
"--",
|
||||||
|
"data/sql/updates",
|
||||||
|
"modules",
|
||||||
|
])
|
||||||
.output()
|
.output()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut rank = std::collections::HashMap::new();
|
let mut rank = std::collections::HashMap::new();
|
||||||
for (i, path) in String::from_utf8_lossy(&out.stdout).lines().filter(|l| l.ends_with(".sql")).enumerate() {
|
for (i, path) in String::from_utf8_lossy(&out.stdout)
|
||||||
|
.lines()
|
||||||
|
.filter(|l| l.ends_with(".sql"))
|
||||||
|
.enumerate()
|
||||||
|
{
|
||||||
rank.entry(path.to_string()).or_insert(i);
|
rank.entry(path.to_string()).or_insert(i);
|
||||||
}
|
}
|
||||||
let key = |m: &Migration| -> usize {
|
let key = |m: &Migration| -> usize {
|
||||||
origin.get(&(m.db.clone(), m.id.clone())).and_then(|p| rank.get(p)).copied().unwrap_or(usize::MAX)
|
origin
|
||||||
|
.get(&(m.db.clone(), m.id.clone()))
|
||||||
|
.and_then(|p| rank.get(p))
|
||||||
|
.copied()
|
||||||
|
.unwrap_or(usize::MAX)
|
||||||
};
|
};
|
||||||
list.sort_by_key(|m| key(m));
|
list.sort_by_key(|m| key(m));
|
||||||
println!("candidate migrations: {} ({} not found in history)", list.len(), list.iter().filter(|m| key(m) == usize::MAX).count());
|
println!(
|
||||||
|
"candidate migrations: {} ({} not found in history)",
|
||||||
|
list.len(),
|
||||||
|
list.iter().filter(|m| key(m) == usize::MAX).count()
|
||||||
|
);
|
||||||
|
|
||||||
let admin = Db::from_repack(&root, Account::Admin).unwrap();
|
let admin = Db::from_repack(&root, Account::Admin).unwrap();
|
||||||
let _ = &admin;
|
let _ = &admin;
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
let report = backup::with_database(&root, |db| {
|
let report = backup::with_database(&root, |db| {
|
||||||
let before = status(db, &list)?;
|
let before = status(db, &list)?;
|
||||||
let pending = before.iter().filter(|i| i.status == Status::Pending).count();
|
let pending = before
|
||||||
println!("already recorded by the database: {}; pending: {pending}", list.len() - pending);
|
.iter()
|
||||||
let pending_list: Vec<Migration> = list.iter().zip(&before).filter(|(_, i)| i.status == Status::Pending).map(|(m, _)| m.clone()).collect();
|
.filter(|i| i.status == Status::Pending)
|
||||||
apply_pending(db, &pending_list, &staging, &|| Ok("(fixture: no backup)".into()))
|
.count();
|
||||||
|
println!(
|
||||||
|
"already recorded by the database: {}; pending: {pending}",
|
||||||
|
list.len() - pending
|
||||||
|
);
|
||||||
|
let pending_list: Vec<Migration> = list
|
||||||
|
.iter()
|
||||||
|
.zip(&before)
|
||||||
|
.filter(|(_, i)| i.status == Status::Pending)
|
||||||
|
.map(|(m, _)| m.clone())
|
||||||
|
.collect();
|
||||||
|
apply_pending(db, &pending_list, &staging, &|| {
|
||||||
|
Ok("(fixture: no backup)".into())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.expect("apply");
|
.expect("apply");
|
||||||
println!("applied {} in {:?}; failed: {:?}", report.applied.len(), t.elapsed(), report.failed);
|
println!(
|
||||||
|
"applied {} in {:?}; failed: {:?}",
|
||||||
|
report.applied.len(),
|
||||||
|
t.elapsed(),
|
||||||
|
report.failed
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -1,57 +1,124 @@
|
|||||||
//! Read-only audit, or explicit SQL checks on a disposable database fixture.
|
//! Read-only audit, or explicit SQL checks on a disposable database fixture.
|
||||||
use coa_core::{db::{Account, Db}, migrations::{self, Store}, manifest::Manifest, realms::Mode};
|
use coa_core::{
|
||||||
|
db::{Account, Db},
|
||||||
|
manifest::Manifest,
|
||||||
|
migrations::{self, Store},
|
||||||
|
realms::Mode,
|
||||||
|
};
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let args: Vec<_> = std::env::args().collect();
|
let args: Vec<_> = std::env::args().collect();
|
||||||
if args.len() < 3 { return Err("usage: migration_plan <root> <signed-manifest> [--apply|--sql-only <migration-directory>]".into()); }
|
if args.len() < 3 {
|
||||||
let root = std::path::Path::new(&args[1]);
|
return Err("usage: migration_plan <root> <signed-manifest> [--apply|--sql-only <migration-directory>]".into());
|
||||||
let bytes = std::fs::read(&args[2])?;
|
|
||||||
let signature = std::fs::read_to_string(format!("{}.sig",args[2]))?;
|
|
||||||
coa_core::signing::verify(&bytes, &signature, coa_core::signing::EMBEDDED_PUBLIC_KEY)?;
|
|
||||||
let manifest = Manifest::parse(&bytes)?;
|
|
||||||
for (index,mode) in [Mode::Coa, Mode::Wildcard].into_iter().enumerate() {
|
|
||||||
let db = Db::from_repack(root, Account::Admin)?.for_realm(mode);
|
|
||||||
let rows = db.load_readonly()?;
|
|
||||||
let relevant: Vec<_> = rows.iter().filter(|r| r.id == "rev_20260903_01_live_class_baseline").map(|r| format!("{} {:?} {}",r.db,r.status,r.baseline)).collect();
|
|
||||||
println!("{} baseline history: {:?}",mode.name(),relevant);
|
|
||||||
let list: Vec<_> = manifest.migrations.iter().filter(|m|index==0 || m.db!="auth").cloned().collect();
|
|
||||||
let plan = migrations::status(&db,&list)?;
|
|
||||||
println!("{} pending: {:?}",mode.name(),plan.iter().filter(|m|m.status!=migrations::Status::Applied).map(|m|(&m.db,&m.id,m.status)).collect::<Vec<_>>());
|
|
||||||
}
|
|
||||||
if args.get(3).is_some_and(|s| s == "--apply" || s == "--sql-only") {
|
|
||||||
assert!(root.file_name().unwrap().to_string_lossy().starts_with("update-database-diagnosis-") && root.join(".coa-update-fixture").is_file(), "Only disposable fixture roots may be changed");
|
|
||||||
if args[3] == "--sql-only" {
|
|
||||||
let db = Db::from_repack(root, Account::Admin)?.for_realm(Mode::Coa);
|
|
||||||
let identity = || -> coa_core::Result<String> {
|
|
||||||
let mut rows = String::new();
|
|
||||||
for (schema,table,columns) in [("acore_auth","account","id,HEX(username)"),("acore_characters","characters","guid,account,HEX(name)"),("acore_characters_wildcard","characters","guid,account,HEX(name)")] {
|
|
||||||
rows.push_str(schema);
|
|
||||||
rows.push_str(&db.query(&format!("SELECT {columns} FROM {schema}.{table} ORDER BY 1;"))?);
|
|
||||||
}
|
}
|
||||||
Ok(coa_core::fsx::sha256_bytes(rows.as_bytes()))
|
let root = std::path::Path::new(&args[1]);
|
||||||
};
|
let bytes = std::fs::read(&args[2])?;
|
||||||
let before = identity()?;
|
let signature = std::fs::read_to_string(format!("{}.sig", args[2]))?;
|
||||||
migrations::verify_files(&manifest.migrations,std::path::Path::new(&args[4]))?;
|
coa_core::signing::verify(&bytes, &signature, coa_core::signing::EMBEDDED_PUBLIC_KEY)?;
|
||||||
for (index,mode) in [Mode::Coa,Mode::Wildcard].into_iter().enumerate() {
|
let manifest = Manifest::parse(&bytes)?;
|
||||||
let realm_db = db.clone().for_realm(mode);
|
for (index, mode) in [Mode::Coa, Mode::Wildcard].into_iter().enumerate() {
|
||||||
let list: Vec<_> = manifest.migrations.iter().filter(|m|index==0 || m.db!="auth").cloned().collect();
|
let db = Db::from_repack(root, Account::Admin)?.for_realm(mode);
|
||||||
let result = migrations::apply_pending(&realm_db,&list,std::path::Path::new(&args[4]),&||Ok("disposable fixture".into()))?;
|
let rows = db.load_readonly()?;
|
||||||
println!("{} SQL result: {}",mode.name(),serde_json::to_string(&result)?);
|
let relevant: Vec<_> = rows
|
||||||
if result.failed.is_some() {return Err("SQL failed; fixture preserved".into());}
|
.iter()
|
||||||
}
|
.filter(|r| r.id == "rev_20260903_01_live_class_baseline")
|
||||||
assert_eq!(before,identity()?,"Account or character identity changed");
|
.map(|r| format!("{} {:?} {}", r.db, r.status, r.baseline))
|
||||||
println!("Account and character identities preserved: {}",before);
|
.collect();
|
||||||
let capture = root.join("captured-schema");
|
println!("{} baseline history: {:?}", mode.name(), relevant);
|
||||||
coa_core::schema_check::capture(&db,&capture)?;
|
let list: Vec<_> = manifest
|
||||||
println!("Captured schema SHA256: {}",coa_core::fsx::sha256_file(&capture.join(coa_core::schema_check::CONTRACT))?);
|
.migrations
|
||||||
return Ok(());
|
.iter()
|
||||||
}
|
.filter(|m| index == 0 || m.db != "auth")
|
||||||
if args.len() != 5 { return Err("Migration directory required".into()); }
|
.cloned()
|
||||||
use coa_core::update::{Env, RepackEnv};
|
.collect();
|
||||||
let meta = coa_core::registry::metadata_dir_for(root)?;
|
let plan = migrations::status(&db, &list)?;
|
||||||
let env = RepackEnv { root, meta_dir: &meta };
|
println!(
|
||||||
let result = env.migrate(&manifest, std::path::Path::new(&args[4]));
|
"{} pending: {:?}",
|
||||||
let _ = coa_core::driver::run(root, coa_core::driver::Verb::StopAll);
|
mode.name(),
|
||||||
println!("Application result: {}",serde_json::to_string(&result?)?);
|
plan.iter()
|
||||||
}
|
.filter(|m| m.status != migrations::Status::Applied)
|
||||||
Ok(())
|
.map(|m| (&m.db, &m.id, m.status))
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if args
|
||||||
|
.get(3)
|
||||||
|
.is_some_and(|s| s == "--apply" || s == "--sql-only")
|
||||||
|
{
|
||||||
|
assert!(
|
||||||
|
root.file_name()
|
||||||
|
.unwrap()
|
||||||
|
.to_string_lossy()
|
||||||
|
.starts_with("update-database-diagnosis-")
|
||||||
|
&& root.join(".coa-update-fixture").is_file(),
|
||||||
|
"Only disposable fixture roots may be changed"
|
||||||
|
);
|
||||||
|
if args[3] == "--sql-only" {
|
||||||
|
let db = Db::from_repack(root, Account::Admin)?.for_realm(Mode::Coa);
|
||||||
|
let identity = || -> coa_core::Result<String> {
|
||||||
|
let mut rows = String::new();
|
||||||
|
for (schema, table, columns) in [
|
||||||
|
("acore_auth", "account", "id,HEX(username)"),
|
||||||
|
("acore_characters", "characters", "guid,account,HEX(name)"),
|
||||||
|
(
|
||||||
|
"acore_characters_wildcard",
|
||||||
|
"characters",
|
||||||
|
"guid,account,HEX(name)",
|
||||||
|
),
|
||||||
|
] {
|
||||||
|
rows.push_str(schema);
|
||||||
|
rows.push_str(&db.query(&format!(
|
||||||
|
"SELECT {columns} FROM {schema}.{table} ORDER BY 1;"
|
||||||
|
))?);
|
||||||
|
}
|
||||||
|
Ok(coa_core::fsx::sha256_bytes(rows.as_bytes()))
|
||||||
|
};
|
||||||
|
let before = identity()?;
|
||||||
|
migrations::verify_files(&manifest.migrations, std::path::Path::new(&args[4]))?;
|
||||||
|
for (index, mode) in [Mode::Coa, Mode::Wildcard].into_iter().enumerate() {
|
||||||
|
let realm_db = db.clone().for_realm(mode);
|
||||||
|
let list: Vec<_> = manifest
|
||||||
|
.migrations
|
||||||
|
.iter()
|
||||||
|
.filter(|m| index == 0 || m.db != "auth")
|
||||||
|
.cloned()
|
||||||
|
.collect();
|
||||||
|
let result = migrations::apply_pending(
|
||||||
|
&realm_db,
|
||||||
|
&list,
|
||||||
|
std::path::Path::new(&args[4]),
|
||||||
|
&|| Ok("disposable fixture".into()),
|
||||||
|
)?;
|
||||||
|
println!(
|
||||||
|
"{} SQL result: {}",
|
||||||
|
mode.name(),
|
||||||
|
serde_json::to_string(&result)?
|
||||||
|
);
|
||||||
|
if result.failed.is_some() {
|
||||||
|
return Err("SQL failed; fixture preserved".into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert_eq!(before, identity()?, "Account or character identity changed");
|
||||||
|
println!("Account and character identities preserved: {}", before);
|
||||||
|
let capture = root.join("captured-schema");
|
||||||
|
coa_core::schema_check::capture(&db, &capture)?;
|
||||||
|
println!(
|
||||||
|
"Captured schema SHA256: {}",
|
||||||
|
coa_core::fsx::sha256_file(&capture.join(coa_core::schema_check::CONTRACT))?
|
||||||
|
);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
if args.len() != 5 {
|
||||||
|
return Err("Migration directory required".into());
|
||||||
|
}
|
||||||
|
use coa_core::update::{Env, RepackEnv};
|
||||||
|
let meta = coa_core::registry::metadata_dir_for(root)?;
|
||||||
|
let env = RepackEnv {
|
||||||
|
root,
|
||||||
|
meta_dir: &meta,
|
||||||
|
};
|
||||||
|
let result = env.migrate(&manifest, std::path::Path::new(&args[4]));
|
||||||
|
let _ = coa_core::driver::run(root, coa_core::driver::Verb::StopAll);
|
||||||
|
println!("Application result: {}", serde_json::to_string(&result?)?);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -7,19 +7,48 @@ use ed25519_dalek::{Signer, SigningKey};
|
|||||||
fn main() {
|
fn main() {
|
||||||
let a: Vec<String> = std::env::args().skip(1).collect();
|
let a: Vec<String> = std::env::args().skip(1).collect();
|
||||||
let out = std::path::PathBuf::from(&a[0]);
|
let out = std::path::PathBuf::from(&a[0]);
|
||||||
let src = out.with_file_name(format!("{}-src", out.file_name().unwrap().to_string_lossy()));
|
let src = out.with_file_name(format!(
|
||||||
|
"{}-src",
|
||||||
|
out.file_name().unwrap().to_string_lossy()
|
||||||
|
));
|
||||||
let _ = std::fs::remove_dir_all(&src);
|
let _ = std::fs::remove_dir_all(&src);
|
||||||
let _ = std::fs::remove_dir_all(&out);
|
let _ = std::fs::remove_dir_all(&out);
|
||||||
for spec in &a[2..] {
|
for spec in &a[2..] {
|
||||||
let (p, c) = spec.split_once('=').expect("path=content");
|
let (p, c) = spec.split_once('=').expect("path=content");
|
||||||
let f = src.join(p);
|
let f = src.join(p);
|
||||||
std::fs::create_dir_all(f.parent().unwrap()).unwrap();
|
std::fs::create_dir_all(f.parent().unwrap()).unwrap();
|
||||||
std::fs::write(f, c.replace("\n", "\n")).unwrap();
|
std::fs::write(f, c.replace("\\n", "\n")).unwrap();
|
||||||
}
|
}
|
||||||
build(&src, &out, &BuildOptions { kind: Kind::Update, version: a[1].clone(), core_commit: None, built_at: chrono::Utc::now().to_rfc3339(), part_size: 1 << 20, bots_commit: None, migrations: vec![] }, &|_| {}).unwrap();
|
build(
|
||||||
let key = format!("{}/.coa-manager/signing/manifest-signing.key", std::env::var("USERPROFILE").unwrap());
|
&src,
|
||||||
let seed: [u8; 32] = STANDARD.decode(std::fs::read_to_string(key).unwrap().trim()).unwrap().try_into().unwrap();
|
&out,
|
||||||
let sig = SigningKey::from_bytes(&seed).sign(&std::fs::read(out.join("manifest.json")).unwrap());
|
&BuildOptions {
|
||||||
std::fs::write(out.join("manifest.json.sig"), STANDARD.encode(sig.to_bytes())).unwrap();
|
kind: Kind::Update,
|
||||||
|
version: a[1].clone(),
|
||||||
|
core_commit: None,
|
||||||
|
built_at: chrono::Utc::now().to_rfc3339(),
|
||||||
|
part_size: 1 << 20,
|
||||||
|
bots_commit: None,
|
||||||
|
migrations: vec![],
|
||||||
|
},
|
||||||
|
&|_| {},
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let key = format!(
|
||||||
|
"{}/.coa-manager/signing/manifest-signing.key",
|
||||||
|
std::env::var("USERPROFILE").unwrap()
|
||||||
|
);
|
||||||
|
let seed: [u8; 32] = STANDARD
|
||||||
|
.decode(std::fs::read_to_string(key).unwrap().trim())
|
||||||
|
.unwrap()
|
||||||
|
.try_into()
|
||||||
|
.unwrap();
|
||||||
|
let sig =
|
||||||
|
SigningKey::from_bytes(&seed).sign(&std::fs::read(out.join("manifest.json")).unwrap());
|
||||||
|
std::fs::write(
|
||||||
|
out.join("manifest.json.sig"),
|
||||||
|
STANDARD.encode(sig.to_bytes()),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
println!("package {} at {}", a[1], out.display());
|
println!("package {} at {}", a[1], out.display());
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,40 @@
|
|||||||
//! Probe only a disposable fixture: enable both worlds, verify isolation, gracefully stop both.
|
//! Probe only a disposable fixture: enable both worlds, verify isolation, gracefully stop both.
|
||||||
use coa_core::{Error, Result, driver::{self, Verb}, realms::{self, Mode}, multiworld, process::{self, ServiceState}};
|
use coa_core::{
|
||||||
|
driver::{self, Verb},
|
||||||
|
multiworld,
|
||||||
|
process::{self, ServiceState},
|
||||||
|
realms::{self, Mode},
|
||||||
|
Error, Result,
|
||||||
|
};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let root = PathBuf::from(std::env::args().nth(1).ok_or_else(|| Error::Invalid("fixture path required".into()))?);
|
let root = PathBuf::from(
|
||||||
if !root.file_name().is_some_and(|n| n.to_string_lossy().contains("fixture")) { return Err(Error::Invalid("Refusing a non-fixture server.".into())); }
|
std::env::args()
|
||||||
|
.nth(1)
|
||||||
|
.ok_or_else(|| Error::Invalid("fixture path required".into()))?,
|
||||||
|
);
|
||||||
|
if !root
|
||||||
|
.file_name()
|
||||||
|
.is_some_and(|n| n.to_string_lossy().contains("fixture"))
|
||||||
|
{
|
||||||
|
return Err(Error::Invalid("Refusing a non-fixture server.".into()));
|
||||||
|
}
|
||||||
let action = std::env::args().nth(2).unwrap_or_else(|| "smoke".into());
|
let action = std::env::args().nth(2).unwrap_or_else(|| "smoke".into());
|
||||||
if action == "stop" { driver::run(&root, Verb::StopAll)?; return Ok(()); }
|
if action == "stop" {
|
||||||
|
driver::run(&root, Verb::StopAll)?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
driver::run(&root, Verb::StopAll)?;
|
driver::run(&root, Verb::StopAll)?;
|
||||||
if action == "wildcard" { realms::select(&root, Mode::Wildcard)?; }
|
if action == "wildcard" {
|
||||||
|
realms::select(&root, Mode::Wildcard)?;
|
||||||
|
}
|
||||||
multiworld::set_enabled(&root, true)?;
|
multiworld::set_enabled(&root, true)?;
|
||||||
let result = (|| {
|
let result = (|| {
|
||||||
let out = driver::run(&root, Verb::StartAll)?;
|
let out = driver::run(&root, Verb::StartAll)?;
|
||||||
if !out.ok { return Err(Error::Invalid(out.output)); }
|
if !out.ok {
|
||||||
|
return Err(Error::Invalid(out.output));
|
||||||
|
}
|
||||||
let first = process::observe(&root, &coa_core::layout::read_ports(&root));
|
let first = process::observe(&root, &coa_core::layout::read_ports(&root));
|
||||||
let second_root = multiworld::root(&root);
|
let second_root = multiworld::root(&root);
|
||||||
let second = process::observe(&second_root, &coa_core::layout::read_ports(&second_root));
|
let second = process::observe(&second_root, &coa_core::layout::read_ports(&second_root));
|
||||||
@@ -22,21 +44,32 @@ fn main() -> Result<()> {
|
|||||||
assert_ne!(first.world.port, second.world.port);
|
assert_ne!(first.world.port, second.world.port);
|
||||||
assert!(second.mysql.pid.is_none() && second.auth.pid.is_none());
|
assert!(second.mysql.pid.is_none() && second.auth.pid.is_none());
|
||||||
let db = coa_core::db::Db::from_repack(&root, coa_core::db::Account::Admin)?;
|
let db = coa_core::db::Db::from_repack(&root, coa_core::db::Account::Admin)?;
|
||||||
let realms = db.query("SELECT id,port,flag FROM acore_auth.realmlist WHERE id IN (1,2) ORDER BY id;")?;
|
let realms = db.query(
|
||||||
|
"SELECT id,port,flag FROM acore_auth.realmlist WHERE id IN (1,2) ORDER BY id;",
|
||||||
|
)?;
|
||||||
println!("Two distinct world PIDs; shared auth/MySQL; realm rows:\n{realms}");
|
println!("Two distinct world PIDs; shared auth/MySQL; realm rows:\n{realms}");
|
||||||
for mode in [Mode::Coa, Mode::Wildcard] {
|
for mode in [Mode::Coa, Mode::Wildcard] {
|
||||||
let problems = coa_core::schema_check::check(&db.clone().for_realm(mode), &root)?;
|
let problems = coa_core::schema_check::check(&db.clone().for_realm(mode), &root)?;
|
||||||
println!("{}: {} database problems", mode.name(), problems.len());
|
println!("{}: {} database problems", mode.name(), problems.len());
|
||||||
for p in problems.iter().take(5) { println!("{}.{}.{}: {}", p.database, p.table, p.column, p.detail); }
|
for p in problems.iter().take(5) {
|
||||||
|
println!("{}.{}.{}: {}", p.database, p.table, p.column, p.detail);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert!(multiworld::set_enabled(&root, false).is_err());
|
assert!(multiworld::set_enabled(&root, false).is_err());
|
||||||
assert!(realms::select(&root, Mode::Wildcard).is_err());
|
assert!(realms::select(&root, Mode::Wildcard).is_err());
|
||||||
Ok(())
|
Ok(())
|
||||||
})();
|
})();
|
||||||
let stopped = driver::run(&root, Verb::StopAll)?;
|
let stopped = driver::run(&root, Verb::StopAll)?;
|
||||||
if !stopped.ok { return Err(Error::Invalid(stopped.output)); }
|
if !stopped.ok {
|
||||||
|
return Err(Error::Invalid(stopped.output));
|
||||||
|
}
|
||||||
assert!(!multiworld::is_running(&root));
|
assert!(!multiworld::is_running(&root));
|
||||||
assert_eq!(process::observe(&root, &coa_core::layout::read_ports(&root)).mysql.state, ServiceState::Stopped);
|
assert_eq!(
|
||||||
|
process::observe(&root, &coa_core::layout::read_ports(&root))
|
||||||
|
.mysql
|
||||||
|
.state,
|
||||||
|
ServiceState::Stopped
|
||||||
|
);
|
||||||
result?;
|
result?;
|
||||||
println!("Both worlds shut down before the shared database.");
|
println!("Both worlds shut down before the shared database.");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -3,12 +3,19 @@ fn main() {
|
|||||||
let ports = coa_core::layout::read_ports(std::path::Path::new(&root));
|
let ports = coa_core::layout::read_ports(std::path::Path::new(&root));
|
||||||
println!("LAN address: {:?}", coa_core::net::lan_ip());
|
println!("LAN address: {:?}", coa_core::net::lan_ip());
|
||||||
for e in coa_core::net::exposure(&ports) {
|
for e in coa_core::net::exposure(&ports) {
|
||||||
println!("{:<14} port {:<5} listening={} reachable_from_network={}", e.what, e.port, e.listening, e.reachable_from_network);
|
println!(
|
||||||
|
"{:<14} port {:<5} listening={} reachable_from_network={}",
|
||||||
|
e.what, e.port, e.listening, e.reachable_from_network
|
||||||
|
);
|
||||||
}
|
}
|
||||||
println!("{:?}", coa_core::net::tailscale());
|
println!("{:?}", coa_core::net::tailscale());
|
||||||
println!("firewall rules: {:?}", coa_core::firewall::status());
|
println!("firewall rules: {:?}", coa_core::firewall::status());
|
||||||
match coa_core::upnp::discover() {
|
match coa_core::upnp::discover() {
|
||||||
Some(gw) => println!("UPnP router: {} -> outside address {:?}", gw.control_url, coa_core::upnp::external_ip(&gw)),
|
Some(gw) => println!(
|
||||||
|
"UPnP router: {} -> outside address {:?}",
|
||||||
|
gw.control_url,
|
||||||
|
coa_core::upnp::external_ip(&gw)
|
||||||
|
),
|
||||||
None => println!("UPnP router: none answered"),
|
None => println!("UPnP router: none answered"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,680 @@
|
|||||||
|
//! Command-line harness for the portable-characters round trip, for manual smoke tests against a **disposable** realm database.
|
||||||
|
//! It performs exactly the operations the Manager performs (`coa_core::portable::realm`), one per invocation, with a Manager
|
||||||
|
//! store kept in a directory of your choice. It is not a user interface and not part of the shipped Manager.
|
||||||
|
//!
|
||||||
|
//! ```text
|
||||||
|
//! portable_smoke --tools <mysql bin dir> --port <port> --store <dir> [--user root] [--realm coa] <command> [args]
|
||||||
|
//! the database password is read from the environment variable COA_DB_PASSWORD
|
||||||
|
//!
|
||||||
|
//! commands
|
||||||
|
//! list characters of the realm and why they cannot be exported
|
||||||
|
//! make-portable <server-id> <guid> export an offline character into the store (revision 1)
|
||||||
|
//! import <character-id> <server-id> <account> create the character on a STOPPED realm
|
||||||
|
//! begin-session <character-id> <server-id> freeze B0: run it after the realm's first load/save, before play
|
||||||
|
//! reconcile <character-id> <server-id> [--close] bring what was played back into the store
|
||||||
|
//! update <character-id> <server-id> bring the realm's own character to the newest revision, in place
|
||||||
|
//! recover <server-id> finish or abort interrupted imports and updates
|
||||||
|
//! show <character-id> revisions and realm bindings
|
||||||
|
//! session-offer <character-id> <server-id> <offer.json> (owner store) offer a character and open its runtime session
|
||||||
|
//! session-import <offer.json> <account> <server-id> (host store: --host-store) keep the copy, import it with the session
|
||||||
|
//! armed (online through the core's import service when --ra-port and --job-dir are given, else offline)
|
||||||
|
//! host-run <owner-store-dir> <server-id> (host store) run the Host: automatic baseline, a checkpoint every
|
||||||
|
//! --interval seconds (default 60), the final checkpoint at logout; messages go straight to the owner store
|
||||||
|
//! dump <character-id> the canonical JSON of the current revision (what a core import job carries)
|
||||||
|
//! collection-states <out.json> (owner store) the canonical account collections as messages
|
||||||
|
//! collection-apply <states.json> <account> <server-id> write the canonical collections to the realm account (known ids only, INSERT IGNORE)
|
||||||
|
//! capabilities <server-id> the realm's content profile (from its core when --ra-port is given), remembered in the store
|
||||||
|
//! preflight <character-id> <server-id> [online|session] what would happen to the character on that realm, before anything is written
|
||||||
|
//! reevaluate <character-id> <server-id> look again at what was held back when the realm's content profile changed (realm stopped)
|
||||||
|
//! collection-add <kind> <id>... (owner store) add ids to a profile collection by hand (a test aid)
|
||||||
|
//! collection-show [<account>] the Owner's collections (revision, count, hash) and, with an account, the realm's
|
||||||
|
//! project <character-id> <server-id> ask the realm's running core what a level-cap projection of the character holds (needs --ra-port
|
||||||
|
//! and --job-dir); --out <file> writes the decision, which a later `import`/`update` of a STOPPED realm can be given with
|
||||||
|
//! --projection <file> (it answers only for the exact state of the character it was made for)
|
||||||
|
//!
|
||||||
|
//! --collection-interval <seconds> how often host-run looks at the account collections (default 300; a session start and the final
|
||||||
|
//! checkpoint always look)
|
||||||
|
//! --data-dir <realm Data dir> the destination's client data (Appearances.dbc, VanityCollection.dbc): without it no selected
|
||||||
|
//! appearance and no collection is written to the realm (everything stays canonical)
|
||||||
|
//! ```
|
||||||
|
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use coa_core::db::Db;
|
||||||
|
use coa_core::portable::realm::{self, ImportOptions};
|
||||||
|
use coa_core::portable::session::live::LiveBridge;
|
||||||
|
use coa_core::portable::session::protocol::SessionOffer;
|
||||||
|
use coa_core::portable::session::{HostConfig, HostService, OwnerService};
|
||||||
|
use coa_core::portable::{CharacterId, Store};
|
||||||
|
use coa_core::realms::Mode;
|
||||||
|
|
||||||
|
/// The options of a command, with the realm's content profile: assembled from its schema, its client data and (given an RA port) its
|
||||||
|
/// core, and remembered in the store. Without `--data-dir` there is no profile and nothing is evaluated.
|
||||||
|
fn with_profile(
|
||||||
|
db: &Db,
|
||||||
|
store: &mut Store,
|
||||||
|
base: &ImportOptions,
|
||||||
|
data_dir: &str,
|
||||||
|
ra_port: Option<u16>,
|
||||||
|
ra_user: &str,
|
||||||
|
server: &str,
|
||||||
|
) -> Result<ImportOptions, String> {
|
||||||
|
if data_dir.is_empty() {
|
||||||
|
return Ok(base.clone());
|
||||||
|
}
|
||||||
|
let registry = coa_core::portable::extension::ExtensionRegistry::new();
|
||||||
|
let mut ra = ra_port.and_then(|port| {
|
||||||
|
std::env::var("COA_RA_PASSWORD")
|
||||||
|
.ok()
|
||||||
|
.and_then(|pw| coa_core::ra::Ra::connect_to(port, ra_user, &pw).ok())
|
||||||
|
});
|
||||||
|
let mut caps = realm::profile::probe_capabilities(
|
||||||
|
db,
|
||||||
|
Some(std::path::Path::new(data_dir)),
|
||||||
|
ra.as_mut(),
|
||||||
|
®istry,
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
if ra.is_none() {
|
||||||
|
let remembered = store.realm_profile(server).map_err(|e| e.to_string())?;
|
||||||
|
caps = realm::profile::with_remembered_progression(caps, remembered.as_ref())
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
if caps.progression.is_none() {
|
||||||
|
eprintln!("realm {server}: its progression (level cap) has never been read from a running core: start it once and run `capabilities` with --ra-port");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let change = store
|
||||||
|
.set_realm_profile(server, &caps, if ra.is_some() { "live" } else { "offline" })
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
eprintln!(
|
||||||
|
"realm {server}: content profile {}{}",
|
||||||
|
&caps.content_profile_hash[..16],
|
||||||
|
if change.changed() {
|
||||||
|
" (new or changed)"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
);
|
||||||
|
Ok(ImportOptions {
|
||||||
|
capabilities: Some(std::sync::Arc::new(caps)),
|
||||||
|
extensions: Some(std::sync::Arc::new(registry)),
|
||||||
|
..base.clone()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage() -> ! {
|
||||||
|
eprintln!(
|
||||||
|
"{}",
|
||||||
|
include_str!("portable_smoke.rs")
|
||||||
|
.lines()
|
||||||
|
.take_while(|l| l.starts_with("//!"))
|
||||||
|
.map(|l| l.trim_start_matches("//!").trim_start_matches(' '))
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\n")
|
||||||
|
);
|
||||||
|
std::process::exit(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
if let Err(e) = run() {
|
||||||
|
eprintln!("error: {e}");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run() -> Result<(), String> {
|
||||||
|
let mut args: Vec<String> = std::env::args().skip(1).collect();
|
||||||
|
let mut take = |name: &str, default: Option<&str>| -> Result<String, String> {
|
||||||
|
if let Some(i) = args.iter().position(|a| a == name) {
|
||||||
|
if i + 1 >= args.len() {
|
||||||
|
return Err(format!("{name} needs a value"));
|
||||||
|
}
|
||||||
|
let v = args.remove(i + 1);
|
||||||
|
args.remove(i);
|
||||||
|
return Ok(v);
|
||||||
|
}
|
||||||
|
default
|
||||||
|
.map(str::to_string)
|
||||||
|
.ok_or_else(|| format!("{name} is required"))
|
||||||
|
};
|
||||||
|
let tools = PathBuf::from(take("--tools", None)?);
|
||||||
|
let port: u16 = take("--port", None)?
|
||||||
|
.parse()
|
||||||
|
.map_err(|_| "--port is not a number".to_string())?;
|
||||||
|
let store_dir = PathBuf::from(take("--store", None)?);
|
||||||
|
let user = take("--user", Some("root"))?;
|
||||||
|
let realm_mode = match take("--realm", Some("coa"))?.as_str() {
|
||||||
|
"coa" => Mode::Coa,
|
||||||
|
other => {
|
||||||
|
return Err(format!(
|
||||||
|
"--realm {other}: only coa is supported (Wildcard portable transfer is not supported)"
|
||||||
|
))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let password =
|
||||||
|
std::env::var("COA_DB_PASSWORD").map_err(|_| "set COA_DB_PASSWORD".to_string())?;
|
||||||
|
// `with_tools` takes a 'static user name; this is a short-lived process
|
||||||
|
let user: &'static str = Box::leak(user.into_boxed_str());
|
||||||
|
let db = Db::with_tools(tools, port, user, &password, realm_mode);
|
||||||
|
let mut store = Store::open(&store_dir).map_err(|e| e.to_string())?;
|
||||||
|
let data_dir = take("--data-dir", Some(""))?;
|
||||||
|
let knowledge = match data_dir.as_str() {
|
||||||
|
"" => None,
|
||||||
|
dir => Some(std::sync::Arc::new(
|
||||||
|
coa_core::portable::realm::knowledge::RealmKnowledge::from_data_dir(
|
||||||
|
std::path::Path::new(dir),
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?,
|
||||||
|
)),
|
||||||
|
};
|
||||||
|
let projection_file = take("--projection", Some(""))?;
|
||||||
|
let out_file = take("--out", Some(""))?;
|
||||||
|
let supplied = match projection_file.as_str() {
|
||||||
|
"" => None,
|
||||||
|
file => {
|
||||||
|
let hold: coa_core::portable::projection::ProjectionHold =
|
||||||
|
serde_json::from_slice(&std::fs::read(file).map_err(|e| e.to_string())?)
|
||||||
|
.map_err(|e| format!("{file}: {e}"))?;
|
||||||
|
Some(coa_core::portable::projection::Oracle(std::sync::Arc::new(
|
||||||
|
coa_core::portable::projection::SuppliedDecision(hold),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let opts = ImportOptions {
|
||||||
|
game_server_users: vec![user.to_string(), "acore".to_string()],
|
||||||
|
knowledge: knowledge.clone(),
|
||||||
|
projection: supplied,
|
||||||
|
..ImportOptions::default()
|
||||||
|
};
|
||||||
|
let host_dir = PathBuf::from(take(
|
||||||
|
"--host-store",
|
||||||
|
Some(&format!("{}-host", store_dir.display())),
|
||||||
|
)?);
|
||||||
|
let ra_port: Option<u16> = take("--ra-port", Some("0"))?
|
||||||
|
.parse()
|
||||||
|
.ok()
|
||||||
|
.filter(|p| *p != 0);
|
||||||
|
let ra_user = take("--ra-user", Some("local"))?;
|
||||||
|
let job_dir = take("--job-dir", Some(""))?;
|
||||||
|
let profile_for = |db: &Db, store: &mut Store, server: &str| -> Result<ImportOptions, String> {
|
||||||
|
with_profile(db, store, &opts, &data_dir, ra_port, &ra_user, server)
|
||||||
|
};
|
||||||
|
let interval: u64 = take("--interval", Some("60"))?
|
||||||
|
.parse()
|
||||||
|
.map_err(|_| "--interval is not a number".to_string())?;
|
||||||
|
let collection_interval: u64 = take("--collection-interval", Some("300"))?
|
||||||
|
.parse()
|
||||||
|
.map_err(|_| "--collection-interval is not a number".to_string())?;
|
||||||
|
let id = |s: &str| -> Result<CharacterId, String> {
|
||||||
|
s.parse()
|
||||||
|
.map_err(|_| format!("{s:?} is not a character id"))
|
||||||
|
};
|
||||||
|
|
||||||
|
let command = if args.is_empty() {
|
||||||
|
usage()
|
||||||
|
} else {
|
||||||
|
args.remove(0)
|
||||||
|
};
|
||||||
|
match (command.as_str(), args.as_slice()) {
|
||||||
|
("list", []) => {
|
||||||
|
for c in realm::inspect_characters(&db).map_err(|e| e.to_string())? {
|
||||||
|
println!(
|
||||||
|
"{}\t{}\tlevel {}\trace {} class {}\t{}",
|
||||||
|
c.local_guid,
|
||||||
|
c.name,
|
||||||
|
c.level,
|
||||||
|
c.race,
|
||||||
|
c.class,
|
||||||
|
if c.eligible() {
|
||||||
|
"ok".to_string()
|
||||||
|
} else {
|
||||||
|
c.blockers
|
||||||
|
.iter()
|
||||||
|
.map(|b| b.to_string())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("; ")
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
("make-portable", [server, guid]) => {
|
||||||
|
let profile = store.default_profile().map_err(|e| e.to_string())?;
|
||||||
|
let made = realm::make_portable(
|
||||||
|
&db,
|
||||||
|
&mut store,
|
||||||
|
profile,
|
||||||
|
server,
|
||||||
|
guid.parse().map_err(|_| "guid")?,
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
println!(
|
||||||
|
"portable character {} (revision {}) {}",
|
||||||
|
made.character_id,
|
||||||
|
made.revision,
|
||||||
|
made.warnings.join("; ")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
("import", [character, server, account]) => {
|
||||||
|
let opts = profile_for(&db, &mut store, server)?;
|
||||||
|
let o = realm::import_character(
|
||||||
|
&db,
|
||||||
|
&mut store,
|
||||||
|
id(character)?,
|
||||||
|
server,
|
||||||
|
account.parse().map_err(|_| "account")?,
|
||||||
|
&opts,
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
for line in &o.not_applied {
|
||||||
|
println!(" not applied: {line}");
|
||||||
|
}
|
||||||
|
println!(
|
||||||
|
"imported as local character {} \"{}\" ({} items, {} pets, renamed: {})",
|
||||||
|
o.local_guid, o.final_name, o.items, o.pets, o.renamed
|
||||||
|
);
|
||||||
|
}
|
||||||
|
("begin-session", [character, server]) => {
|
||||||
|
let s = realm::begin_session(&db, &mut store, id(character)?, server)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
println!("baseline captured at canonical revision {}: {} item(s) held back by the realm, {} of its own", s.c0_revision, s.items_filtered, s.items_realm_local);
|
||||||
|
}
|
||||||
|
("reconcile", [character, server, rest @ ..]) => {
|
||||||
|
let close = rest.iter().any(|a| a == "--close");
|
||||||
|
let o = realm::reconcile_session(
|
||||||
|
&db,
|
||||||
|
&mut store,
|
||||||
|
id(character)?,
|
||||||
|
server,
|
||||||
|
close,
|
||||||
|
Some("portable_smoke"),
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
println!(
|
||||||
|
"canonical revision {}{}",
|
||||||
|
o.revision,
|
||||||
|
if o.new_revision {
|
||||||
|
" (new)"
|
||||||
|
} else {
|
||||||
|
" (unchanged)"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
for c in o.changes {
|
||||||
|
println!(" {c}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
("update", [character, server]) => {
|
||||||
|
let opts = profile_for(&db, &mut store, server)?;
|
||||||
|
let o = realm::update_realm_character(&db, &mut store, id(character)?, server, &opts)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
for line in &o.warnings {
|
||||||
|
println!(" {line}");
|
||||||
|
}
|
||||||
|
println!(
|
||||||
|
"{} (revision {} -> {}): {:?}",
|
||||||
|
if o.updated {
|
||||||
|
"updated in place"
|
||||||
|
} else {
|
||||||
|
"already up to date"
|
||||||
|
},
|
||||||
|
o.from_revision,
|
||||||
|
o.to_revision,
|
||||||
|
o.counts
|
||||||
|
);
|
||||||
|
}
|
||||||
|
("recover", [server]) => {
|
||||||
|
for r in
|
||||||
|
realm::recover_imports(&db, &mut store, server, &opts).map_err(|e| e.to_string())?
|
||||||
|
{
|
||||||
|
println!("{}: {:?}", r.import_id, r.resolution);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
("session-offer", [character, server, out]) => {
|
||||||
|
let offer = OwnerService::new(&mut store)
|
||||||
|
.offer(id(character)?, server)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
std::fs::write(
|
||||||
|
out,
|
||||||
|
serde_json::to_vec_pretty(&offer).map_err(|e| e.to_string())?,
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
println!(
|
||||||
|
"session {} offered at canonical revision {} -> {out}",
|
||||||
|
offer.session_id, offer.canonical_revision
|
||||||
|
);
|
||||||
|
}
|
||||||
|
("session-import", [file, account, server]) => {
|
||||||
|
let offer: SessionOffer =
|
||||||
|
serde_json::from_slice(&std::fs::read(file).map_err(|e| e.to_string())?)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
let mut host = Store::open(&host_dir).map_err(|e| e.to_string())?;
|
||||||
|
let profile = host.default_profile().map_err(|e| e.to_string())?;
|
||||||
|
HostService::new(&mut host, server, HostConfig::default())
|
||||||
|
.accept_offer(profile, &offer)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
let account: u32 = account.parse().map_err(|_| "account")?;
|
||||||
|
let opts = with_profile(&db, &mut host, &opts, &data_dir, ra_port, &ra_user, server)?;
|
||||||
|
let outcome = match (ra_port, job_dir.is_empty()) {
|
||||||
|
(Some(port), false) => {
|
||||||
|
let mut ra = coa_core::ra::Ra::connect_to(
|
||||||
|
port,
|
||||||
|
&ra_user,
|
||||||
|
&std::env::var("COA_RA_PASSWORD")
|
||||||
|
.map_err(|_| "set COA_RA_PASSWORD".to_string())?,
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
realm::online::import_character_online(
|
||||||
|
&mut ra,
|
||||||
|
&mut host,
|
||||||
|
offer.character_id,
|
||||||
|
server,
|
||||||
|
account,
|
||||||
|
&opts,
|
||||||
|
std::path::Path::new(&job_dir),
|
||||||
|
Some(offer.session_id),
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?
|
||||||
|
}
|
||||||
|
_ => realm::import_character_in_session(
|
||||||
|
&db,
|
||||||
|
&mut host,
|
||||||
|
offer.character_id,
|
||||||
|
server,
|
||||||
|
account,
|
||||||
|
&opts,
|
||||||
|
Some(offer.session_id),
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?,
|
||||||
|
};
|
||||||
|
HostService::new(&mut host, server, HostConfig::default())
|
||||||
|
.bind(offer.session_id, outcome.local_guid)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
println!("imported as local character {} \"{}\"; session {} is armed: the realm takes the baseline at its first load", outcome.local_guid, outcome.final_name, offer.session_id);
|
||||||
|
}
|
||||||
|
("host-run", [owner_dir, server]) => {
|
||||||
|
let mut owner = Store::open(&PathBuf::from(owner_dir)).map_err(|e| e.to_string())?;
|
||||||
|
let mut host = Store::open(&host_dir).map_err(|e| e.to_string())?;
|
||||||
|
let mut service = HostService::new(
|
||||||
|
&mut host,
|
||||||
|
server,
|
||||||
|
HostConfig {
|
||||||
|
checkpoint_interval_secs: interval,
|
||||||
|
collection_interval_secs: collection_interval,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
let start = std::time::Instant::now();
|
||||||
|
println!("host running for {server}; Ctrl-C to stop");
|
||||||
|
loop {
|
||||||
|
let ra = ra_port.and_then(|port| {
|
||||||
|
std::env::var("COA_RA_PASSWORD")
|
||||||
|
.ok()
|
||||||
|
.and_then(|pw| coa_core::ra::Ra::connect_to(port, &ra_user, &pw).ok())
|
||||||
|
});
|
||||||
|
let mut bridge = match ra {
|
||||||
|
Some(ra) => LiveBridge::new(&db, ra),
|
||||||
|
None => LiveBridge::without_console(&db),
|
||||||
|
}
|
||||||
|
.with_knowledge(knowledge.clone());
|
||||||
|
match service.tick(&mut bridge, start.elapsed().as_secs()) {
|
||||||
|
Ok(events) => events.iter().for_each(|e| println!("{e:?}")),
|
||||||
|
Err(e) => eprintln!("tick failed: {e}"),
|
||||||
|
}
|
||||||
|
for m in service.outbox().map_err(|e| e.to_string())? {
|
||||||
|
let ack = if m.started {
|
||||||
|
OwnerService::new(&mut owner).handle_started(&m.bytes)
|
||||||
|
} else {
|
||||||
|
OwnerService::new(&mut owner).handle_checkpoint(&m.bytes)
|
||||||
|
};
|
||||||
|
match ack {
|
||||||
|
Ok(ack) => {
|
||||||
|
println!(
|
||||||
|
"owner: session {} #{}: {:?} (canonical revision {})",
|
||||||
|
ack.session_id, ack.sequence, ack.outcome, ack.canonical_revision
|
||||||
|
);
|
||||||
|
if let Err(e) = service.receive_ack(&mut bridge, &ack) {
|
||||||
|
eprintln!("acknowledgement failed: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => eprintln!("owner refused a message: {e}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for m in service.collection_outbox().map_err(|e| e.to_string())? {
|
||||||
|
match OwnerService::new(&mut owner).handle_collection(&m.bytes) {
|
||||||
|
Ok(ack) => {
|
||||||
|
println!("owner: {} of account {}: {:?} (collection revision {}, canonical sent back: {})", ack.kind, m.account, ack.outcome, ack.collection_revision, ack.canonical.is_some());
|
||||||
|
match service.receive_collection_ack(&mut bridge, m.account, &ack) {
|
||||||
|
Ok(Some(applied)) => {
|
||||||
|
println!("host: applied to the realm: {applied:?}")
|
||||||
|
}
|
||||||
|
Ok(None) => {}
|
||||||
|
Err(e) => eprintln!("collection acknowledgement failed: {e}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => eprintln!("owner refused a collection message: {e}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
("collection-states", [out]) => {
|
||||||
|
let states = OwnerService::new(&mut store)
|
||||||
|
.collection_states(coa_core::portable::Ruleset::Coa)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
for s in &states {
|
||||||
|
println!(
|
||||||
|
"{}: revision {}, {} ids",
|
||||||
|
s.kind, s.collection_revision, s.set.count
|
||||||
|
);
|
||||||
|
}
|
||||||
|
std::fs::write(out, serde_json::to_vec(&states).map_err(|e| e.to_string())?)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
}
|
||||||
|
("collection-apply", [file, account, server]) => {
|
||||||
|
let states: Vec<coa_core::portable::session::protocol::CollectionState> =
|
||||||
|
serde_json::from_slice(&std::fs::read(file).map_err(|e| e.to_string())?)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
let account: u32 = account.parse().map_err(|_| "account")?;
|
||||||
|
let mut host = Store::open(&host_dir).map_err(|e| e.to_string())?;
|
||||||
|
let mut bridge = LiveBridge::without_console(&db).with_knowledge(knowledge.clone());
|
||||||
|
let mut service = HostService::new(&mut host, server, HostConfig::default());
|
||||||
|
for state in &states {
|
||||||
|
let applied = service
|
||||||
|
.receive_collection_state(&mut bridge, account, state)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
println!("{}: {:?}", state.kind, applied);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
("capabilities", [server]) => {
|
||||||
|
let caps = profile_for(&db, &mut store, server)?
|
||||||
|
.capabilities
|
||||||
|
.ok_or("give --data-dir to read the realm's client data")?;
|
||||||
|
println!(
|
||||||
|
"{}",
|
||||||
|
serde_json::to_string_pretty(&*caps).map_err(|e| e.to_string())?
|
||||||
|
);
|
||||||
|
}
|
||||||
|
("preflight", [character, server, rest @ ..]) => {
|
||||||
|
let opts = profile_for(&db, &mut store, server)?;
|
||||||
|
let caps = opts
|
||||||
|
.capabilities
|
||||||
|
.clone()
|
||||||
|
.ok_or("give --data-dir to read the realm's client data")?;
|
||||||
|
let model = store
|
||||||
|
.load_current(id(character)?)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
let operation = match rest.first().map(String::as_str) {
|
||||||
|
Some("online") => coa_core::portable::compat::Operation::OnlineImport,
|
||||||
|
Some("session") => coa_core::portable::compat::Operation::RuntimeSession,
|
||||||
|
_ if store
|
||||||
|
.server_mappings(model.character_id)
|
||||||
|
.map_err(|e| e.to_string())?
|
||||||
|
.iter()
|
||||||
|
.any(|m| &m.server_id == server) =>
|
||||||
|
{
|
||||||
|
coa_core::portable::compat::Operation::Update
|
||||||
|
}
|
||||||
|
_ => coa_core::portable::compat::Operation::OfflineImport,
|
||||||
|
};
|
||||||
|
let report =
|
||||||
|
coa_core::portable::compat::evaluate(&coa_core::portable::compat::Inputs {
|
||||||
|
operation,
|
||||||
|
model: &model,
|
||||||
|
capabilities: &caps,
|
||||||
|
knowledge: opts.knowledge.as_deref(),
|
||||||
|
collections: &[],
|
||||||
|
extensions: opts.extensions.as_deref(),
|
||||||
|
projection_decider: opts.projection.is_some()
|
||||||
|
|| matches!(
|
||||||
|
operation,
|
||||||
|
coa_core::portable::compat::Operation::OnlineImport
|
||||||
|
| coa_core::portable::compat::Operation::RuntimeSession
|
||||||
|
) && ra_port.is_some(),
|
||||||
|
});
|
||||||
|
println!(
|
||||||
|
"{} on {server} (content profile {}): {:?}",
|
||||||
|
report.operation,
|
||||||
|
&caps.content_profile_hash[..16],
|
||||||
|
report.verdict()
|
||||||
|
);
|
||||||
|
for o in &report.outcomes {
|
||||||
|
println!(" {o}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
("project", [character, server]) => {
|
||||||
|
let port = ra_port
|
||||||
|
.ok_or("give --ra-port: only a running core can say what a projection holds")?;
|
||||||
|
if job_dir.is_empty() {
|
||||||
|
return Err("give --job-dir (the core's PortableImport.JobDir)".into());
|
||||||
|
}
|
||||||
|
let opts = profile_for(&db, &mut store, server)?;
|
||||||
|
let canonical = store
|
||||||
|
.load_current(id(character)?)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
let mut ra = coa_core::ra::Ra::connect_to(
|
||||||
|
port,
|
||||||
|
&ra_user,
|
||||||
|
&std::env::var("COA_RA_PASSWORD").map_err(|_| "set COA_RA_PASSWORD".to_string())?,
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
let progression = opts
|
||||||
|
.capabilities
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|c| c.progression.clone());
|
||||||
|
match realm::project::decide_with_core(
|
||||||
|
&mut ra,
|
||||||
|
std::path::Path::new(&job_dir),
|
||||||
|
&canonical,
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?
|
||||||
|
{
|
||||||
|
coa_core::portable::projection::Decision::Native => println!(
|
||||||
|
"not projected: level {} is within the realm's cap {}",
|
||||||
|
canonical.progression.level,
|
||||||
|
progression.map_or("?".to_string(), |p| p.max_player_level.to_string())
|
||||||
|
),
|
||||||
|
coa_core::portable::projection::Decision::Projected(hold) => {
|
||||||
|
println!(
|
||||||
|
"projected level {} -> {} (signature {})",
|
||||||
|
hold.canonical_level,
|
||||||
|
hold.projected_level,
|
||||||
|
&hold.progression_signature[..16]
|
||||||
|
);
|
||||||
|
println!(" held: {} item(s), {} ability(ies), {} button(s), {} build record(s) edited, {} blocked", hold.held_items.len(), hold.held_spells.len(), hold.held_actions.len(), hold.settings.iter().filter(|s| !s.entries.is_empty() || !s.buttons.is_empty()).count(), hold.blocked_settings.len());
|
||||||
|
if !out_file.is_empty() {
|
||||||
|
std::fs::write(
|
||||||
|
&out_file,
|
||||||
|
serde_json::to_vec_pretty(&hold).map_err(|e| e.to_string())?,
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
println!(" decision written to {out_file}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
("reevaluate", [character, server]) => {
|
||||||
|
let opts = profile_for(&db, &mut store, server)?;
|
||||||
|
let r =
|
||||||
|
realm::reevaluate_realm_character(&db, &mut store, id(character)?, server, &opts)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
if r.profile_unchanged {
|
||||||
|
println!("the realm's content profile is the one this character was synchronised under: nothing to look at");
|
||||||
|
} else {
|
||||||
|
println!(
|
||||||
|
"{}",
|
||||||
|
r.update
|
||||||
|
.map(|u| format!("restored: {:?}", u.changes))
|
||||||
|
.unwrap_or_else(|| "nothing new to show on this realm".into())
|
||||||
|
);
|
||||||
|
for e in r.extensions {
|
||||||
|
println!(" {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
("collection-add", [kind, ids @ ..]) => {
|
||||||
|
let profile = store.default_profile().map_err(|e| e.to_string())?;
|
||||||
|
let ids = ids
|
||||||
|
.iter()
|
||||||
|
.map(|i| i.parse::<u32>().map_err(|_| format!("{i:?} is not an id")))
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
let set =
|
||||||
|
coa_core::portable::collection::IdSet::from_ids(ids).map_err(|e| e.to_string())?;
|
||||||
|
let merge = store
|
||||||
|
.merge_collection(profile, coa_core::portable::Ruleset::Coa, kind, &set)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
println!(
|
||||||
|
"{kind}: {} id(s) added{}",
|
||||||
|
merge.added,
|
||||||
|
merge
|
||||||
|
.info
|
||||||
|
.map(|i| format!(", revision {}, {} ids", i.revision, i.count))
|
||||||
|
.unwrap_or_default()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
("collection-show", rest) => {
|
||||||
|
let profile = store.default_profile().map_err(|e| e.to_string())?;
|
||||||
|
for kind in coa_core::portable::session::protocol::COLLECTION_KINDS {
|
||||||
|
match store
|
||||||
|
.collection_info(profile, coa_core::portable::Ruleset::Coa, kind)
|
||||||
|
.map_err(|e| e.to_string())?
|
||||||
|
{
|
||||||
|
Some(i) => println!(
|
||||||
|
"owner {kind}: revision {}, {} ids, hash {}",
|
||||||
|
i.revision,
|
||||||
|
i.count,
|
||||||
|
hex::encode(&i.hash[..8])
|
||||||
|
),
|
||||||
|
None => println!("owner {kind}: none"),
|
||||||
|
}
|
||||||
|
if let [account] = rest {
|
||||||
|
let account: u32 = account.parse().map_err(|_| "account")?;
|
||||||
|
let set = coa_core::portable::realm::collections::read_set(&db, account, kind)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
println!("realm {kind} of account {account}: {} ids", set.len());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
("dump", [character]) => {
|
||||||
|
let model = store
|
||||||
|
.load_current(id(character)?)
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
let json =
|
||||||
|
coa_core::portable::snapshot::canonical_json(&model).map_err(|e| e.to_string())?;
|
||||||
|
println!("{}", String::from_utf8_lossy(&json));
|
||||||
|
}
|
||||||
|
("show", [character]) => {
|
||||||
|
let c = id(character)?;
|
||||||
|
let r = store.character(c).map_err(|e| e.to_string())?;
|
||||||
|
println!(
|
||||||
|
"{} {} level {} revision {}",
|
||||||
|
r.character_id, r.name, r.level, r.revision
|
||||||
|
);
|
||||||
|
for m in store.server_mappings(c).map_err(|e| e.to_string())? {
|
||||||
|
println!(
|
||||||
|
" on {}: local guid {} at revision {} ({:?})",
|
||||||
|
m.server_id, m.local_guid, m.last_revision, m.state
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => usage(),
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
//! Create an account through the Manager's RA client on a RUNNING disposable fixture.
|
//! Create an account through the Manager's RA client on a RUNNING disposable fixture.
|
||||||
fn main() {
|
fn main() {
|
||||||
let a: Vec<String> = std::env::args().skip(1).collect();
|
let a: Vec<String> = std::env::args().skip(1).collect();
|
||||||
assert!(a[0].to_lowercase().contains("fixture") || a[0].to_lowercase().contains("installtest") || a[0].to_lowercase().contains("cleaninstall"), "refusing: not a disposable folder");
|
assert!(
|
||||||
|
a[0].to_lowercase().contains("fixture")
|
||||||
|
|| a[0].to_lowercase().contains("installtest")
|
||||||
|
|| a[0].to_lowercase().contains("cleaninstall"),
|
||||||
|
"refusing: not a disposable folder"
|
||||||
|
);
|
||||||
let root = std::path::Path::new(&a[0]);
|
let root = std::path::Path::new(&a[0]);
|
||||||
let mut ra = coa_core::ra::Ra::connect(root).expect("connect");
|
let mut ra = coa_core::ra::Ra::connect(root).expect("connect");
|
||||||
ra.create_account(&a[1], &a[2]).expect("create");
|
ra.create_account(&a[1], &a[2]).expect("create");
|
||||||
|
|||||||
@@ -13,30 +13,69 @@ fn main() -> Result<()> {
|
|||||||
let action = args.get(1).map(String::as_str).unwrap_or("view");
|
let action = args.get(1).map(String::as_str).unwrap_or("view");
|
||||||
match action {
|
match action {
|
||||||
"select" => {
|
"select" => {
|
||||||
let mode = if args.get(2).map(String::as_str) == Some("wildcard") { Mode::Wildcard } else { Mode::Coa };
|
let mode = if args.get(2).map(String::as_str) == Some("wildcard") {
|
||||||
|
Mode::Wildcard
|
||||||
|
} else {
|
||||||
|
Mode::Coa
|
||||||
|
};
|
||||||
println!("{}", serde_json::to_string(&realms::select(root, mode)?)?);
|
println!("{}", serde_json::to_string(&realms::select(root, mode)?)?);
|
||||||
}
|
}
|
||||||
"start" | "stop" => {
|
"start" | "stop" => {
|
||||||
let out = driver::run(root, if action == "start" { Verb::StartAll } else { Verb::StopAll })?;
|
let out = driver::run(
|
||||||
|
root,
|
||||||
|
if action == "start" {
|
||||||
|
Verb::StartAll
|
||||||
|
} else {
|
||||||
|
Verb::StopAll
|
||||||
|
},
|
||||||
|
)?;
|
||||||
println!("{}", serde_json::to_string(&out)?);
|
println!("{}", serde_json::to_string(&out)?);
|
||||||
if !out.ok { return Err(Error::Invalid("Fixture operation failed".into())); }
|
if !out.ok {
|
||||||
|
return Err(Error::Invalid("Fixture operation failed".into()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"probe" => {
|
"probe" => {
|
||||||
let db = Db::from_repack(root, Account::Admin)?;
|
let db = Db::from_repack(root, Account::Admin)?;
|
||||||
let s = realms::state(root)?;
|
let s = realms::state(root)?;
|
||||||
println!("{}", db.query("SELECT * FROM acore_characters.manager_profile_probe;")?);
|
println!(
|
||||||
println!("active={} chars={} world={}", s.active.name(), s.active.schema("characters")?, s.active.schema("world")?);
|
"{}",
|
||||||
|
db.query("SELECT * FROM acore_characters.manager_profile_probe;")?
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"active={} chars={} world={}",
|
||||||
|
s.active.name(),
|
||||||
|
s.active.schema("characters")?,
|
||||||
|
s.active.schema("world")?
|
||||||
|
);
|
||||||
}
|
}
|
||||||
"mark" => {
|
"mark" => {
|
||||||
Db::from_repack(root, Account::Admin)?.query("INSERT INTO acore_characters.manager_profile_probe VALUES (22);")?;
|
Db::from_repack(root, Account::Admin)?
|
||||||
|
.query("INSERT INTO acore_characters.manager_profile_probe VALUES (22);")?;
|
||||||
}
|
}
|
||||||
"backup" => {
|
"backup" => {
|
||||||
use coa_core::backup::{self, Kind, Trigger};
|
use coa_core::backup::{self, Kind, Trigger};
|
||||||
let meta = root.join("fixture-manager");
|
let meta = root.join("fixture-manager");
|
||||||
let point = backup::create(root, &meta, Kind::Full, Trigger::Manual, Some("realm isolation check".into()), &|step| println!("{step}"))?;
|
let point = backup::create(
|
||||||
|
root,
|
||||||
|
&meta,
|
||||||
|
Kind::Full,
|
||||||
|
Trigger::Manual,
|
||||||
|
Some("realm isolation check".into()),
|
||||||
|
&|step| println!("{step}"),
|
||||||
|
)?;
|
||||||
assert_eq!(point.realm, Mode::Wildcard);
|
assert_eq!(point.realm, Mode::Wildcard);
|
||||||
for name in ["characters", "world", "auth", "coa-characters", "coa-world", "configs"] {
|
for name in [
|
||||||
assert!(point.components.iter().any(|c| c.name == name), "Missing {name}");
|
"characters",
|
||||||
|
"world",
|
||||||
|
"auth",
|
||||||
|
"coa-characters",
|
||||||
|
"coa-world",
|
||||||
|
"configs",
|
||||||
|
] {
|
||||||
|
assert!(
|
||||||
|
point.components.iter().any(|c| c.name == name),
|
||||||
|
"Missing {name}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
assert!(backup::verify(&meta, &point.id)?.ok);
|
assert!(backup::verify(&meta, &point.id)?.ok);
|
||||||
println!("Verified both realm backups: {}", point.id);
|
println!("Verified both realm backups: {}", point.id);
|
||||||
@@ -46,7 +85,10 @@ fn main() -> Result<()> {
|
|||||||
use coa_core::manifest::{Manifest, Migration};
|
use coa_core::manifest::{Manifest, Migration};
|
||||||
use coa_core::update::{Env, RepackEnv};
|
use coa_core::update::{Env, RepackEnv};
|
||||||
let meta = root.join("fixture-manager");
|
let meta = root.join("fixture-manager");
|
||||||
let env = RepackEnv { root, meta_dir: &meta };
|
let env = RepackEnv {
|
||||||
|
root,
|
||||||
|
meta_dir: &meta,
|
||||||
|
};
|
||||||
env.ensure_stopped()?;
|
env.ensure_stopped()?;
|
||||||
let staged = root.join("fixture-migrations");
|
let staged = root.join("fixture-migrations");
|
||||||
let mut manifest: Manifest = serde_json::from_value(serde_json::json!({
|
let mut manifest: Manifest = serde_json::from_value(serde_json::json!({
|
||||||
@@ -58,7 +100,13 @@ fn main() -> Result<()> {
|
|||||||
let path = staged.join(format!("{kind}/manager_realm_fixture.sql"));
|
let path = staged.join(format!("{kind}/manager_realm_fixture.sql"));
|
||||||
std::fs::create_dir_all(path.parent().unwrap())?;
|
std::fs::create_dir_all(path.parent().unwrap())?;
|
||||||
std::fs::write(&path, sql)?;
|
std::fs::write(&path, sql)?;
|
||||||
manifest.migrations.push(Migration { compatible_sha256: vec![], id: "manager_realm_fixture".into(), db: kind.into(), sha256: coa_core::fsx::sha256_file(&path)?, destructive: false });
|
manifest.migrations.push(Migration {
|
||||||
|
compatible_sha256: vec![],
|
||||||
|
id: "manager_realm_fixture".into(),
|
||||||
|
db: kind.into(),
|
||||||
|
sha256: coa_core::fsx::sha256_file(&path)?,
|
||||||
|
destructive: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
let result = env.migrate(&manifest, &staged)?;
|
let result = env.migrate(&manifest, &staged)?;
|
||||||
assert!(result.failed.is_none());
|
assert!(result.failed.is_none());
|
||||||
@@ -66,7 +114,12 @@ fn main() -> Result<()> {
|
|||||||
for mode in [Mode::Coa, Mode::Wildcard] {
|
for mode in [Mode::Coa, Mode::Wildcard] {
|
||||||
let realm = db.clone().for_realm(mode);
|
let realm = db.clone().for_realm(mode);
|
||||||
for kind in ["characters", "world", "auth"] {
|
for kind in ["characters", "world", "auth"] {
|
||||||
assert_eq!(realm.query(&format!("SELECT COUNT(*) FROM acore_{kind}.manager_migration_probe;"))?, "1");
|
assert_eq!(
|
||||||
|
realm.query(&format!(
|
||||||
|
"SELECT COUNT(*) FROM acore_{kind}.manager_migration_probe;"
|
||||||
|
))?,
|
||||||
|
"1"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -79,8 +132,16 @@ fn main() -> Result<()> {
|
|||||||
})?;
|
})?;
|
||||||
backup::restore_database(root, &meta, &point.id, "characters")?;
|
backup::restore_database(root, &meta, &point.id, "characters")?;
|
||||||
backup::with_database(root, |db| {
|
backup::with_database(root, |db| {
|
||||||
assert_eq!(db.query("SELECT COUNT(*) FROM acore_characters.manager_profile_probe;")?, "0");
|
assert_eq!(
|
||||||
assert_eq!(db.clone().for_realm(Mode::Coa).query("SELECT value FROM acore_characters.manager_profile_probe;")?, "11");
|
db.query("SELECT COUNT(*) FROM acore_characters.manager_profile_probe;")?,
|
||||||
|
"0"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
db.clone()
|
||||||
|
.for_realm(Mode::Coa)
|
||||||
|
.query("SELECT value FROM acore_characters.manager_profile_probe;")?,
|
||||||
|
"11"
|
||||||
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
println!("Both realms migrated once; shared auth migrated once; Wildcard restore left CoA intact.");
|
println!("Both realms migrated once; shared auth migrated once; Wildcard restore left CoA intact.");
|
||||||
|
|||||||
@@ -1,12 +1,29 @@
|
|||||||
//! Signed-package repair smoke test. Only a disposable fixture may be used.
|
//! Signed-package repair smoke test. Only a disposable fixture may be used.
|
||||||
use std::path::PathBuf;
|
|
||||||
use base64::{engine::general_purpose::STANDARD, Engine};
|
use base64::{engine::general_purpose::STANDARD, Engine};
|
||||||
|
use coa_core::{
|
||||||
|
fsx,
|
||||||
|
manifest::{Kind, Migration},
|
||||||
|
package::{self, BuildOptions},
|
||||||
|
pkgsource::Source,
|
||||||
|
realms::Mode,
|
||||||
|
registry::{metadata_dir_for, InstallKind, InstallMeta, MetaDir},
|
||||||
|
Error, Result,
|
||||||
|
};
|
||||||
use ed25519_dalek::{Signer, SigningKey};
|
use ed25519_dalek::{Signer, SigningKey};
|
||||||
use coa_core::{Result, Error, fsx, package::{self, BuildOptions}, manifest::{Kind, Migration}, registry::{InstallKind, InstallMeta, MetaDir, metadata_dir_for}, pkgsource::Source, realms::Mode};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let root = PathBuf::from(std::env::args().nth(1).ok_or_else(|| Error::Invalid("fixture path required".into()))?);
|
let root = PathBuf::from(
|
||||||
if !root.file_name().is_some_and(|n| n.to_string_lossy().contains("fixture")) { return Err(Error::Invalid("Refusing a non-fixture server.".into())); }
|
std::env::args()
|
||||||
|
.nth(1)
|
||||||
|
.ok_or_else(|| Error::Invalid("fixture path required".into()))?,
|
||||||
|
);
|
||||||
|
if !root
|
||||||
|
.file_name()
|
||||||
|
.is_some_and(|n| n.to_string_lossy().contains("fixture"))
|
||||||
|
{
|
||||||
|
return Err(Error::Invalid("Refusing a non-fixture server.".into()));
|
||||||
|
}
|
||||||
let work = tempfile::tempdir()?;
|
let work = tempfile::tempdir()?;
|
||||||
let base_tree = work.path().join("base-tree");
|
let base_tree = work.path().join("base-tree");
|
||||||
let update_tree = work.path().join("update-tree");
|
let update_tree = work.path().join("update-tree");
|
||||||
@@ -17,15 +34,54 @@ fn main() -> Result<()> {
|
|||||||
fsx::atomic_write(&update_tree.join(probe), b"correct official file")?;
|
fsx::atomic_write(&update_tree.join(probe), b"correct official file")?;
|
||||||
let sql = "CREATE TABLE IF NOT EXISTS acore_world.manager_repair_probe (id INT PRIMARY KEY); INSERT IGNORE INTO acore_world.manager_repair_probe VALUES (42);";
|
let sql = "CREATE TABLE IF NOT EXISTS acore_world.manager_repair_probe (id INT PRIMARY KEY); INSERT IGNORE INTO acore_world.manager_repair_probe VALUES (42);";
|
||||||
let id = "20261004_repair_e2e";
|
let id = "20261004_repair_e2e";
|
||||||
fsx::atomic_write(&update_tree.join(format!("_migrations/world/{id}.sql")), sql.as_bytes())?;
|
fsx::atomic_write(
|
||||||
let options = |kind, version: &str, migrations| BuildOptions { kind, version: version.into(), core_commit: None, built_at: "fixture".into(), part_size: 1 << 20, bots_commit: None, migrations };
|
&update_tree.join(format!("_migrations/world/{id}.sql")),
|
||||||
let base = package::build(&base_tree, &base_pkg, &options(Kind::Base, "1.0.0", vec![]), &|_| {})?;
|
sql.as_bytes(),
|
||||||
let update = package::build(&update_tree, &update_pkg, &options(Kind::Update, "1.0.1", vec![Migration { compatible_sha256: vec![], id: id.into(), db: "world".into(), sha256: fsx::sha256_bytes(sql.as_bytes()), destructive: false }]), &|_| {})?;
|
)?;
|
||||||
|
let options = |kind, version: &str, migrations| BuildOptions {
|
||||||
|
kind,
|
||||||
|
version: version.into(),
|
||||||
|
core_commit: None,
|
||||||
|
built_at: "fixture".into(),
|
||||||
|
part_size: 1 << 20,
|
||||||
|
bots_commit: None,
|
||||||
|
migrations,
|
||||||
|
};
|
||||||
|
let base = package::build(
|
||||||
|
&base_tree,
|
||||||
|
&base_pkg,
|
||||||
|
&options(Kind::Base, "1.0.0", vec![]),
|
||||||
|
&|_| {},
|
||||||
|
)?;
|
||||||
|
let update = package::build(
|
||||||
|
&update_tree,
|
||||||
|
&update_pkg,
|
||||||
|
&options(
|
||||||
|
Kind::Update,
|
||||||
|
"1.0.1",
|
||||||
|
vec![Migration {
|
||||||
|
compatible_sha256: vec![],
|
||||||
|
id: id.into(),
|
||||||
|
db: "world".into(),
|
||||||
|
sha256: fsx::sha256_bytes(sql.as_bytes()),
|
||||||
|
destructive: false,
|
||||||
|
}],
|
||||||
|
),
|
||||||
|
&|_| {},
|
||||||
|
)?;
|
||||||
// A test-only trust key, unrelated to production signing material.
|
// A test-only trust key, unrelated to production signing material.
|
||||||
let key = SigningKey::from_bytes(&[23; 32]);
|
let key = SigningKey::from_bytes(&[23; 32]);
|
||||||
let public = STANDARD.encode(key.verifying_key().as_bytes());
|
let public = STANDARD.encode(key.verifying_key().as_bytes());
|
||||||
for pkg in [&base_pkg, &update_pkg] {
|
for pkg in [&base_pkg, &update_pkg] {
|
||||||
fsx::atomic_write(&pkg.join("manifest.json.sig"), STANDARD.encode(key.sign(&std::fs::read(pkg.join("manifest.json"))?).to_bytes()).as_bytes())?;
|
fsx::atomic_write(
|
||||||
|
&pkg.join("manifest.json.sig"),
|
||||||
|
STANDARD
|
||||||
|
.encode(
|
||||||
|
key.sign(&std::fs::read(pkg.join("manifest.json"))?)
|
||||||
|
.to_bytes(),
|
||||||
|
)
|
||||||
|
.as_bytes(),
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
let dir = metadata_dir_for(&root)?;
|
let dir = metadata_dir_for(&root)?;
|
||||||
let mut meta = InstallMeta::new(InstallKind::New, &root);
|
let mut meta = InstallMeta::new(InstallKind::New, &root);
|
||||||
@@ -35,24 +91,43 @@ fn main() -> Result<()> {
|
|||||||
fsx::atomic_write_json(&dir.join("manifests/update-1.0.1.json"), &update)?;
|
fsx::atomic_write_json(&dir.join("manifests/update-1.0.1.json"), &update)?;
|
||||||
fsx::atomic_write(&root.join(probe), b"corrupted")?;
|
fsx::atomic_write(&root.join(probe), b"corrupted")?;
|
||||||
let settings = std::fs::read(root.join("Settings/repack.json"))?;
|
let settings = std::fs::read(root.join("Settings/repack.json"))?;
|
||||||
let counts = coa_core::backup::with_database(&root, |db| db.query("SELECT COUNT(*) FROM acore_auth.account; SELECT COUNT(*) FROM acore_characters.characters; SELECT COUNT(*) FROM acore_characters_wildcard.characters;"))?;
|
let counts = coa_core::backup::with_database(&root, |db| {
|
||||||
let report = coa_core::repair::run(&root, &dir, &Source::Dir(base_pkg), &Source::Dir(update_pkg), &public, &|s,p| println!("{p}% {s}"))?;
|
db.query("SELECT COUNT(*) FROM acore_auth.account; SELECT COUNT(*) FROM acore_characters.characters; SELECT COUNT(*) FROM acore_characters_wildcard.characters;")
|
||||||
|
})?;
|
||||||
|
let report = coa_core::repair::run(
|
||||||
|
&root,
|
||||||
|
&dir,
|
||||||
|
&Source::Dir(base_pkg),
|
||||||
|
&Source::Dir(update_pkg),
|
||||||
|
&public,
|
||||||
|
&|s, p| println!("{p}% {s}"),
|
||||||
|
)?;
|
||||||
assert_eq!(std::fs::read(root.join(probe))?, b"correct official file");
|
assert_eq!(std::fs::read(root.join(probe))?, b"correct official file");
|
||||||
assert!(report.error.is_none(), "{:?}", report.error);
|
assert!(report.error.is_none(), "{:?}", report.error);
|
||||||
assert_eq!(report.applied.len(), 2, "Migration must run in both worlds");
|
assert_eq!(report.applied.len(), 2, "Migration must run in both worlds");
|
||||||
assert!(report.database.iter().all(|d| d.problems.is_empty() && d.migrations.iter().all(|m| m.status == coa_core::migrations::Status::Applied)));
|
assert!(report.database.iter().all(|d| d.problems.is_empty()
|
||||||
|
&& d.migrations
|
||||||
|
.iter()
|
||||||
|
.all(|m| m.status == coa_core::migrations::Status::Applied)));
|
||||||
assert_eq!(std::fs::read(root.join("Settings/repack.json"))?, settings);
|
assert_eq!(std::fs::read(root.join("Settings/repack.json"))?, settings);
|
||||||
assert!(coa_core::backup::verify(&dir, &report.backup)?.ok);
|
assert!(coa_core::backup::verify(&dir, &report.backup)?.ok);
|
||||||
coa_core::backup::with_database(&root, |db| {
|
coa_core::backup::with_database(&root, |db| {
|
||||||
assert_eq!(db.query("SELECT COUNT(*) FROM acore_auth.account; SELECT COUNT(*) FROM acore_characters.characters; SELECT COUNT(*) FROM acore_characters_wildcard.characters;")?, counts);
|
assert_eq!(db.query("SELECT COUNT(*) FROM acore_auth.account; SELECT COUNT(*) FROM acore_characters.characters; SELECT COUNT(*) FROM acore_characters_wildcard.characters;")?, counts);
|
||||||
for mode in [Mode::Coa, Mode::Wildcard] {
|
for mode in [Mode::Coa, Mode::Wildcard] {
|
||||||
assert_eq!(db.clone().for_realm(mode).query("SELECT id FROM acore_world.manager_repair_probe;")?, "42");
|
assert_eq!(
|
||||||
|
db.clone()
|
||||||
|
.for_realm(mode)
|
||||||
|
.query("SELECT id FROM acore_world.manager_repair_probe;")?,
|
||||||
|
"42"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// Corrupt only the second realm, proving that checks read its actual schema.
|
// Corrupt only the second realm, proving that checks read its actual schema.
|
||||||
let wildcard = db.clone().for_realm(Mode::Wildcard);
|
let wildcard = db.clone().for_realm(Mode::Wildcard);
|
||||||
wildcard.query("ALTER TABLE acore_characters.character_action DROP COLUMN type;")?;
|
wildcard.query("ALTER TABLE acore_characters.character_action DROP COLUMN type;")?;
|
||||||
let problems = coa_core::schema_check::check(&wildcard, &root)?;
|
let problems = coa_core::schema_check::check(&wildcard, &root)?;
|
||||||
assert!(problems.iter().any(|p| p.table == "character_action" && p.column == "type"));
|
assert!(problems
|
||||||
|
.iter()
|
||||||
|
.any(|p| p.table == "character_action" && p.column == "type"));
|
||||||
assert!(coa_core::schema_check::check(&db.clone().for_realm(Mode::Coa), &root)?.is_empty());
|
assert!(coa_core::schema_check::check(&db.clone().for_realm(Mode::Coa), &root)?.is_empty());
|
||||||
wildcard.query("ALTER TABLE acore_characters.character_action ADD COLUMN type TINYINT UNSIGNED NOT NULL DEFAULT 0;")?;
|
wildcard.query("ALTER TABLE acore_characters.character_action ADD COLUMN type TINYINT UNSIGNED NOT NULL DEFAULT 0;")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ fn main() {
|
|||||||
let url = std::env::args().nth(1).unwrap();
|
let url = std::env::args().nth(1).unwrap();
|
||||||
let mode = std::env::args().nth(2).unwrap();
|
let mode = std::env::args().nth(2).unwrap();
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
let client = reqwest::blocking::Client::builder().timeout(None::<std::time::Duration>).build().unwrap();
|
let client = reqwest::blocking::Client::builder()
|
||||||
|
.timeout(None::<std::time::Duration>)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
let mut resp = client.get(&url).send().unwrap();
|
let mut resp = client.get(&url).send().unwrap();
|
||||||
if mode == "bytes" {
|
if mode == "bytes" {
|
||||||
let b = resp.bytes().unwrap();
|
let b = resp.bytes().unwrap();
|
||||||
@@ -13,7 +16,9 @@ fn main() {
|
|||||||
let mut total = 0;
|
let mut total = 0;
|
||||||
loop {
|
loop {
|
||||||
let n = resp.read(&mut buf).unwrap();
|
let n = resp.read(&mut buf).unwrap();
|
||||||
if n == 0 { break; }
|
if n == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
total += n;
|
total += n;
|
||||||
}
|
}
|
||||||
println!("read loop {} in {:?}", total, t.elapsed());
|
println!("read loop {} in {:?}", total, t.elapsed());
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let path = std::env::args().nth(1).expect("usage: scan <server folder>");
|
let path = std::env::args()
|
||||||
|
.nth(1)
|
||||||
|
.expect("usage: scan <server folder>");
|
||||||
let root = Path::new(&path);
|
let root = Path::new(&path);
|
||||||
let report = coa_core::layout::scan(root).expect("scan failed");
|
let report = coa_core::layout::scan(root).expect("scan failed");
|
||||||
println!("{}", serde_json::to_string_pretty(&report).unwrap());
|
println!("{}", serde_json::to_string_pretty(&report).unwrap());
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
//! Check full schema contracts and blocking custom columns, only against a disposable fixture.
|
//! Check full schema contracts and blocking custom columns, only against a disposable fixture.
|
||||||
use coa_core::{Result, Error, backup, schema_check, realms::Mode};
|
use coa_core::{backup, realms::Mode, schema_check, Error, Result};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let root = PathBuf::from(std::env::args().nth(1).ok_or_else(|| Error::Invalid("fixture path required".into()))?);
|
let root = PathBuf::from(
|
||||||
if !root.file_name().is_some_and(|n| n.to_string_lossy().contains("fixture")) { return Err(Error::Invalid("Refusing a non-fixture server.".into())); }
|
std::env::args()
|
||||||
|
.nth(1)
|
||||||
|
.ok_or_else(|| Error::Invalid("fixture path required".into()))?,
|
||||||
|
);
|
||||||
|
if !root
|
||||||
|
.file_name()
|
||||||
|
.is_some_and(|n| n.to_string_lossy().contains("fixture"))
|
||||||
|
{
|
||||||
|
return Err(Error::Invalid("Refusing a non-fixture server.".into()));
|
||||||
|
}
|
||||||
backup::with_database(&root, |db| {
|
backup::with_database(&root, |db| {
|
||||||
let coa = db.clone().for_realm(Mode::Coa);
|
let coa = db.clone().for_realm(Mode::Coa);
|
||||||
let wildcard = db.clone().for_realm(Mode::Wildcard);
|
let wildcard = db.clone().for_realm(Mode::Wildcard);
|
||||||
@@ -14,11 +23,14 @@ fn main() -> Result<()> {
|
|||||||
assert!(schema_check::check(&coa, reference.path())?.is_empty());
|
assert!(schema_check::check(&coa, reference.path())?.is_empty());
|
||||||
wildcard.query("ALTER TABLE acore_characters.character_action ADD COLUMN manager_required INT NOT NULL;")?;
|
wildcard.query("ALTER TABLE acore_characters.character_action ADD COLUMN manager_required INT NOT NULL;")?;
|
||||||
let result = (|| {
|
let result = (|| {
|
||||||
assert!(schema_check::check(&wildcard, &root)?.iter().any(|p| p.table == "character_action" && p.column == "manager_required"));
|
assert!(schema_check::check(&wildcard, &root)?
|
||||||
|
.iter()
|
||||||
|
.any(|p| p.table == "character_action" && p.column == "manager_required"));
|
||||||
assert!(schema_check::check(&coa, &root)?.is_empty());
|
assert!(schema_check::check(&coa, &root)?.is_empty());
|
||||||
Ok(())
|
Ok(())
|
||||||
})();
|
})();
|
||||||
wildcard.query("ALTER TABLE acore_characters.character_action DROP COLUMN manager_required;")?;
|
wildcard
|
||||||
|
.query("ALTER TABLE acore_characters.character_action DROP COLUMN manager_required;")?;
|
||||||
result
|
result
|
||||||
})?;
|
})?;
|
||||||
println!("Full schema contract and a blocking NOT NULL column verified; second-realm corruption does not affect CoA checks.");
|
println!("Full schema contract and a blocking NOT NULL column verified; second-realm corruption does not affect CoA checks.");
|
||||||
|
|||||||
@@ -9,13 +9,26 @@ fn main() {
|
|||||||
let seed_b64 = match std::env::var("COA_SIGNING_KEY") {
|
let seed_b64 = match std::env::var("COA_SIGNING_KEY") {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let path = a.next().unwrap_or_else(|| format!("{}/.coa-manager/signing/manifest-signing.key", std::env::var("USERPROFILE").unwrap()));
|
let path = a.next().unwrap_or_else(|| {
|
||||||
|
format!(
|
||||||
|
"{}/.coa-manager/signing/manifest-signing.key",
|
||||||
|
std::env::var("USERPROFILE").unwrap()
|
||||||
|
)
|
||||||
|
});
|
||||||
fs::read_to_string(path).expect("cannot read signing key")
|
fs::read_to_string(path).expect("cannot read signing key")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let seed: [u8; 32] = STANDARD.decode(seed_b64.trim()).unwrap().try_into().expect("key length");
|
let seed: [u8; 32] = STANDARD
|
||||||
|
.decode(seed_b64.trim())
|
||||||
|
.unwrap()
|
||||||
|
.try_into()
|
||||||
|
.expect("key length");
|
||||||
let bytes = fs::read(&manifest).unwrap();
|
let bytes = fs::read(&manifest).unwrap();
|
||||||
let sig = SigningKey::from_bytes(&seed).sign(&bytes);
|
let sig = SigningKey::from_bytes(&seed).sign(&bytes);
|
||||||
fs::write(format!("{manifest}.sig"), format!("{}\n", STANDARD.encode(sig.to_bytes()))).unwrap();
|
fs::write(
|
||||||
|
format!("{manifest}.sig"),
|
||||||
|
format!("{}\n", STANDARD.encode(sig.to_bytes())),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
println!("signed {manifest}");
|
println!("signed {manifest}");
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
//! Read-only helper for a DISPOSABLE fixture: run one query. usage: sqlq <fixture> <sql>
|
//! Read-only helper for a DISPOSABLE fixture: run one query. usage: sqlq <fixture> <sql>
|
||||||
fn main() {
|
fn main() {
|
||||||
let a: Vec<String> = std::env::args().skip(1).collect();
|
let a: Vec<String> = std::env::args().skip(1).collect();
|
||||||
assert!(a[0].to_lowercase().contains("fixture"), "refusing: not a fixture folder");
|
assert!(
|
||||||
|
a[0].to_lowercase().contains("fixture"),
|
||||||
|
"refusing: not a fixture folder"
|
||||||
|
);
|
||||||
let root = std::path::Path::new(&a[0]);
|
let root = std::path::Path::new(&a[0]);
|
||||||
let out = coa_core::backup::with_database(root, |db| db.query(&a[1])).expect("query");
|
let out = coa_core::backup::with_database(root, |db| db.query(&a[1])).expect("query");
|
||||||
println!("{out}");
|
println!("{out}");
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ fn put(root: &std::path::Path, rel: &str, body: &str) {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let root = PathBuf::from(std::env::args().nth(1).expect("fixture folder"));
|
let root = PathBuf::from(std::env::args().nth(1).expect("fixture folder"));
|
||||||
assert!(root.to_string_lossy().to_lowercase().contains("fixture"), "refusing: not a fixture folder");
|
assert!(
|
||||||
|
root.to_string_lossy().to_lowercase().contains("fixture"),
|
||||||
|
"refusing: not a fixture folder"
|
||||||
|
);
|
||||||
let meta_dir = metadata_dir_for(&root).unwrap();
|
let meta_dir = metadata_dir_for(&root).unwrap();
|
||||||
if !meta_dir.join("install.json").is_file() {
|
if !meta_dir.join("install.json").is_file() {
|
||||||
MetaDir::create(&root, &InstallMeta::new(InstallKind::Imported, &root)).unwrap();
|
MetaDir::create(&root, &InstallMeta::new(InstallKind::Imported, &root)).unwrap();
|
||||||
@@ -28,33 +31,105 @@ fn main() {
|
|||||||
let work = std::env::temp_dir().join("coa-update-e2e");
|
let work = std::env::temp_dir().join("coa-update-e2e");
|
||||||
let _ = std::fs::remove_dir_all(&work);
|
let _ = std::fs::remove_dir_all(&work);
|
||||||
let (src, pkg) = (work.join("src"), work.join("pkg"));
|
let (src, pkg) = (work.join("src"), work.join("pkg"));
|
||||||
put(&src, "Core/reference/update-e2e.txt", "shipped by the update\n");
|
put(
|
||||||
put(&src, "Settings/worldserver.conf.template", "[worldserver]\nUpdateE2E.NewSetting = 7\n");
|
&src,
|
||||||
|
"Core/reference/update-e2e.txt",
|
||||||
|
"shipped by the update\n",
|
||||||
|
);
|
||||||
|
put(
|
||||||
|
&src,
|
||||||
|
"Settings/worldserver.conf.template",
|
||||||
|
"[worldserver]\nUpdateE2E.NewSetting = 7\n",
|
||||||
|
);
|
||||||
let sql = "CREATE TABLE IF NOT EXISTS coa_manager_update_test (id INT PRIMARY KEY); INSERT IGNORE INTO coa_manager_update_test VALUES (1);";
|
let sql = "CREATE TABLE IF NOT EXISTS coa_manager_update_test (id INT PRIMARY KEY); INSERT IGNORE INTO coa_manager_update_test VALUES (1);";
|
||||||
put(&src, "_migrations/world/2026_09_30_00_update_e2e.sql", sql);
|
put(&src, "_migrations/world/2026_09_30_00_update_e2e.sql", sql);
|
||||||
let mut m = build(&src, &pkg, &BuildOptions { kind: Kind::Update, version: "0.2.0".into(), core_commit: None, built_at: chrono::Utc::now().to_rfc3339(), part_size: 1 << 20, bots_commit: None, migrations: vec![] }, &|_| {}).unwrap();
|
let mut m = build(
|
||||||
m.migrations.push(Migration { compatible_sha256: vec![], id: "2026_09_30_00_update_e2e".into(), db: "world".into(), sha256: fsx::sha256_bytes(sql.as_bytes()), destructive: false });
|
&src,
|
||||||
std::fs::write(pkg.join("manifest.json"), serde_json::to_vec_pretty(&m).unwrap()).unwrap();
|
&pkg,
|
||||||
let key = format!("{}/.coa-manager/signing/manifest-signing.key", std::env::var("USERPROFILE").unwrap());
|
&BuildOptions {
|
||||||
let seed: [u8; 32] = STANDARD.decode(std::fs::read_to_string(key).unwrap().trim()).unwrap().try_into().unwrap();
|
kind: Kind::Update,
|
||||||
let sig = SigningKey::from_bytes(&seed).sign(&std::fs::read(pkg.join("manifest.json")).unwrap());
|
version: "0.2.0".into(),
|
||||||
std::fs::write(pkg.join("manifest.json.sig"), STANDARD.encode(sig.to_bytes())).unwrap();
|
core_commit: None,
|
||||||
|
built_at: chrono::Utc::now().to_rfc3339(),
|
||||||
|
part_size: 1 << 20,
|
||||||
|
bots_commit: None,
|
||||||
|
migrations: vec![],
|
||||||
|
},
|
||||||
|
&|_| {},
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
m.migrations.push(Migration {
|
||||||
|
compatible_sha256: vec![],
|
||||||
|
id: "2026_09_30_00_update_e2e".into(),
|
||||||
|
db: "world".into(),
|
||||||
|
sha256: fsx::sha256_bytes(sql.as_bytes()),
|
||||||
|
destructive: false,
|
||||||
|
});
|
||||||
|
std::fs::write(
|
||||||
|
pkg.join("manifest.json"),
|
||||||
|
serde_json::to_vec_pretty(&m).unwrap(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let key = format!(
|
||||||
|
"{}/.coa-manager/signing/manifest-signing.key",
|
||||||
|
std::env::var("USERPROFILE").unwrap()
|
||||||
|
);
|
||||||
|
let seed: [u8; 32] = STANDARD
|
||||||
|
.decode(std::fs::read_to_string(key).unwrap().trim())
|
||||||
|
.unwrap()
|
||||||
|
.try_into()
|
||||||
|
.unwrap();
|
||||||
|
let sig =
|
||||||
|
SigningKey::from_bytes(&seed).sign(&std::fs::read(pkg.join("manifest.json")).unwrap());
|
||||||
|
std::fs::write(
|
||||||
|
pkg.join("manifest.json.sig"),
|
||||||
|
STANDARD.encode(sig.to_bytes()),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let template_before = std::fs::read(root.join("Settings/worldserver.conf.template")).unwrap();
|
let template_before = std::fs::read(root.join("Settings/worldserver.conf.template")).unwrap();
|
||||||
let env = RepackEnv { root: &root, meta_dir: &meta_dir };
|
let env = RepackEnv {
|
||||||
|
root: &root,
|
||||||
|
meta_dir: &meta_dir,
|
||||||
|
};
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
let out = apply(
|
let out = apply(
|
||||||
&Params { root: &root, meta_dir: &meta_dir, source: Source::Dir(pkg), trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY, cancel: Cancel::default(), resolutions: Default::default(), env: &env, fail_after_ops: None },
|
&Params {
|
||||||
|
root: &root,
|
||||||
|
meta_dir: &meta_dir,
|
||||||
|
source: Source::Dir(pkg),
|
||||||
|
trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
|
cancel: Cancel::default(),
|
||||||
|
resolutions: Default::default(),
|
||||||
|
env: &env,
|
||||||
|
fail_after_ops: None,
|
||||||
|
},
|
||||||
&|s, p| eprintln!(" {p:>3}% {s}"),
|
&|s, p| eprintln!(" {p:>3}% {s}"),
|
||||||
)
|
)
|
||||||
.expect("update");
|
.expect("update");
|
||||||
println!("update {:?} in {:?}; recovery point {:?}; migrations {:?}", out.txn.state, t.elapsed(), out.txn.recovery_point, out.migrations.as_ref().map(|r| &r.applied));
|
println!(
|
||||||
|
"update {:?} in {:?}; recovery point {:?}; migrations {:?}",
|
||||||
|
out.txn.state,
|
||||||
|
t.elapsed(),
|
||||||
|
out.txn.recovery_point,
|
||||||
|
out.migrations.as_ref().map(|r| &r.applied)
|
||||||
|
);
|
||||||
|
|
||||||
let tpl = std::fs::read_to_string(root.join("Settings/worldserver.conf.template")).unwrap();
|
let tpl = std::fs::read_to_string(root.join("Settings/worldserver.conf.template")).unwrap();
|
||||||
assert!(tpl.contains("UpdateE2E.NewSetting = 7"), "new key merged");
|
assert!(tpl.contains("UpdateE2E.NewSetting = 7"), "new key merged");
|
||||||
assert!(tpl.len() > template_before.len() && tpl.starts_with(&String::from_utf8_lossy(&template_before).into_owned()), "existing template content untouched, key appended");
|
assert!(
|
||||||
assert_eq!(std::fs::read_to_string(root.join("Core/reference/update-e2e.txt")).unwrap(), "shipped by the update\n");
|
tpl.len() > template_before.len()
|
||||||
let n = backup::with_database(&root, |db| db.query("SELECT COUNT(*) FROM acore_world.coa_manager_update_test;")).unwrap();
|
&& tpl.starts_with(&String::from_utf8_lossy(&template_before).into_owned()),
|
||||||
|
"existing template content untouched, key appended"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
std::fs::read_to_string(root.join("Core/reference/update-e2e.txt")).unwrap(),
|
||||||
|
"shipped by the update\n"
|
||||||
|
);
|
||||||
|
let n = backup::with_database(&root, |db| {
|
||||||
|
db.query("SELECT COUNT(*) FROM acore_world.coa_manager_update_test;")
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
assert_eq!(n, "1", "the migration ran");
|
assert_eq!(n, "1", "the migration ran");
|
||||||
println!("OK: files, merge, migration and health check verified");
|
println!("OK: files, merge, migration and health check verified");
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,39 @@
|
|||||||
//! Failure injection on a NEW disposable fixture created by tools/make-fixture.ps1.
|
//! Failure injection on a NEW disposable fixture created by tools/make-fixture.ps1.
|
||||||
//! Uses real MySQL dumps, SQL execution, signed packages and update rollback.
|
//! Uses real MySQL dumps, SQL execution, signed packages and update rollback.
|
||||||
use std::{collections::BTreeMap, path::{Path, PathBuf}};
|
|
||||||
use coa_core::{backup, db::{Account, Db}, download::Cancel, driver::{self, Verb}, fsx,
|
|
||||||
manifest::{Kind, Migration}, package::{self, BuildOptions}, pkgsource::Source,
|
|
||||||
registry::{InstallKind, InstallMeta, MetaDir},
|
|
||||||
update::{self, Env, RepackEnv}, Error, Result};
|
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
|
use coa_core::{
|
||||||
|
backup,
|
||||||
|
db::{Account, Db},
|
||||||
|
download::Cancel,
|
||||||
|
driver::{self, Verb},
|
||||||
|
fsx,
|
||||||
|
manifest::{Kind, Migration},
|
||||||
|
package::{self, BuildOptions},
|
||||||
|
pkgsource::Source,
|
||||||
|
registry::{InstallKind, InstallMeta, MetaDir},
|
||||||
|
update::{self, Env, RepackEnv},
|
||||||
|
Error, Result,
|
||||||
|
};
|
||||||
use ed25519_dalek::{Signer, SigningKey};
|
use ed25519_dalek::{Signer, SigningKey};
|
||||||
|
use std::{
|
||||||
|
collections::BTreeMap,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let arg = std::env::args().nth(1).expect("usage: update_recovery_e2e <new fixture>");
|
let arg = std::env::args()
|
||||||
|
.nth(1)
|
||||||
|
.expect("usage: update_recovery_e2e <new fixture>");
|
||||||
let root = PathBuf::from(arg);
|
let root = PathBuf::from(arg);
|
||||||
assert!(root.file_name().unwrap().to_string_lossy().starts_with("coa-update-recovery-fixture-"));
|
assert!(root
|
||||||
assert!(!root.join("recovery-e2e-started").exists(), "Use a new fixture; never reuse an owned server");
|
.file_name()
|
||||||
|
.unwrap()
|
||||||
|
.to_string_lossy()
|
||||||
|
.starts_with("coa-update-recovery-fixture-"));
|
||||||
|
assert!(
|
||||||
|
!root.join("recovery-e2e-started").exists(),
|
||||||
|
"Use a new fixture; never reuse an owned server"
|
||||||
|
);
|
||||||
fsx::atomic_write(&root.join("recovery-e2e-started"), b"disposable fixture")?;
|
fsx::atomic_write(&root.join("recovery-e2e-started"), b"disposable fixture")?;
|
||||||
let result = exercise(&root);
|
let result = exercise(&root);
|
||||||
let stopped = driver::run(&root, Verb::StopAll)?;
|
let stopped = driver::run(&root, Verb::StopAll)?;
|
||||||
@@ -34,43 +55,119 @@ fn exercise(root: &Path) -> Result<()> {
|
|||||||
fsx::atomic_write(&source.join("Core/recovery-probe.txt"), b"updated")?;
|
fsx::atomic_write(&source.join("Core/recovery-probe.txt"), b"updated")?;
|
||||||
let mut migrations = Vec::new();
|
let mut migrations = Vec::new();
|
||||||
for (db, id, sql) in [
|
for (db, id, sql) in [
|
||||||
("characters", "probe_chars", "UPDATE manager_recovery_probe SET id=999;"),
|
(
|
||||||
("world", "probe_world", "DROP TABLE manager_recovery_probe; THIS IS INTENTIONALLY INVALID SQL;"),
|
"characters",
|
||||||
|
"probe_chars",
|
||||||
|
"UPDATE manager_recovery_probe SET id=999;",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"world",
|
||||||
|
"probe_world",
|
||||||
|
"DROP TABLE manager_recovery_probe; THIS IS INTENTIONALLY INVALID SQL;",
|
||||||
|
),
|
||||||
] {
|
] {
|
||||||
fsx::atomic_write(&source.join(format!("_migrations/{db}/{id}.sql")), sql.as_bytes())?;
|
fsx::atomic_write(
|
||||||
migrations.push(Migration { compatible_sha256: vec![], db: db.into(), id: id.into(), sha256: fsx::sha256_bytes(sql.as_bytes()), destructive: false });
|
&source.join(format!("_migrations/{db}/{id}.sql")),
|
||||||
|
sql.as_bytes(),
|
||||||
|
)?;
|
||||||
|
migrations.push(Migration {
|
||||||
|
compatible_sha256: vec![],
|
||||||
|
db: db.into(),
|
||||||
|
id: id.into(),
|
||||||
|
sha256: fsx::sha256_bytes(sql.as_bytes()),
|
||||||
|
destructive: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
let pkg = root.join("fixture-package");
|
let pkg = root.join("fixture-package");
|
||||||
let manifest = package::build(&source, &pkg, &BuildOptions {
|
let manifest = package::build(
|
||||||
kind: Kind::Update, version: "2.0.0".into(), core_commit: None, bots_commit: None,
|
&source,
|
||||||
built_at: "fixture".into(), part_size: 1 << 20, migrations,
|
&pkg,
|
||||||
}, &|_| {})?;
|
&BuildOptions {
|
||||||
|
kind: Kind::Update,
|
||||||
|
version: "2.0.0".into(),
|
||||||
|
core_commit: None,
|
||||||
|
bots_commit: None,
|
||||||
|
built_at: "fixture".into(),
|
||||||
|
part_size: 1 << 20,
|
||||||
|
migrations,
|
||||||
|
},
|
||||||
|
&|_| {},
|
||||||
|
)?;
|
||||||
let key = SigningKey::generate(&mut rand_core::OsRng);
|
let key = SigningKey::generate(&mut rand_core::OsRng);
|
||||||
let signature = base64::engine::general_purpose::STANDARD.encode(key.sign(&std::fs::read(pkg.join("manifest.json"))?).to_bytes());
|
let signature = base64::engine::general_purpose::STANDARD.encode(
|
||||||
|
key.sign(&std::fs::read(pkg.join("manifest.json"))?)
|
||||||
|
.to_bytes(),
|
||||||
|
);
|
||||||
fsx::atomic_write(&pkg.join("manifest.json.sig"), signature.as_bytes())?;
|
fsx::atomic_write(&pkg.join("manifest.json.sig"), signature.as_bytes())?;
|
||||||
let trusted = base64::engine::general_purpose::STANDARD.encode(key.verifying_key().to_bytes());
|
let trusted = base64::engine::general_purpose::STANDARD.encode(key.verifying_key().to_bytes());
|
||||||
let env = RepackEnv { root, meta_dir: &meta };
|
let env = RepackEnv {
|
||||||
let error = update::apply(&update::Params {
|
root,
|
||||||
root, meta_dir: &meta, source: Source::Dir(pkg), trusted_key: &trusted,
|
meta_dir: &meta,
|
||||||
cancel: Cancel::default(), resolutions: BTreeMap::new(), env: &env, fail_after_ops: None,
|
};
|
||||||
}, &|step, pct| println!("{pct}% {step}" )).unwrap_err();
|
let error = update::apply(
|
||||||
|
&update::Params {
|
||||||
|
root,
|
||||||
|
meta_dir: &meta,
|
||||||
|
source: Source::Dir(pkg),
|
||||||
|
trusted_key: &trusted,
|
||||||
|
cancel: Cancel::default(),
|
||||||
|
resolutions: BTreeMap::new(),
|
||||||
|
env: &env,
|
||||||
|
fail_after_ops: None,
|
||||||
|
},
|
||||||
|
&|step, pct| println!("{pct}% {step}"),
|
||||||
|
)
|
||||||
|
.unwrap_err();
|
||||||
assert!(error.to_string().contains("probe_world"), "{error}");
|
assert!(error.to_string().contains("probe_world"), "{error}");
|
||||||
assert!(error.to_string().contains("private update rehearsal failed"), "{error}");
|
assert!(
|
||||||
|
error
|
||||||
|
.to_string()
|
||||||
|
.contains("private update rehearsal failed"),
|
||||||
|
"{error}"
|
||||||
|
);
|
||||||
assert!(!root.join("Core/recovery-probe.txt").exists());
|
assert!(!root.join("Core/recovery-probe.txt").exists());
|
||||||
assert!(update::unfinished(&meta).is_none());
|
assert!(update::unfinished(&meta).is_none());
|
||||||
assert_eq!(MetaDir::open(&meta)?.1.core.version.as_deref(), Some("1.0.0"));
|
assert_eq!(
|
||||||
|
MetaDir::open(&meta)?.1.core.version.as_deref(),
|
||||||
|
Some("1.0.0")
|
||||||
|
);
|
||||||
backup::with_database(root, |db| {
|
backup::with_database(root, |db| {
|
||||||
assert_eq!(db.query("SELECT id FROM acore_characters.manager_recovery_probe;")?, "42");
|
assert_eq!(
|
||||||
assert_eq!(db.query("SELECT id FROM acore_world.manager_recovery_probe;")?, "43");
|
db.query("SELECT id FROM acore_characters.manager_recovery_probe;")?,
|
||||||
assert_eq!(db.query("SELECT id FROM acore_characters.manager_recovery_view;")?, "42");
|
"42"
|
||||||
assert_eq!(db.recovery_objects("acore_characters")?.iter().filter(|object| object["name"].as_str().is_some_and(|name| name.starts_with("manager_recovery_"))).count(), 3);
|
);
|
||||||
assert!(!coa_core::migrations::status(db, &manifest.migrations)?.iter().any(|m| m.status == coa_core::migrations::Status::Applied));
|
assert_eq!(
|
||||||
|
db.query("SELECT id FROM acore_world.manager_recovery_probe;")?,
|
||||||
|
"43"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
db.query("SELECT id FROM acore_characters.manager_recovery_view;")?,
|
||||||
|
"42"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
db.recovery_objects("acore_characters")?
|
||||||
|
.iter()
|
||||||
|
.filter(|object| object["name"]
|
||||||
|
.as_str()
|
||||||
|
.is_some_and(|name| name.starts_with("manager_recovery_")))
|
||||||
|
.count(),
|
||||||
|
3
|
||||||
|
);
|
||||||
|
assert!(!coa_core::migrations::status(db, &manifest.migrations)?
|
||||||
|
.iter()
|
||||||
|
.any(|m| m.status == coa_core::migrations::Status::Applied));
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
// A recovery point can be reused if the process died midway through restoring multiple schemas.
|
// A recovery point can be reused if the process died midway through restoring multiple schemas.
|
||||||
let point = backup::list(&meta).into_iter().find(|p| p.trigger == backup::Trigger::BeforeUpdate).ok_or_else(|| Error::Invalid("missing backup".into()))?;
|
let point = backup::list(&meta)
|
||||||
|
.into_iter()
|
||||||
|
.find(|p| p.trigger == backup::Trigger::BeforeUpdate)
|
||||||
|
.ok_or_else(|| Error::Invalid("missing backup".into()))?;
|
||||||
env.restore_snapshot(&point.id)?;
|
env.restore_snapshot(&point.id)?;
|
||||||
assert_eq!(Db::from_repack(root, Account::Admin)?.realm(), coa_core::realms::Mode::Coa);
|
assert_eq!(
|
||||||
|
Db::from_repack(root, Account::Admin)?.realm(),
|
||||||
|
coa_core::realms::Mode::Coa
|
||||||
|
);
|
||||||
println!("PASS: private rehearsal caught failed SQL before changing the installed world, characters, ledger, objects, files or version; complete recovery succeeded");
|
println!("PASS: private rehearsal caught failed SQL before changing the installed world, characters, ledger, objects, files or version; complete recovery succeeded");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -3,15 +3,28 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let root = PathBuf::from(std::env::args().nth(1).expect("disposable fixture path"));
|
let root = PathBuf::from(std::env::args().nth(1).expect("disposable fixture path"));
|
||||||
assert_eq!(std::fs::read(root.join(".release-schema-fixture")).unwrap(), b"disposable release-schema fixture");
|
assert_eq!(
|
||||||
|
std::fs::read(root.join(".release-schema-fixture")).unwrap(),
|
||||||
|
b"disposable release-schema fixture"
|
||||||
|
);
|
||||||
let meta = coa_core::registry::metadata_dir_for(&root).unwrap();
|
let meta = coa_core::registry::metadata_dir_for(&root).unwrap();
|
||||||
let env = RepackEnv { root: &root, meta_dir: &meta };
|
let env = RepackEnv {
|
||||||
|
root: &root,
|
||||||
|
meta_dir: &meta,
|
||||||
|
};
|
||||||
let result = env.validate();
|
let result = env.validate();
|
||||||
let _ = coa_core::driver::run(&root, coa_core::driver::Verb::StopAll);
|
let _ = coa_core::driver::run(&root, coa_core::driver::Verb::StopAll);
|
||||||
if let Err(error) = result {
|
if let Err(error) = result {
|
||||||
eprintln!("{}", error);
|
eprintln!("{}", error);
|
||||||
for log in ["Core/Logs/auth-console.log", "Core/Logs/world-console.log", "Core/Logs/supervisor.log"] {
|
for log in [
|
||||||
eprintln!("{log}:\n{}", coa_core::diag::redact(&coa_core::health::tail(&root.join(log), 8192)));
|
"Core/Logs/auth-console.log",
|
||||||
|
"Core/Logs/world-console.log",
|
||||||
|
"Core/Logs/supervisor.log",
|
||||||
|
] {
|
||||||
|
eprintln!(
|
||||||
|
"{log}:\n{}",
|
||||||
|
coa_core::diag::redact(&coa_core::health::tail(&root.join(log), 8192))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,18 +8,56 @@ use coa_core::update::{apply, preview, Params, RepackEnv};
|
|||||||
fn main() {
|
fn main() {
|
||||||
let a: Vec<String> = std::env::args().skip(1).collect();
|
let a: Vec<String> = std::env::args().skip(1).collect();
|
||||||
let root = std::path::PathBuf::from(&a[0]);
|
let root = std::path::PathBuf::from(&a[0]);
|
||||||
assert!(a[0].to_lowercase().contains("installtest"), "refusing: not a disposable test install");
|
assert!(
|
||||||
|
a[0].to_lowercase().contains("installtest"),
|
||||||
|
"refusing: not a disposable test install"
|
||||||
|
);
|
||||||
let dir = metadata_dir_for(&root).unwrap();
|
let dir = metadata_dir_for(&root).unwrap();
|
||||||
let (_, meta) = MetaDir::open(&dir).unwrap();
|
let (_, meta) = MetaDir::open(&dir).unwrap();
|
||||||
let src = Source::Url(a[1].clone());
|
let src = Source::Url(a[1].clone());
|
||||||
let p = preview(&root, &meta, &src, coa_core::signing::EMBEDDED_PUBLIC_KEY, &Default::default()).unwrap_or_else(|e| panic!("preview failed: {e:?}"));
|
let p = preview(
|
||||||
println!("preview: {} -> {} | download {} bytes | {} files change | {} migrations | conflicts {:?}", p.from_version.clone().unwrap_or_default(), p.to_version, p.download_bytes, p.items.iter().filter(|i| format!("{:?}", i.action) != "Skip").count(), p.migrations, p.conflicts);
|
&root,
|
||||||
let env = RepackEnv { root: &root, meta_dir: &dir };
|
&meta,
|
||||||
|
&src,
|
||||||
|
coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
|
&Default::default(),
|
||||||
|
)
|
||||||
|
.unwrap_or_else(|e| panic!("preview failed: {e:?}"));
|
||||||
|
println!(
|
||||||
|
"preview: {} -> {} | download {} bytes | {} files change | {} migrations | conflicts {:?}",
|
||||||
|
p.from_version.clone().unwrap_or_default(),
|
||||||
|
p.to_version,
|
||||||
|
p.download_bytes,
|
||||||
|
p.items
|
||||||
|
.iter()
|
||||||
|
.filter(|i| format!("{:?}", i.action) != "Skip")
|
||||||
|
.count(),
|
||||||
|
p.migrations,
|
||||||
|
p.conflicts
|
||||||
|
);
|
||||||
|
let env = RepackEnv {
|
||||||
|
root: &root,
|
||||||
|
meta_dir: &dir,
|
||||||
|
};
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
let out = apply(
|
let out = apply(
|
||||||
&Params { root: &root, meta_dir: &dir, source: src, trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY, cancel: Cancel::default(), resolutions: Default::default(), env: &env, fail_after_ops: None },
|
&Params {
|
||||||
|
root: &root,
|
||||||
|
meta_dir: &dir,
|
||||||
|
source: src,
|
||||||
|
trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
|
cancel: Cancel::default(),
|
||||||
|
resolutions: Default::default(),
|
||||||
|
env: &env,
|
||||||
|
fail_after_ops: None,
|
||||||
|
},
|
||||||
&|s, pct| eprintln!(" {pct:>3}% {s}"),
|
&|s, pct| eprintln!(" {pct:>3}% {s}"),
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| panic!("apply failed: {e:?}"));
|
.unwrap_or_else(|e| panic!("apply failed: {e:?}"));
|
||||||
println!("apply finished in {:?}: state {:?}, to {:?}", t.elapsed(), out.txn.state, out.txn.to_version);
|
println!(
|
||||||
|
"apply finished in {:?}: state {:?}, to {:?}",
|
||||||
|
t.elapsed(),
|
||||||
|
out.txn.state,
|
||||||
|
out.txn.to_version
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -1,28 +1,62 @@
|
|||||||
//! Exercise the production updater only on a disposable copy of an installed server.
|
//! Exercise the production updater only on a disposable copy of an installed server.
|
||||||
use coa_core::{registry::MetaDir, update::{self, Env, RepackEnv}};
|
use coa_core::{
|
||||||
fn main() -> Result<(),Box<dyn std::error::Error>> {
|
registry::MetaDir,
|
||||||
let args:Vec<_>=std::env::args().collect();
|
update::{self, Env, RepackEnv},
|
||||||
if args.len()!=3 && args.len()!=4 {return Err("usage: upgrade_fixture <disposable-root> <signed-package-directory>".into());}
|
};
|
||||||
let root=std::path::Path::new(&args[1]);
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
assert!(root.file_name().unwrap().to_string_lossy().starts_with("coa-schema-fixture-real") && root.join(".coa-update-fixture").is_file(),"Disposable fixture required");
|
let args: Vec<_> = std::env::args().collect();
|
||||||
let meta=coa_core::registry::metadata_dir_for(root)?;
|
if args.len() != 3 && args.len() != 4 {
|
||||||
let (_,installed)=MetaDir::open(&meta)?;
|
return Err("usage: upgrade_fixture <disposable-root> <signed-package-directory>".into());
|
||||||
assert_eq!(coa_core::fsx::canonicalize_lenient(std::path::Path::new(&installed.server_path))?,coa_core::fsx::canonicalize_lenient(root)?,"Fixture metadata must point to the copy");
|
}
|
||||||
assert!(installed.client_path.is_none(),"Detach the real client from fixture metadata");
|
let root = std::path::Path::new(&args[1]);
|
||||||
let env=RepackEnv{root,meta_dir:&meta};
|
assert!(
|
||||||
if args.get(3).is_some_and(|flag|flag=="--validate-only") {
|
root.file_name()
|
||||||
let result=env.validate();
|
.unwrap()
|
||||||
let _=coa_core::driver::run(root,coa_core::driver::Verb::StopAll);
|
.to_string_lossy()
|
||||||
result?;
|
.starts_with("coa-schema-fixture-real")
|
||||||
println!("Startup and identity validation passed");
|
&& root.join(".coa-update-fixture").is_file(),
|
||||||
return Ok(());
|
"Disposable fixture required"
|
||||||
}
|
);
|
||||||
let outcome=update::apply(&update::Params{root,meta_dir:&meta,source:coa_core::pkgsource::Source::Dir(args[2].clone().into()),trusted_key:coa_core::signing::EMBEDDED_PUBLIC_KEY,cancel:Default::default(),resolutions:Default::default(),env:&env,fail_after_ops:None},&|phase,percent|println!("{percent}% {phase}"));
|
let meta = coa_core::registry::metadata_dir_for(root)?;
|
||||||
let stopped=coa_core::driver::run(root,coa_core::driver::Verb::StopAll);
|
let (_, installed) = MetaDir::open(&meta)?;
|
||||||
println!("Shutdown after test: {:?}",stopped.map(|r|r.ok));
|
assert_eq!(
|
||||||
let outcome=outcome?;
|
coa_core::fsx::canonicalize_lenient(std::path::Path::new(&installed.server_path))?,
|
||||||
println!("Final transaction: {:?}",outcome.txn.state);
|
coa_core::fsx::canonicalize_lenient(root)?,
|
||||||
env.ensure_stopped()?;
|
"Fixture metadata must point to the copy"
|
||||||
assert_eq!(outcome.txn.state,update::State::Committed);
|
);
|
||||||
Ok(())
|
assert!(
|
||||||
|
installed.client_path.is_none(),
|
||||||
|
"Detach the real client from fixture metadata"
|
||||||
|
);
|
||||||
|
let env = RepackEnv {
|
||||||
|
root,
|
||||||
|
meta_dir: &meta,
|
||||||
|
};
|
||||||
|
if args.get(3).is_some_and(|flag| flag == "--validate-only") {
|
||||||
|
let result = env.validate();
|
||||||
|
let _ = coa_core::driver::run(root, coa_core::driver::Verb::StopAll);
|
||||||
|
result?;
|
||||||
|
println!("Startup and identity validation passed");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
let outcome = update::apply(
|
||||||
|
&update::Params {
|
||||||
|
root,
|
||||||
|
meta_dir: &meta,
|
||||||
|
source: coa_core::pkgsource::Source::Dir(args[2].clone().into()),
|
||||||
|
trusted_key: coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||||
|
cancel: Default::default(),
|
||||||
|
resolutions: Default::default(),
|
||||||
|
env: &env,
|
||||||
|
fail_after_ops: None,
|
||||||
|
},
|
||||||
|
&|phase, percent| println!("{percent}% {phase}"),
|
||||||
|
);
|
||||||
|
let stopped = coa_core::driver::run(root, coa_core::driver::Verb::StopAll);
|
||||||
|
println!("Shutdown after test: {:?}", stopped.map(|r| r.ok));
|
||||||
|
let outcome = outcome?;
|
||||||
|
println!("Final transaction: {:?}", outcome.txn.state);
|
||||||
|
env.ensure_stopped()?;
|
||||||
|
assert_eq!(outcome.txn.state, update::State::Committed);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let m = std::env::args().nth(1).expect("usage: verify <manifest.json>");
|
let m = std::env::args()
|
||||||
|
.nth(1)
|
||||||
|
.expect("usage: verify <manifest.json>");
|
||||||
let bytes = std::fs::read(&m).unwrap();
|
let bytes = std::fs::read(&m).unwrap();
|
||||||
let sig = std::fs::read_to_string(format!("{m}.sig")).unwrap();
|
let sig = std::fs::read_to_string(format!("{m}.sig")).unwrap();
|
||||||
match coa_core::signing::verify_embedded(&bytes, &sig) {
|
match coa_core::signing::verify_embedded(&bytes, &sig) {
|
||||||
|
|||||||
@@ -1,15 +1,34 @@
|
|||||||
//! Reproduce applied migration history with five missing tables on a disposable MySQL fixture.
|
//! Reproduce applied migration history with five missing tables on a disposable MySQL fixture.
|
||||||
|
use coa_core::{
|
||||||
|
backup, fsx,
|
||||||
|
manifest::Migration,
|
||||||
|
migrations::{self, LedgerRow, Status, Store},
|
||||||
|
release_schema, schema_check, Error, Result,
|
||||||
|
};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use coa_core::{backup, fsx, manifest::Migration, migrations::{self, LedgerRow, Status, Store}, release_schema, schema_check, Error, Result};
|
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let mut args = std::env::args().skip(1);
|
let mut args = std::env::args().skip(1);
|
||||||
let root = PathBuf::from(args.next().ok_or_else(|| Error::Invalid("fixture path required".into()))?);
|
let root = PathBuf::from(
|
||||||
let old_sql = PathBuf::from(args.next().ok_or_else(|| Error::Invalid("core SQL directory required".into()))?);
|
args.next()
|
||||||
let repairs = PathBuf::from(args.next().ok_or_else(|| Error::Invalid("repair SQL directory required".into()))?);
|
.ok_or_else(|| Error::Invalid("fixture path required".into()))?,
|
||||||
if !root.file_name().is_some_and(|n| n.to_string_lossy().starts_with("coa-update-recovery-fixture-"))
|
);
|
||||||
|| !root.join("recovery-e2e-started").exists() {
|
let old_sql = PathBuf::from(
|
||||||
return Err(Error::Invalid("Refusing a non-disposable recovery fixture.".into()));
|
args.next()
|
||||||
|
.ok_or_else(|| Error::Invalid("core SQL directory required".into()))?,
|
||||||
|
);
|
||||||
|
let repairs = PathBuf::from(
|
||||||
|
args.next()
|
||||||
|
.ok_or_else(|| Error::Invalid("repair SQL directory required".into()))?,
|
||||||
|
);
|
||||||
|
if !root.file_name().is_some_and(|n| {
|
||||||
|
n.to_string_lossy()
|
||||||
|
.starts_with("coa-update-recovery-fixture-")
|
||||||
|
}) || !root.join("recovery-e2e-started").exists()
|
||||||
|
{
|
||||||
|
return Err(Error::Invalid(
|
||||||
|
"Refusing a non-disposable recovery fixture.".into(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
let tree = tempfile::tempdir()?;
|
let tree = tempfile::tempdir()?;
|
||||||
backup::with_database(&root, |db| {
|
backup::with_database(&root, |db| {
|
||||||
@@ -18,38 +37,90 @@ fn main() -> Result<()> {
|
|||||||
db.load()?;
|
db.load()?;
|
||||||
// Record exactly the old file hashes, as in the user's all-applied report.
|
// Record exactly the old file hashes, as in the user's all-applied report.
|
||||||
let mut migrations = Vec::new();
|
let mut migrations = Vec::new();
|
||||||
for name in ["rev_20260929_92_coa_wildcard_skill_cards", "rev_20260929_93_coa_wildcard_skill_card_duplicates", "rev_20260929_94_coa_wildcard_specialization_cache"] {
|
for name in [
|
||||||
|
"rev_20260929_92_coa_wildcard_skill_cards",
|
||||||
|
"rev_20260929_93_coa_wildcard_skill_card_duplicates",
|
||||||
|
"rev_20260929_94_coa_wildcard_specialization_cache",
|
||||||
|
] {
|
||||||
let path = old_sql.join(format!("{name}.sql"));
|
let path = old_sql.join(format!("{name}.sql"));
|
||||||
let hash = fsx::sha256_file(&path)?;
|
let hash = fsx::sha256_file(&path)?;
|
||||||
db.put(&LedgerRow { db: "characters".into(), id: name.into(), sha256: hash.clone(), status: Status::Applied, error: None, baseline: false })?;
|
db.put(&LedgerRow {
|
||||||
migrations.push(Migration { compatible_sha256: vec![], db: "characters".into(), id: name.into(), sha256: hash, destructive: false });
|
db: "characters".into(),
|
||||||
|
id: name.into(),
|
||||||
|
sha256: hash.clone(),
|
||||||
|
status: Status::Applied,
|
||||||
|
error: None,
|
||||||
|
baseline: false,
|
||||||
|
})?;
|
||||||
|
migrations.push(Migration {
|
||||||
|
compatible_sha256: vec![],
|
||||||
|
db: "characters".into(),
|
||||||
|
id: name.into(),
|
||||||
|
sha256: hash,
|
||||||
|
destructive: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
for (_, tables) in schema_check::WILDCARD_TABLES.iter().filter(|(kind,_)| *kind == "characters") {
|
for (_, tables) in schema_check::WILDCARD_TABLES
|
||||||
for table in *tables { db.query(&format!("DROP TABLE IF EXISTS acore_characters.`{table}`;"))?; }
|
.iter()
|
||||||
|
.filter(|(kind, _)| *kind == "characters")
|
||||||
|
{
|
||||||
|
for table in *tables {
|
||||||
|
db.query(&format!("DROP TABLE IF EXISTS acore_characters.`{table}`;"))?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert!(migrations::status(&db, &migrations)?.iter().all(|m| m.status == Status::Applied));
|
assert!(migrations::status(&db, &migrations)?
|
||||||
assert!(!db.tables("acore_characters")?.iter().any(|t| t == "coa_wildcard_skill_card"));
|
.iter()
|
||||||
|
.all(|m| m.status == Status::Applied));
|
||||||
|
assert!(!db
|
||||||
|
.tables("acore_characters")?
|
||||||
|
.iter()
|
||||||
|
.any(|t| t == "coa_wildcard_skill_card"));
|
||||||
let empty_core = tempfile::tempdir()?;
|
let empty_core = tempfile::tempdir()?;
|
||||||
let files = release_schema::collect(empty_core.path(), None, Some(&repairs))?;
|
let files = release_schema::collect(empty_core.path(), None, Some(&repairs))?;
|
||||||
assert_eq!(files.len(), 1);
|
assert_eq!(files.len(), 1);
|
||||||
let repair = &files[0];
|
let repair = &files[0];
|
||||||
migrations.push(Migration { compatible_sha256: vec![], db: repair.db.clone(), id: repair.id.clone(), sha256: repair.sha256.clone(), destructive: false });
|
migrations.push(Migration {
|
||||||
|
compatible_sha256: vec![],
|
||||||
|
db: repair.db.clone(),
|
||||||
|
id: repair.id.clone(),
|
||||||
|
sha256: repair.sha256.clone(),
|
||||||
|
destructive: false,
|
||||||
|
});
|
||||||
let staged = tree.path().join("sql/characters");
|
let staged = tree.path().join("sql/characters");
|
||||||
fsx::atomic_write(&staged.join(format!("{}.sql", repair.id)), &std::fs::read(&repair.abs)?)?;
|
fsx::atomic_write(
|
||||||
let report = migrations::apply_pending(&db, &migrations, &tree.path().join("sql"), &|| Ok("disposable fixture".into()))?;
|
&staged.join(format!("{}.sql", repair.id)),
|
||||||
|
&std::fs::read(&repair.abs)?,
|
||||||
|
)?;
|
||||||
|
let report =
|
||||||
|
migrations::apply_pending(&db, &migrations, &tree.path().join("sql"), &|| {
|
||||||
|
Ok("disposable fixture".into())
|
||||||
|
})?;
|
||||||
assert!(report.failed.is_none());
|
assert!(report.failed.is_none());
|
||||||
assert_eq!(report.applied, [repair.id.clone()]);
|
assert_eq!(&report.applied, std::slice::from_ref(&repair.id));
|
||||||
assert_eq!(db.query("SELECT COUNT(*) FROM acore_characters.characters;")?, characters);
|
assert_eq!(
|
||||||
|
db.query("SELECT COUNT(*) FROM acore_characters.characters;")?,
|
||||||
|
characters
|
||||||
|
);
|
||||||
db.query("INSERT INTO acore_characters.coa_wildcard_skill_card VALUES (77,123,456);")?;
|
db.query("INSERT INTO acore_characters.coa_wildcard_skill_card VALUES (77,123,456);")?;
|
||||||
db.run_sql_file("acore_characters", &repair.abs)?;
|
db.run_sql_file("acore_characters", &repair.abs)?;
|
||||||
assert_eq!(db.query("SELECT progress FROM acore_characters.coa_wildcard_skill_card WHERE account=77 AND card=123;")?, "456");
|
assert_eq!(db.query("SELECT progress FROM acore_characters.coa_wildcard_skill_card WHERE account=77 AND card=123;")?, "456");
|
||||||
assert!(migrations::apply_pending(&db, &migrations, &tree.path().join("sql"), &|| Ok("disposable fixture".into()))?.applied.is_empty());
|
assert!(
|
||||||
|
migrations::apply_pending(&db, &migrations, &tree.path().join("sql"), &|| Ok(
|
||||||
|
"disposable fixture".into()
|
||||||
|
))?
|
||||||
|
.applied
|
||||||
|
.is_empty()
|
||||||
|
);
|
||||||
schema_check::capture(&db, tree.path())?;
|
schema_check::capture(&db, tree.path())?;
|
||||||
db.query("DROP TABLE acore_characters.coa_wildcard_skill_card_purchase;")?;
|
db.query("DROP TABLE acore_characters.coa_wildcard_skill_card_purchase;")?;
|
||||||
assert!(schema_check::check(&db, tree.path())?.iter().any(|p| p.table == "coa_wildcard_skill_card_purchase" && p.detail == "Missing table"));
|
assert!(schema_check::check(&db, tree.path())?
|
||||||
|
.iter()
|
||||||
|
.any(|p| p.table == "coa_wildcard_skill_card_purchase" && p.detail == "Missing table"));
|
||||||
db.run_sql_file("acore_characters", &repair.abs)?;
|
db.run_sql_file("acore_characters", &repair.abs)?;
|
||||||
db.query("ALTER TABLE acore_characters.coa_wildcard_skill_card DROP COLUMN progress;")?;
|
db.query("ALTER TABLE acore_characters.coa_wildcard_skill_card DROP COLUMN progress;")?;
|
||||||
assert!(schema_check::check(&db, tree.path())?.iter().any(|p| p.table == "coa_wildcard_skill_card" && p.column == "progress"));
|
assert!(schema_check::check(&db, tree.path())?
|
||||||
|
.iter()
|
||||||
|
.any(|p| p.table == "coa_wildcard_skill_card" && p.column == "progress"));
|
||||||
db.query("ALTER TABLE acore_characters.coa_wildcard_skill_card ADD COLUMN progress INT UNSIGNED NOT NULL DEFAULT 0;")?;
|
db.query("ALTER TABLE acore_characters.coa_wildcard_skill_card ADD COLUMN progress INT UNSIGNED NOT NULL DEFAULT 0;")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
Loaded 100 of 583 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user