3 Commits

10 changed files with 671 additions and 40 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ GPL-licensed implementation. This file says what may be read, what may not, and
| [Moonshine](https://github.com/hgaiser/moonshine) | BSD-2-Clause | May be read. Facts taken are logged below. Code is not copied; if a snippet is ever borrowed, it keeps Moonshine's copyright line and licence text in the file that holds it. | | [Moonshine](https://github.com/hgaiser/moonshine) | BSD-2-Clause | May be read. Facts taken are logged below. Code is not copied; if a snippet is ever borrowed, it keeps Moonshine's copyright line and licence text in the file that holds it. |
| RFCs and standards (RTP RFC 3550, RTSP RFC 2326, SDP RFC 4566, Opus RFC 6716 / RFC 7845, AES FIPS 197, GCM/CBC NIST SP 800-38D/38A, PKCS #1 RFC 8017, X.509 RFC 5280) | open standards | Read freely. | | RFCs and standards (RTP RFC 3550, RTSP RFC 2326, SDP RFC 4566, Opus RFC 6716 / RFC 7845, AES FIPS 197, GCM/CBC NIST SP 800-38D/38A, PKCS #1 RFC 8017, X.509 RFC 5280) | open standards | Read freely. |
| Crate docs (docs.rs, crates.io, crate READMEs) | per crate | Read freely. | | Crate docs (docs.rs, crates.io, crate READMEs) | per crate | Read freely. |
| Our own measurements | ours | Captures through our own relay ([tools/lab-relay](../tools/lab-relay)). Mark allowed **one** capture on his PC (answer 16, 2026-11-25), done exactly as [LAB_CAPTURE.md](LAB_CAPTURE.md) says; never his TV, never 192.168.100.217. Recordings stay on F: under `F:\Akce\DomiStream-lab\`, out of git; only facts and test vectors derived from them go in, with the date and setup. | | Our own measurements | ours | Captures through our own relay ([tools/lab-relay](../tools/lab-relay)). Mark allowed **one** capture on his PC (answer 16, 2026-11-25), done exactly as [LAB_CAPTURE.md](LAB_CAPTURE.md) says; never his TV, never 192.168.100.217. Recordings stay local (on E:, approved for Play remotely) under `E:\build\play-remotely\lab\`, out of git; only facts and test vectors derived from them go in, with the date and setup. |
| Official Sunshine and Moonlight PC **binaries** in that capture | GPL-3.0 (we only run them) | Black-box peers: run, observe their traffic, their `--help` output, their own logs and the files/registry keys they write. Never open their source, never disassemble or decompile them. | | Official Sunshine and Moonlight PC **binaries** in that capture | GPL-3.0 (we only run them) | Black-box peers: run, observe their traffic, their `--help` output, their own logs and the files/registry keys they write. Never open their source, never disassemble or decompile them. |
| READMEs and wikis of forbidden projects | n/a | For facts only (licence, release notes, compatibility statements). Never their source files. | | READMEs and wikis of forbidden projects | n/a | For facts only (licence, release notes, compatibility statements). Never their source files. |
+16 -14
View File
@@ -11,16 +11,16 @@ the files they write. We never open their source, never disassemble them ([CLEAN
Hard limits: Hard limits:
- One stream of the **Desktop** app, no game. Nothing touches the TV or 192.168.100.217. - One stream of the **Desktop** app, no game. Nothing touches the TV or 192.168.100.217.
- Every listening socket is on loopback: Sunshine on `127.0.0.2`, the relay on `127.0.0.1`. - Every listening socket is on loopback: Sunshine on `127.0.0.2`, the relay on `127.0.0.1`.
- Lab keys and credentials live only under `F:\Akce\DomiStream-lab\`, are never printed, never on a command line that - Lab keys and credentials live only under `E:\build\play-remotely\lab\`, are never printed, never on a command line that
survives, never in git, and are deleted at the end. survives, never in git, and are deleted at the end.
- Recordings stay under `F:\Akce\DomiStream-lab\captures\`, out of git. Only derived facts and test vectors go into - Recordings stay under `E:\build\play-remotely\lab\captures\`, out of git. Only derived facts and test vectors go into
the docs. the docs.
- One UAC prompt in total. - One UAC prompt in total.
## 0. Layout ## 0. Layout
``` ```
F:\Akce\DomiStream-lab\ E:\build\play-remotely\lab\
downloads\ Sunshine MSI and the Moonlight portable zip, as downloaded (untrusted until the sha256 matches) downloads\ Sunshine MSI and the Moonlight portable zip, as downloaded (untrusted until the sha256 matches)
moonlight\ the extracted Moonlight portable folder moonlight\ the extracted Moonlight portable folder
keys\ lab-only TLS material (ACL: Mark's account + SYSTEM): Sunshine lab cert/key, Moonlight lab cert/key keys\ lab-only TLS material (ACL: Mark's account + SYSTEM): Sunshine lab cert/key, Moonlight lab cert/key
@@ -29,12 +29,14 @@ F:\Akce\DomiStream-lab\
``` ```
Our scripts and the relay come from this repo (`tools/lab-relay/`) and run from it, never from `downloads\`. Our scripts and the relay come from this repo (`tools/lab-relay/`) and run from it, never from `downloads\`.
The relay source is written but **has never been compiled** (the disk rule held every build back). The two Built and checked on 2026-11-25 (Windows MSVC, stable 1.99, `-j 2`): `cargo test` 28 passed, `cargo clippy
PowerShell scripts named below (`lab-install.ps1`, `lab-api.ps1`) are **not written yet**; they come with the first --all-targets -- -D warnings` and `cargo fmt --check` clean. The relay has **not been run** yet. The two scripts
build, for the build lead to read before anything runs. (`tools/lab-relay/scripts/lab-install.ps1`, `lab-api.ps1`) have been parse-checked only, never run; the build lead
reads them before anything goes to Mark.
The relay is built with `-j 2` and only while CPU, RAM and every drive the build writes to are below 90 % The lab root is on E: (approved for Play remotely). The relay is built in `E:uild\play-remotely\DomiStream-wt-lab`
(DomiStream CLAUDE.md). with `TEMP`/`TMP` set to `E:uild\play-remotely mp`, `-j 2`, and only while CPU, RAM, D: and E: are all below
90 % (DomiStream CLAUDE.md).
## 1. Step (a): the old Sunshine is gone (read-only) ## 1. Step (a): the old Sunshine is gone (read-only)
@@ -61,7 +63,7 @@ sha256 `1d7fed8beecd5889dc7ff14cf9f42d6d38f37c3066c13c6c2a5f4e91847e0ccf`,
The same digest is checked twice: against this pin and against the release API's `digest` field fetched at download The same digest is checked twice: against this pin and against the release API's `digest` field fetched at download
time. A mismatch on either = delete the file and stop. time. A mismatch on either = delete the file and stop.
Download (not elevated): `Invoke-WebRequest -Uri <url> -OutFile F:\Akce\DomiStream-lab\downloads\Sunshine-Windows-AMD64-installer.msi`, Download (not elevated): `Invoke-WebRequest -Uri <url> -OutFile E:\build\play-remotely\lab\downloads\Sunshine-Windows-AMD64-installer.msi`,
then `Get-FileHash -Algorithm SHA256`. Nothing is run from `downloads\` before the hash matches. then `Get-FileHash -Algorithm SHA256`. Nothing is run from `downloads\` before the hash matches.
**Why one elevated script, not a bare `msiexec`:** Sunshine's first start must already be bound to loopback, and **Why one elevated script, not a bare `msiexec`:** Sunshine's first start must already be bound to loopback, and
@@ -70,7 +72,7 @@ on all interfaces with no credentials. So we start **one** elevated PowerShell (
with our script `tools/lab-relay/scripts/lab-install.ps1`). That is the one UAC prompt ("Windows PowerShell", with our script `tools/lab-relay/scripts/lab-install.ps1`). That is the one UAC prompt ("Windows PowerShell",
publisher Microsoft Windows). Inside it, without further prompts: publisher Microsoft Windows). Inside it, without further prompts:
1. `msiexec /i <msi> /qn /norestart /l*v F:\Akce\DomiStream-lab\captures\msiexec.log` (quiet; elevated already). 1. `msiexec /i <msi> /qn /norestart /l*v E:\build\play-remotely\lab\captures\msiexec.log` (quiet; elevated already).
2. `Stop-Service SunshineService` as soon as the MSI returns (the MSI starts it; until our config is in, it has no 2. `Stop-Service SunshineService` as soon as the MSI returns (the MSI starts it; until our config is in, it has no
credentials, so nobody can pair or call its API). credentials, so nobody can pair or call its API).
3. Write `C:\Program Files\Sunshine\config\sunshine.conf` with only these lines: 3. Write `C:\Program Files\Sunshine\config\sunshine.conf` with only these lines:
@@ -85,8 +87,8 @@ publisher Microsoft Windows). Inside it, without further prompts:
lan_encryption_mode = 1 lan_encryption_mode = 1
wan_encryption_mode = 1 wan_encryption_mode = 1
min_log_level = debug min_log_level = debug
pkey = F:/Akce/DomiStream-lab/keys/sunshine-lab-key.pem pkey = E:/build/play-remotely/lab/keys/sunshine-lab-key.pem
cert = F:/Akce/DomiStream-lab/keys/sunshine-lab-cert.pem cert = E:/build/play-remotely/lab/keys/sunshine-lab-cert.pem
``` ```
Forward slashes in paths: how the config parser treats backslashes is not documented. Encryption mode 1 ("if the client supports it") rather than 2: if Moonlight PC lacks one kind of encryption, a Forward slashes in paths: how the config parser treats backslashes is not documented. Encryption mode 1 ("if the client supports it") rather than 2: if Moonlight PC lacks one kind of encryption, a
@@ -116,7 +118,7 @@ so they expose nothing. Changing them needs admin and is left to Arena Day 1.
**Pin** (release API, S-19): `v6.2.0` (2026-10-04), `MoonlightPortable-x64-6.2.0.zip`, 37,242,232 bytes, **Pin** (release API, S-19): `v6.2.0` (2026-10-04), `MoonlightPortable-x64-6.2.0.zip`, 37,242,232 bytes,
sha256 `6f91d268b41ed5ca8066d9d7578dc403b8db190991ff48f00b1700465f8f7ebf`, sha256 `6f91d268b41ed5ca8066d9d7578dc403b8db190991ff48f00b1700465f8f7ebf`,
`https://github.com/moonlight-stream/moonlight-qt/releases/download/v6.2.0/MoonlightPortable-x64-6.2.0.zip`. `https://github.com/moonlight-stream/moonlight-qt/releases/download/v6.2.0/MoonlightPortable-x64-6.2.0.zip`.
Download to `downloads\`, check the hash (pin and API digest), extract to `F:\Akce\DomiStream-lab\moonlight\`. Download to `downloads\`, check the hash (pin and API digest), extract to `E:\build\play-remotely\lab\moonlight\`.
No installer, no admin. No installer, no admin.
Before its first start we snapshot (names only) the `moonlight\` folder tree and the key names under Before its first start we snapshot (names only) the `moonlight\` folder tree and the key names under
@@ -236,7 +238,7 @@ re-encrypted with test keys generated in the test).
5. Keep `secrets\sunshine-lab.cred` until Arena's Day 1 takeover rotates the credentials into Custos, then delete it. 5. Keep `secrets\sunshine-lab.cred` until Arena's Day 1 takeover rotates the credentials into Custos, then delete it.
6. Delete `downloads\Moonlight*.zip`. Keep the Sunshine MSI (Arena Day 1 pins the same version). 6. Delete `downloads\Moonlight*.zip`. Keep the Sunshine MSI (Arena Day 1 pins the same version).
7. Sunshine **stays installed**, bound to 127.0.0.2, ready for Arena's Day 1 takeover. 7. Sunshine **stays installed**, bound to 127.0.0.2, ready for Arena's Day 1 takeover.
8. The recordings stay on F: until the facts are in PROTOCOL.md and QA has its vectors; then they are deleted on the 8. The recordings stay on E: until the facts are in PROTOCOL.md and QA has its vectors; then they are deleted on the
build lead's word. build lead's word.
## 6. If something fails ## 6. If something fails
+208
View File
@@ -0,0 +1,208 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "cc"
version = "1.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02f0e023adb368345ce0ca6cdfc0f24a06554468d0e8503e14a0841de79bfa69"
dependencies = [
"find-msvc-tools",
"shlex",
]
[[package]]
name = "cfg-if"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
[[package]]
name = "find-msvc-tools"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
[[package]]
name = "getrandom"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]]
name = "lab-relay"
version = "0.1.0"
dependencies = [
"ring",
"rustls",
"rustls-pki-types",
]
[[package]]
name = "libc"
version = "0.2.191"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
[[package]]
name = "once_cell"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "ring"
version = "0.17.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
dependencies = [
"cc",
"cfg-if",
"getrandom",
"libc",
"untrusted",
"windows-sys",
]
[[package]]
name = "rustls"
version = "0.23.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf"
dependencies = [
"once_cell",
"ring",
"rustls-pki-types",
"rustls-webpki",
"subtle",
"zeroize",
]
[[package]]
name = "rustls-pki-types"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb"
dependencies = [
"zeroize",
]
[[package]]
name = "rustls-webpki"
version = "0.103.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5"
dependencies = [
"ring",
"rustls-pki-types",
"untrusted",
]
[[package]]
name = "shlex"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
[[package]]
name = "subtle"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "untrusted"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "wasi"
version = "0.11.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "zeroize"
version = "1.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85ccff8a4805aba1eaa4cd4afcd49f7557dd2cf5fd79ffc37f8959466effc5aa"
+183
View File
@@ -0,0 +1,183 @@
<#
.SYNOPSIS
Lab capture: talk to the lab Sunshine's local API (docs/LAB_CAPTURE.md sections 2, 3, 5). Not elevated.
.DESCRIPTION
Every call goes to https://127.0.0.2:47990 with Basic auth built in memory, no Origin/Referer header (the
documented non-browser path), TLS pinned to the lab certificate in keys\ byte for byte.
Credentials come only from DPAPI files in secrets\; they are never printed, logged or put on a command line.
-Action Rotate throwaway credentials (from lab-install.ps1) -> fresh lab credentials; deletes the throwaway
-Action Status lists paired clients and apps (names only)
-Action Pin submits the PIN Moonlight shows: -PinFile <file with 4 digits> (the file is deleted after
reading), optional -PairingId, -ClientName (default "DomiStream lab Moonlight")
-Action Logs saves GET /api/logs to captures\sunshine.log (not printed: it may hold secrets)
-Action Cleanup unpair all clients, drop the lab cert/key from the config (bind_address stays 127.0.0.2),
restart Sunshine
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidateSet('Rotate', 'Status', 'Pin', 'Logs', 'Cleanup')]
[string] $Action,
[string] $LabRoot = 'E:\build\play-remotely\lab',
[string] $PinFile,
[string] $PairingId,
[string] $ClientName = 'DomiStream lab Moonlight'
)
Set-StrictMode -Version 2.0
$ErrorActionPreference = 'Stop'
$BaseUrl = 'https://127.0.0.2:47990'
$keys = Join-Path $LabRoot 'keys'
$secrets = Join-Path $LabRoot 'secrets'
$captures = Join-Path $LabRoot 'captures'
$throwawayFile = Join-Path $secrets 'sunshine-throwaway.cred'
$labFile = Join-Path $secrets 'sunshine-lab.cred'
$certFile = Join-Path $keys 'sunshine-lab-cert.pem'
function Fail([string] $Why) {
Write-Host "lab-api: STOPPED: $Why"
exit 1
}
# --- TLS pinning: accept exactly the lab certificate -------------------------------------------------------------
if (-not (Test-Path -LiteralPath $certFile)) { Fail "lab certificate not found: $certFile" }
$pem = Get-Content -LiteralPath $certFile -Raw
$m = [regex]::Match($pem, '-----BEGIN CERTIFICATE-----([A-Za-z0-9+/=\s]+)-----END CERTIFICATE-----')
if (-not $m.Success) { Fail 'lab certificate is not PEM' }
$pinnedDer = [Convert]::FromBase64String(($m.Groups[1].Value -replace '\s', ''))
if (-not ('DomiLabPin' -as [type])) {
Add-Type -TypeDefinition @'
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public static class DomiLabPin {
public static byte[] Pinned;
public static bool Check(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors errors) {
if (cert == null || Pinned == null) return false;
byte[] raw = cert.GetRawCertData();
if (raw.Length != Pinned.Length) return false;
int diff = 0;
for (int i = 0; i < raw.Length; i++) diff |= raw[i] ^ Pinned[i];
return diff == 0;
}
public static void Install() {
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(Check);
}
}
'@
}
[DomiLabPin]::Pinned = $pinnedDer
[DomiLabPin]::Install()
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# --- Credentials -------------------------------------------------------------------------------------------------
function Read-Cred([string] $File) {
if (-not (Test-Path -LiteralPath $File)) { Fail "credentials file not found: $File" }
$j = Get-Content -LiteralPath $File -Raw | ConvertFrom-Json
$u = New-Object Management.Automation.PSCredential('x', ($j.user | ConvertTo-SecureString))
$p = New-Object Management.Automation.PSCredential('x', ($j.password | ConvertTo-SecureString))
return @{ User = $u.GetNetworkCredential().Password; Password = $p.GetNetworkCredential().Password }
}
function Save-Cred([string] $File, [string] $User, [string] $Password) {
@{
user = (ConvertTo-SecureString -String $User -AsPlainText -Force | ConvertFrom-SecureString)
password = (ConvertTo-SecureString -String $Password -AsPlainText -Force | ConvertFrom-SecureString)
} | ConvertTo-Json | Set-Content -LiteralPath $File -Encoding ASCII
}
function New-Secret {
$bytes = New-Object byte[] 32
$rng = [Security.Cryptography.RandomNumberGenerator]::Create()
$rng.GetBytes($bytes)
$rng.Dispose()
return ([Convert]::ToBase64String($bytes)).TrimEnd('=').Replace('+', '-').Replace('/', '_')
}
# --- One API call ------------------------------------------------------------------------------------------------
function Invoke-Sunshine([hashtable] $Cred, [string] $Method, [string] $Path, $Body, [string] $OutFile) {
$pair = [Text.Encoding]::UTF8.GetBytes($Cred.User + ':' + $Cred.Password)
$headers = @{ Authorization = 'Basic ' + [Convert]::ToBase64String($pair) }
$req = @{ Uri = $BaseUrl + $Path; Method = $Method; Headers = $headers; UseBasicParsing = $true; TimeoutSec = 30 }
if ($null -ne $Body) {
$req.Body = ($Body | ConvertTo-Json -Depth 5 -Compress)
$req.ContentType = 'application/json'
}
try {
if ($OutFile) {
Invoke-WebRequest @req -OutFile $OutFile | Out-Null
return $null
}
return Invoke-RestMethod @req
} catch {
# The message names the call only; the request, which holds the credentials, is never echoed.
Fail "$Method $Path failed: $($_.Exception.GetType().Name)"
}
}
# --- Actions -----------------------------------------------------------------------------------------------------
switch ($Action) {
'Rotate' {
$old = Read-Cred $throwawayFile
$newUser = 'lab' + (New-Secret).Substring(0, 12)
$newPass = New-Secret
$null = Invoke-Sunshine $old 'POST' '/api/password' @{
currentUsername = $old.User
currentPassword = $old.Password
newUsername = $newUser
newPassword = $newPass
confirmNewPassword = $newPass
}
Save-Cred $labFile $newUser $newPass
# Prove the new pair works before forgetting the old one.
$null = Invoke-Sunshine (Read-Cred $labFile) 'GET' '/api/clients/list' $null
Remove-Item -LiteralPath $throwawayFile -Force
Write-Host 'lab-api: credentials rotated; throwaway deleted'
}
'Status' {
$c = Read-Cred $labFile
$clients = Invoke-Sunshine $c 'GET' '/api/clients/list' $null
$apps = Invoke-Sunshine $c 'GET' '/api/apps' $null
Write-Host ('lab-api: clients: ' + (($clients | ConvertTo-Json -Depth 4 -Compress)))
Write-Host ('lab-api: apps: ' + ((@($apps.apps) | ForEach-Object { $_.name }) -join ', '))
}
'Pin' {
if (-not $PinFile) { Fail '-PinFile is required' }
$pin = (Get-Content -LiteralPath $PinFile -Raw).Trim()
Remove-Item -LiteralPath $PinFile -Force
if ($pin -notmatch '^[0-9]{4}$') { Fail 'the PIN file must hold exactly 4 digits' }
$body = @{ pin = $pin; name = $ClientName }
if ($PairingId) { $body.pairing_id = $PairingId }
$r = Invoke-Sunshine (Read-Cred $labFile) 'POST' '/api/pin' $body
Write-Host ('lab-api: PIN submitted, answer: ' + ($r | ConvertTo-Json -Compress))
}
'Logs' {
$out = Join-Path $captures 'sunshine.log'
$null = Invoke-Sunshine (Read-Cred $labFile) 'GET' '/api/logs' $null $out
Write-Host "lab-api: Sunshine log saved to $out (not shown: it may hold secrets)"
}
'Cleanup' {
$c = Read-Cred $labFile
$null = Invoke-Sunshine $c 'POST' '/api/clients/unpair-all' $null
# Same loopback-only config as lab-install.ps1, without the lab cert/key, so Sunshine makes a fresh pair.
$null = Invoke-Sunshine $c 'POST' '/api/config' @{
bind_address = '127.0.0.2'
address_family = 'ipv4'
origin_web_ui_allowed = 'pc'
upnp = 'disabled'
external_ip = '127.0.0.2'
sunshine_name = 'DomiStream-lab'
lan_encryption_mode = '1'
wan_encryption_mode = '1'
}
$null = Invoke-Sunshine $c 'POST' '/api/restart' $null
Write-Host 'lab-api: unpaired all clients, lab cert/key dropped from the config, Sunshine restarting'
Write-Host 'lab-api: next: delete keys\sunshine-lab-*.pem and keys\moonlight-lab-*.pem once Sunshine is back'
}
}
exit 0
+217
View File
@@ -0,0 +1,217 @@
<#
.SYNOPSIS
Lab capture step (b): install the pinned Sunshine bound to 127.0.0.2 only (docs/LAB_CAPTURE.md section 2).
.DESCRIPTION
Runs ELEVATED, once, started by the operator with:
Start-Process powershell -Verb RunAs -ArgumentList '-NoProfile','-ExecutionPolicy','Bypass','-File',
'<repo>\tools\lab-relay\scripts\lab-install.ps1'
That is the one UAC prompt of the lab capture.
What it does, in order, and nothing else:
1. Refuses unless elevated, unless the MSI's sha256 matches the pin, and unless no Sunshine is installed.
2. Creates keys\, secrets\, captures\ under the lab root, readable only by this account and SYSTEM.
3. msiexec /i (quiet, logged to captures\msiexec.log), then stops the service the MSI started.
4. Writes sunshine.conf: bind_address 127.0.0.2, web UI for this PC only, no UPnP, lab cert/key under keys\.
5. Sets throwaway web-UI credentials with `sunshine --creds` (they exist only in that one process's argv and
in a DPAPI-protected file; lab-api.ps1 -Action Rotate replaces them).
6. Starts the service and checks that every Sunshine listener is on 127.0.0.2. Anything else: stop, fail.
It does not touch Windows Defender, firewall rules (it only lists the ones the MSI added), or any other app.
It never prints, logs or writes a credential in plain text.
#>
[CmdletBinding()]
param(
[string] $LabRoot = 'E:\build\play-remotely\lab',
[string] $Msi = 'E:\build\play-remotely\lab\downloads\Sunshine-Windows-AMD64-installer.msi'
)
Set-StrictMode -Version 2.0
$ErrorActionPreference = 'Stop'
# --- Pins (release API, docs/LAB_CAPTURE.md section 2) ------------------------------------------------------------
$PinnedSha256 = '1d7fed8beecd5889dc7ff14cf9f42d6d38f37c3066c13c6c2a5f4e91847e0ccf'
$PinnedSize = 33710080
$BindAddress = '127.0.0.2'
$Ports = @(47984, 47989, 47990, 48010)
function Fail([string] $Why) {
Write-Host "lab-install: STOPPED: $Why"
exit 1
}
function Say([string] $What) {
Write-Host "lab-install: $What"
}
# --- 1. Preconditions --------------------------------------------------------------------------------------------
$principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Fail 'not elevated; start it with Start-Process -Verb RunAs'
}
if (-not (Test-Path -LiteralPath $Msi -PathType Leaf)) { Fail "MSI not found: $Msi" }
$msiItem = Get-Item -LiteralPath $Msi
if ($msiItem.Length -ne $PinnedSize) { Fail "MSI size $($msiItem.Length) is not the pinned $PinnedSize" }
$hash = (Get-FileHash -LiteralPath $Msi -Algorithm SHA256).Hash.ToLowerInvariant()
if ($hash -ne $PinnedSha256) { Fail "MSI sha256 $hash does not match the pin; delete the file" }
Say 'MSI matches the pinned sha256'
if (Get-Service -Name '*sunshine*' -ErrorAction SilentlyContinue) { Fail 'a Sunshine service already exists' }
if (Test-Path -LiteralPath 'C:\Program Files\Sunshine\sunshine.exe') { Fail 'C:\Program Files\Sunshine\sunshine.exe already exists' }
$busy = Get-NetTCPConnection -State Listen -ErrorAction SilentlyContinue | Where-Object { $Ports -contains $_.LocalPort }
if ($busy) { Fail 'a GameStream port is already in use' }
# --- 2. Lab folders, this account + SYSTEM only ------------------------------------------------------------------
$account = [Security.Principal.WindowsIdentity]::GetCurrent().Name
$keys = Join-Path $LabRoot 'keys'
$secrets = Join-Path $LabRoot 'secrets'
$captures = Join-Path $LabRoot 'captures'
foreach ($dir in @($keys, $secrets, $captures)) {
New-Item -ItemType Directory -Force -Path $dir | Out-Null
& icacls.exe $dir /inheritance:r /grant:r "${account}:(OI)(CI)F" '*S-1-5-18:(OI)(CI)F' | Out-Null
if ($LASTEXITCODE -ne 0) { Fail "icacls failed on $dir" }
}
$hostKey = Join-Path $keys 'sunshine-lab-key.pem'
$hostCert = Join-Path $keys 'sunshine-lab-cert.pem'
foreach ($f in @($hostKey, $hostCert)) { if (Test-Path -LiteralPath $f) { Fail "$f already exists; clean up first" } }
Say "lab folders ready under $LabRoot"
# --- 3. Install ----------------------------------------------------------------------------------------------------
$msiLog = Join-Path $captures 'msiexec.log'
$p = Start-Process -FilePath 'msiexec.exe' -ArgumentList @('/i', "`"$Msi`"", '/qn', '/norestart', '/l*v', "`"$msiLog`"") -Wait -PassThru
if ($p.ExitCode -ne 0 -and $p.ExitCode -ne 3010) { Fail "msiexec exit code $($p.ExitCode); see $msiLog" }
Say "MSI installed (exit code $($p.ExitCode))"
$service = Get-CimInstance Win32_Service | Where-Object { $_.PathName -like '*Sunshine*' } | Select-Object -First 1
if (-not $service) { Fail 'no Sunshine service after the install' }
Stop-Service -Name $service.Name -Force
Say "service $($service.Name) stopped until the config is in"
$exe = 'C:\Program Files\Sunshine\sunshine.exe'
if (-not (Test-Path -LiteralPath $exe)) { Fail "$exe not found after the install" }
$installDir = Split-Path -Parent $exe
$configDir = Join-Path $installDir 'config'
New-Item -ItemType Directory -Force -Path $configDir | Out-Null
$conf = Join-Path $configDir 'sunshine.conf'
if (Test-Path -LiteralPath $conf) { Copy-Item -LiteralPath $conf -Destination (Join-Path $captures 'sunshine.conf.as-installed') -Force }
# --- 4. Config: loopback only ------------------------------------------------------------------------------------
function Write-Conf([bool] $WithLabKeys) {
$lines = @(
"bind_address = $BindAddress",
'address_family = ipv4',
'origin_web_ui_allowed = pc',
'upnp = disabled',
"external_ip = $BindAddress",
'sunshine_name = DomiStream-lab',
'lan_encryption_mode = 1',
'wan_encryption_mode = 1',
'min_log_level = debug'
)
if ($WithLabKeys) {
# Forward slashes: how the config parser treats backslashes is not documented.
$lines += 'pkey = ' + ($hostKey -replace '\\', '/')
$lines += 'cert = ' + ($hostCert -replace '\\', '/')
}
[IO.File]::WriteAllLines($conf, [string[]] $lines, (New-Object Text.UTF8Encoding($false)))
}
Write-Conf $true
Say 'sunshine.conf written (bind_address 127.0.0.2)'
# --- 5. Throwaway credentials ------------------------------------------------------------------------------------
function New-Secret {
$bytes = New-Object byte[] 32
$rng = [Security.Cryptography.RandomNumberGenerator]::Create()
$rng.GetBytes($bytes)
$rng.Dispose()
# base64url: only [A-Za-z0-9_-], so it needs no quoting on a command line.
return ([Convert]::ToBase64String($bytes)).TrimEnd('=').Replace('+', '-').Replace('/', '_')
}
$user = 'lab' + (New-Secret).Substring(0, 12)
$pass = New-Secret
# One child process; its argv dies with it. Output is read and discarded, never written anywhere.
$psi = New-Object Diagnostics.ProcessStartInfo
$psi.FileName = $exe
$psi.Arguments = "--creds $user $pass"
$psi.WorkingDirectory = $installDir
$psi.UseShellExecute = $false
$psi.CreateNoWindow = $true
$psi.RedirectStandardOutput = $true
$psi.RedirectStandardError = $true
$proc = [Diagnostics.Process]::Start($psi)
$null = $proc.StandardOutput.ReadToEnd()
$null = $proc.StandardError.ReadToEnd()
if (-not $proc.WaitForExit(60000)) { $proc.Kill(); Fail 'sunshine --creds did not finish' }
$credsExit = $proc.ExitCode
$psi = $null
$proc.Dispose()
if ($credsExit -ne 0) { Fail "sunshine --creds exit code $credsExit" }
# DPAPI (this account): readable only by this account on this PC; lab-api.ps1 -Action Rotate replaces it.
$throwaway = Join-Path $secrets 'sunshine-throwaway.cred'
@{
user = (ConvertTo-SecureString -String $user -AsPlainText -Force | ConvertFrom-SecureString)
password = (ConvertTo-SecureString -String $pass -AsPlainText -Force | ConvertFrom-SecureString)
} | ConvertTo-Json | Set-Content -LiteralPath $throwaway -Encoding ASCII
Remove-Variable -Name user, pass -ErrorAction SilentlyContinue
Say 'throwaway credentials set and stored (DPAPI)'
# --- 6. Start and check the binding ------------------------------------------------------------------------------
function Wait-Listeners([int] $Seconds) {
$deadline = (Get-Date).AddSeconds($Seconds)
while ((Get-Date) -lt $deadline) {
$l = Get-NetTCPConnection -State Listen -ErrorAction SilentlyContinue | Where-Object { $Ports -contains $_.LocalPort }
if ($l -and (@($l | Select-Object -ExpandProperty LocalPort -Unique).Count -eq $Ports.Count)) { return $l }
Start-Sleep -Milliseconds 500
}
return $null
}
function Assert-Loopback($Listeners) {
$wrong = @($Listeners | Where-Object { $_.LocalAddress -ne $BindAddress })
if ($wrong.Count -gt 0) {
Stop-Service -Name $service.Name -Force
Fail ('Sunshine listened on ' + (($wrong | ForEach-Object { "$($_.LocalAddress):$($_.LocalPort)" }) -join ', ') + '; service stopped')
}
}
Start-Service -Name $service.Name
$listeners = Wait-Listeners 60
if (-not $listeners) {
Stop-Service -Name $service.Name -Force
Fail 'Sunshine did not listen on all four TCP ports; service stopped (bind_address 127.0.0.2 refused? see LAB_CAPTURE.md section 4 fallback)'
}
Assert-Loopback $listeners
# Did Sunshine create its pair at the lab path? If not, fall back to its default pair and copy it for the relay.
$deadline = (Get-Date).AddSeconds(30)
while (-not ((Test-Path -LiteralPath $hostKey) -and (Test-Path -LiteralPath $hostCert)) -and (Get-Date) -lt $deadline) {
Start-Sleep -Milliseconds 500
}
if (-not ((Test-Path -LiteralPath $hostKey) -and (Test-Path -LiteralPath $hostCert))) {
Say 'Sunshine did not create the lab pair at keys\; using its default pair'
Stop-Service -Name $service.Name -Force
Write-Conf $false
Start-Service -Name $service.Name
$listeners = Wait-Listeners 60
if (-not $listeners) { Stop-Service -Name $service.Name -Force; Fail 'Sunshine did not come back after the fallback' }
Assert-Loopback $listeners
$defKey = Join-Path $configDir 'credentials\cakey.pem'
$defCert = Join-Path $configDir 'credentials\cacert.pem'
if (-not ((Test-Path -LiteralPath $defKey) -and (Test-Path -LiteralPath $defCert))) { Fail 'default pair not found either' }
Copy-Item -LiteralPath $defKey -Destination $hostKey
Copy-Item -LiteralPath $defCert -Destination $hostCert
}
Say 'Sunshine listens on 127.0.0.2 only; lab certificate pair in keys\'
# --- Report what the MSI did to the firewall (read only, nothing changed) ----------------------------------------
$rules = @(Get-NetFirewallRule -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -like '*Sunshine*' })
$notes = Join-Path $captures 'install-notes.txt'
@(
"installed: $(Get-Date -Format o)",
"service: $($service.Name)",
"msi sha256: $hash",
"listeners: " + (($listeners | ForEach-Object { "$($_.LocalAddress):$($_.LocalPort)" }) -join ', '),
"firewall rules named like Sunshine (not changed): " + (($rules | ForEach-Object { "$($_.DisplayName) [$($_.Direction) $($_.Action) $($_.Enabled)]" }) -join '; ')
) | Set-Content -LiteralPath $notes -Encoding ASCII
Say "done; notes in $notes. Next, not elevated: lab-api.ps1 -Action Rotate"
exit 0
+16 -7
View File
@@ -7,9 +7,9 @@ use std::time::Duration;
use crate::record::Protocol; use crate::record::Protocol;
/// Where recordings go unless told otherwise. /// Where recordings go unless told otherwise.
pub const DEFAULT_CAPTURE_DIR: &str = r"F:\Akce\DomiStream-lab\captures"; pub const DEFAULT_CAPTURE_DIR: &str = r"E:\build\play-remotely\lab\captures";
/// Where lab keys live unless told otherwise. /// Where lab keys live unless told otherwise.
pub const DEFAULT_KEY_DIR: &str = r"F:\Akce\DomiStream-lab\keys"; pub const DEFAULT_KEY_DIR: &str = r"E:\build\play-remotely\lab\keys";
/// Transport of a relayed port. /// Transport of a relayed port.
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -118,7 +118,9 @@ pub enum ConfigError {
impl std::fmt::Display for ConfigError { impl std::fmt::Display for ConfigError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
Self::NotLoopback(ip) => write!(f, "{ip} is not a loopback address; the relay binds and connects only on loopback"), Self::NotLoopback(ip) => {
write!(f, "{ip} is not a loopback address; the relay binds and connects only on loopback")
}
Self::SelfLoop => f.write_str("listen and upstream are the same address and ports"), Self::SelfLoop => f.write_str("listen and upstream are the same address and ports"),
Self::BadRewrite(s) => write!(f, "rewrite {s:?}: both sides must be non-empty and the same length"), Self::BadRewrite(s) => write!(f, "rewrite {s:?}: both sides must be non-empty and the same length"),
Self::PortOverflow(p) => write!(f, "port {p} plus the offset is over 65535"), Self::PortOverflow(p) => write!(f, "port {p} plus the offset is over 65535"),
@@ -173,8 +175,10 @@ impl Config {
GAMESTREAM_PORTS GAMESTREAM_PORTS
.iter() .iter()
.map(|&(port, transport, protocol)| { .map(|&(port, transport, protocol)| {
let upstream_port = port.checked_add(self.upstream_port_offset).ok_or(ConfigError::PortOverflow(port))?; let upstream_port =
let transport = if transport == Transport::Tls && self.tls.is_none() { Transport::Tcp } else { transport }; port.checked_add(self.upstream_port_offset).ok_or(ConfigError::PortOverflow(port))?;
let transport =
if transport == Transport::Tls && self.tls.is_none() { Transport::Tcp } else { transport };
let protocol = if transport == Transport::Tcp && protocol == Protocol::HttpsPlain { let protocol = if transport == Transport::Tcp && protocol == Protocol::HttpsPlain {
Protocol::HttpsTls Protocol::HttpsTls
} else { } else {
@@ -260,8 +264,13 @@ mod tests {
#[test] #[test]
fn non_loopback_listen_or_upstream_is_refused() { fn non_loopback_listen_or_upstream_is_refused() {
for a in ["--listen 0.0.0.0", "--listen 192.168.100.140", "--upstream 192.168.100.217", "--listen ::", "--upstream 26.1.2.3"] for a in [
{ "--listen 0.0.0.0",
"--listen 192.168.100.140",
"--upstream 192.168.100.217",
"--listen ::",
"--upstream 26.1.2.3",
] {
assert!(matches!(Config::from_args(&args(a)), Err(ConfigError::NotLoopback(_))), "{a}"); assert!(matches!(Config::from_args(&args(a)), Err(ConfigError::NotLoopback(_))), "{a}");
} }
} }
+1 -6
View File
@@ -60,12 +60,7 @@ fn run(args: &[String]) -> AnyResult {
let mut threads = Vec::new(); let mut threads = Vec::new();
for spec in config.ports()? { for spec in config.ports()? {
let (config, rec) = (Arc::clone(&config), Arc::clone(&rec)); let (config, rec) = (Arc::clone(&config), Arc::clone(&rec));
println!( println!("lab-relay: {:?} {} -> {}", spec.protocol, config.listen_addr(&spec), config.upstream_addr(&spec));
"lab-relay: {:?} {} -> {}",
spec.protocol,
config.listen_addr(&spec),
config.upstream_addr(&spec)
);
threads.push(thread::spawn(move || { threads.push(thread::spawn(move || {
let r = match spec.transport { let r = match spec.transport {
Transport::Tcp => tcp::serve(Arc::clone(&config), spec, Arc::clone(&rec)), Transport::Tcp => tcp::serve(Arc::clone(&config), spec, Arc::clone(&rec)),
+2 -1
View File
@@ -61,6 +61,7 @@ impl Rewriter {
} }
/// Bytes currently held back. /// Bytes currently held back.
#[cfg(test)]
pub fn held(&self) -> usize { pub fn held(&self) -> usize {
self.held.len() self.held.len()
} }
@@ -92,7 +93,7 @@ mod tests {
fn replaces_in_one_chunk() { fn replaces_in_one_chunk() {
let (out, n) = run(&mut lab(), &[ANSWER]); let (out, n) = run(&mut lab(), &[ANSWER]);
assert_eq!(n, 1); assert_eq!(n, 1);
assert_eq!(out, ANSWER.to_vec().iter().copied().collect::<Vec<_>>().replace_all_for_test()); assert_eq!(out, ANSWER.to_vec().replace_all_for_test());
} }
#[test] #[test]
+12 -2
View File
@@ -105,7 +105,13 @@ fn sha256_hex(bytes: &[u8]) -> String {
fn relay(client: TcpStream, config: &Config, spec: PortSpec, rec: &Recorder, conn: u32) -> io::Result<()> { fn relay(client: TcpStream, config: &Config, spec: PortSpec, rec: &Recorder, conn: u32) -> io::Result<()> {
let upstream_addr = config.upstream_addr(&spec); let upstream_addr = config.upstream_addr(&spec);
let peer = client.peer_addr()?; let peer = client.peer_addr()?;
rec.log(Kind::Open, Protocol::HttpsPlain, Direction::None, conn, format!("{peer} -> {upstream_addr} (TLS terminated)").as_bytes()); rec.log(
Kind::Open,
Protocol::HttpsPlain,
Direction::None,
conn,
format!("{peer} -> {upstream_addr} (TLS terminated)").as_bytes(),
);
let Some(files) = &config.tls else { let Some(files) = &config.tls else {
return Err(io::Error::other("TLS files not configured")); return Err(io::Error::other("TLS files not configured"));
}; };
@@ -146,7 +152,11 @@ fn relay(client: TcpStream, config: &Config, spec: PortSpec, rec: &Recorder, con
down.protocol_version(), down.protocol_version(),
down.negotiated_cipher_suite().map(|s| s.suite()), down.negotiated_cipher_suite().map(|s| s.suite()),
presented.as_deref().unwrap_or("none"), presented.as_deref().unwrap_or("none"),
if presented.as_deref() == Some(expected.as_str()) { "matches the lab client certificate" } else { "differs from the lab client certificate" }, if presented.as_deref() == Some(expected.as_str()) {
"matches the lab client certificate"
} else {
"differs from the lab client certificate"
},
), ),
); );
+13 -7
View File
@@ -53,7 +53,13 @@ pub fn serve(config: Arc<Config>, spec: PortSpec, rec: Arc<Recorder>) -> io::Res
let up = Arc::new(UdpSocket::bind(SocketAddr::new(config.listen, 0))?); let up = Arc::new(UdpSocket::bind(SocketAddr::new(config.listen, 0))?);
up.connect(upstream_addr)?; up.connect(upstream_addr)?;
let conn = rec.new_connection(); let conn = rec.new_connection();
rec.log(Kind::Open, spec.protocol, Direction::None, conn, format!("{from} -> {upstream_addr}").as_bytes()); rec.log(
Kind::Open,
spec.protocol,
Direction::None,
conn,
format!("{from} -> {upstream_addr}").as_bytes(),
);
spawn_return_path(Arc::clone(&up), Arc::clone(&listen), from, spec, Arc::clone(&rec), conn); spawn_return_path(Arc::clone(&up), Arc::clone(&listen), from, spec, Arc::clone(&rec), conn);
map.insert(from, (Arc::clone(&up), conn)); map.insert(from, (Arc::clone(&up), conn));
Some((up, conn)) Some((up, conn))
@@ -61,13 +67,13 @@ pub fn serve(config: Arc<Config>, spec: PortSpec, rec: Arc<Recorder>) -> io::Res
}; };
let Some((up, conn)) = flow else { continue }; let Some((up, conn)) = flow else { continue };
rec.log(Kind::Data, spec.protocol, Direction::ClientToHost, conn, &buf[..n]); rec.log(Kind::Data, spec.protocol, Direction::ClientToHost, conn, &buf[..n]);
if let Err(e) = up.send(&buf[..n]) { if let Err(e) = up.send(&buf[..n])
if !transient(&e) { && !transient(&e)
{
rec.note(spec.protocol, conn, &format!("send to host failed: {e}")); rec.note(spec.protocol, conn, &format!("send to host failed: {e}"));
} }
} }
} }
}
fn spawn_return_path( fn spawn_return_path(
up: Arc<UdpSocket>, up: Arc<UdpSocket>,
@@ -83,12 +89,12 @@ fn spawn_return_path(
match up.recv(&mut buf) { match up.recv(&mut buf) {
Ok(n) => { Ok(n) => {
rec.log(Kind::Data, spec.protocol, Direction::HostToClient, conn, &buf[..n]); rec.log(Kind::Data, spec.protocol, Direction::HostToClient, conn, &buf[..n]);
if let Err(e) = listen.send_to(&buf[..n], client) { if let Err(e) = listen.send_to(&buf[..n], client)
if !transient(&e) { && !transient(&e)
{
rec.note(spec.protocol, conn, &format!("send to client failed: {e}")); rec.note(spec.protocol, conn, &format!("send to client failed: {e}"));
} }
} }
}
Err(e) if transient(&e) => {} Err(e) if transient(&e) => {}
Err(e) => { Err(e) => {
rec.note(spec.protocol, conn, &format!("receive from host failed: {e}")); rec.note(spec.protocol, conn, &format!("receive from host failed: {e}"));