Пинг ванильным методом и причины отказа по токину

- StatusSession: ответ на ванильный статус на том же порту.
  Первый байт потока различает наш протокол и гостей: R - наш кадр,
  иначе старый пинг (FE) или новый handshake + request + ping.
  Логин в старом стиле получает вежливый отказ словами.
- Reader: первый байт, уже прочитанный вручную, теперь правильно
  исключается из головы - раньше счётчик дважды пропускал его.
- TokenAuth: точные причины отказа (не подписано, другой сервер,
  не тот вид, истёк, не тот игрок) и Verdict для каждой сессии.
- ClientSession: первое чтение смотрит на байт и отдаёт гостей статусу;
  остальное идёт через прежнее расщепление.
- StatusTest: 5 проверок (json, modern, pong, legacy, отказ). Легаси-пинг
  читался как знаковый байт; исправлено на беззнаковый.
- StatusRouteTest: 3 проверки через настоящий сервер и настоящие порты.
- watch-game.ps1: удаляет устаревший dev-token перед стартом сервера.
This commit is contained in:
sasheg dev
2026-10-22 19:25:06 +03:00
parent 6019654188
commit d98cd83fe5
8 changed files with 1012 additions and 31 deletions
+12 -4
View File
@@ -43,7 +43,10 @@ if ($line) {
}
$tokenFile = Join-Path $Root 'rsx-server-core\world\dev-token.txt'
if ($Fresh -and (Test-Path $tokenFile)) { Remove-Item $tokenFile -Force }
# The server makes a new secret every time it starts, so the token of the
# last run is of no use to it. It has to go, or the client will be given a
# token the server does not know and will be turned away at the door.
if (Test-Path $tokenFile) { Remove-Item $tokenFile -Force }
Write-Host 'starting the server'
$serverArgs = @(
@@ -51,7 +54,8 @@ $serverArgs = @(
'--port', "$Port",
'--accounts', (Join-Path $Root 'rsx-server-core\accounts.txt'),
'--world', (Join-Path $Root 'rsx-server-core\world'),
'--dev-token', $User
'--dev-token', $User,
'--bind', '127.0.0.1'
)
$java = 'D:\jdk-21\bin\java.exe'
if (-not (Test-Path $java)) { $java = (Get-Command java).Source }
@@ -59,11 +63,15 @@ $server = Start-Process -FilePath $java -ArgumentList $serverArgs `
-RedirectStandardOutput $ServerLog -RedirectStandardError "$ServerLog.err" -PassThru
Write-Host "server pid $($server.Id), log $ServerLog"
# the server writes its own token, and the client needs it
# The server writes its own token, and the client needs it. The file has to be
# the one this run wrote, not the one of the run before.
$token = $null
for ($i = 0; $i -lt 40; $i++) {
$started = Get-Date
for ($i = 0; $i -lt 60; $i++) {
Start-Sleep -Milliseconds 500
if (Test-Path $tokenFile) {
$written = (Get-Item $tokenFile).LastWriteTime
if ($written -lt $started) { continue }
$token = (Get-Content $tokenFile -Raw).Trim()
if ($token) { break }
}