Conversation
… pairing docker-modem's dial() mishandles the 'ssh:' protocol when building request URLs (it's not in its hardcoded slashed-protocol list), corrupting the host:port and throwing ERR_INVALID_ARG_VALUE. This made automatic Wolf pairing fail deterministically for any host. SunshineMoonlightPairer already avoids this by using the project's own SSHClient — applied the same pattern to WolfMoonlightPairer. Fixes PierreBeucher#379
Owner
|
Thanks for your PR! I'll have a look ASAP :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #379 — Wolf pairing throws
TypeError [ERR_INVALID_ARG_VALUE]: Invalid port in urlin a loop and never sends the PIN.Root cause
WolfMoonlightPairerfetches thewolfcontainer's logs (to find the PIN URL and confirm pairing success) through a Dockerode client configured withprotocol: 'ssh'and a plainhost. Internally,docker-modem'sModem.dial()builds the request URL with Node's legacyurlmodule. Since'ssh'isn't indocker-modem's hardcoded list of "slashed" protocols (http,https,ws, ...),url.parse()/url.format()/url.resolve()mis-handle the host, and the host ends up duplicated next to the port (ssh:<host>:22<host>), which then fails to parse as a port.I reproduced this with Scaleway but this isn't specific to Scaleway or to IP hosts — I reproduced it locally against
docker-modem@5.0.6and it fails identically for a bare IP, a hostname, andlocalhost. It's a deterministic bug in this dependency version, not an intermittent one, so automatic Wolf pairing could never have succeeded through this code path.SunshineMoonlightPairernever hits this bug because it already uses the project's ownSSHClient(src/tools/ssh.ts, built onnode-ssh) instead of Dockerode's SSH transport — which is presumably why this stayed unnoticed for Sunshine users while Wolf users hit it every time.Fix
Replace the Dockerode/
docker-modemSSH transport inWolfMoonlightPairerwith the sameSSHClientalready used bySunshineMoonlightPairerandInstanceRunner:buildDockerClient()→buildSshClient(), returning a plainSSHClient.getLatestPinURL()/checkPairingSuccess()now rundocker logs wolf --tail <n> [--since <unix_ts>] 2>&1over a real SSH exec instead of going through the Docker Engine API over SSH. Parsing logic (PIN URL regex, success-message match) is unchanged.doPair()opens one SSH connection for the whole polling loop and disposes it in afinally.No behavior change other than how logs are fetched — the PIN-sending flow (
sendPinData, HTTP POST to Wolf's/pin/endpoint) is untouched.Testing
url.parse/format/resolve, mirroringdocker-modem'sdial()) to confirm the exact failure mode before writing the fix.tsc -p tsconfig.build.json --noEmit: no new errors (pre-existing unrelated errors insrc/cli/prompter.tsare untouched by this change).task test-unit: all 155 existing tests pass.WolfMoonlightPairer/SunshineMoonlightPairerpairing flow (network/SSH-dependent), so this change relies on the above + manual verification. Happy to add coverage if useful — let me know what you'd want tested.Note
This fix was drafted with Claude code AI assistance (root cause analysis, code change, local repro), then reviewed and validated end-to-end by me against a live instance before opening this PR.