mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
488ffe4bc8
- Protocol 5: a client authenticates as a node (Node), its pushes go to the section's DefaultTopic unless they name one; old Identities refused at start with what to write instead. - Topics listed by name, ids picked and kept by the server; nodes come from client sections, [BakaShrot.Nodes] optional, AcceptNodes = * by default. - Protocol 6: every refusal carries a code, every client failure too (BakaShrot_ErrorCodes.pbi, BakaShrot_GetLastError(), ErrorCode in Python); nothing reconnects by itself, delivery is at least once. - [BakaShrot.Server] Synchronous = FULL (default) or NORMAL, benchmarked. - Schema v8: browse table and browse_messages view for database tools. - Tools renamed BakaShrot<Name>, wait for Enter when started from Explorer. - Examples/SingleServer: a server and a client with scripts (example keys, public on purpose). - Restart-Test.ps1: servers killed mid-traffic and mid-catch-up. - Docs: one server per node rule, DatabaseError() checked per thread, release notes' Compatibility section, Notes "Right now". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RwFeVQrLqMQPw9AZnsHqQH
68 lines
2.6 KiB
PowerShell
68 lines
2.6 KiB
PowerShell
# ============================================================================
|
|
# BakaShrot example: starts the server with server.ini.
|
|
#
|
|
# In a window of its own by default (the server needs a console: it reads
|
|
# its commands there, and stops at once without one), then waits until it
|
|
# listens. Type "quit" in that window to stop it, "help" for the others.
|
|
#
|
|
# Usage: powershell -ExecutionPolicy Bypass -File Start-Server.ps1 [-BinDir <dir>] [-Here] [-Reset]
|
|
# -BinDir Where BakaShrot_Server.exe is, with libsodium.dll and
|
|
# sqlite3.dll: Build\ by default (Build.ps1), or a Release\<v>\.
|
|
# -Here Runs it in this console instead, until "quit".
|
|
# -Reset Deletes the example's database first: no messages, ids from 1.
|
|
#
|
|
# Its database, example.sqlite, goes next to this script.
|
|
# ============================================================================
|
|
|
|
param(
|
|
[string]$BinDir = (Join-Path $PSScriptRoot "..\..\Build"),
|
|
[switch]$Here,
|
|
[switch]$Reset
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$Server = Join-Path $BinDir "BakaShrot_Server.exe"
|
|
$Ini = Join-Path $PSScriptRoot "server.ini"
|
|
$Port = 12360
|
|
|
|
function Test-Port($Port) {
|
|
$Client = New-Object System.Net.Sockets.TcpClient
|
|
try {
|
|
$Async = $Client.BeginConnect("127.0.0.1", $Port, $null, $null)
|
|
return ($Async.AsyncWaitHandle.WaitOne(200) -and $Client.Connected)
|
|
} catch { return $false }
|
|
finally { $Client.Close() }
|
|
}
|
|
|
|
if (-not (Test-Path $Server)) {
|
|
throw "No ${Server}: build it first (Build.ps1), or pass -BinDir"
|
|
}
|
|
if (Test-Port $Port) {
|
|
throw "Something already listens on port $Port, the example server may already run"
|
|
}
|
|
|
|
if ($Reset) {
|
|
Get-ChildItem $PSScriptRoot -Filter "example.sqlite*" | Remove-Item -Confirm:$false
|
|
Write-Host "Deleted the example's database"
|
|
}
|
|
|
|
if ($Here) {
|
|
Push-Location $PSScriptRoot
|
|
try { & $Server $Ini }
|
|
finally { Pop-Location }
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
$Process = Start-Process -FilePath $Server -ArgumentList "`"$Ini`"" -WorkingDirectory $PSScriptRoot -PassThru
|
|
$Deadline = (Get-Date).AddSeconds(15)
|
|
while (-not (Test-Port $Port)) {
|
|
if ($Process.HasExited) { throw "The server stopped with code $($Process.ExitCode), see its log above" }
|
|
if ((Get-Date) -gt $Deadline) { throw "The server isn't listening on $Port after 15 s" }
|
|
Start-Sleep -Milliseconds 100
|
|
}
|
|
|
|
Write-Host "The server runs in its own window (process $($Process.Id)), on 127.0.0.1:$Port."
|
|
Write-Host "Try it with: powershell -ExecutionPolicy Bypass -File `"$(Join-Path $PSScriptRoot 'Run-Client.ps1')`""
|
|
Write-Host "Stop it by typing quit in its window."
|