From 9a7f09eaf7ae18dce73a11a798a70f51588a8dec Mon Sep 17 00:00:00 2001 From: Frotty Date: Tue, 17 Nov 2026 23:13:09 +0100 Subject: [PATCH] Describe the Battle.net sign-in lock without naming other tools The comments and a test name pointed at a tool that is not public; they now say what the code shares: every tool that renews this sign-in binds the same localhost port. --- .../languageserver/requests/BattleNetSignIn.java | 12 ++++++------ .../languageserver/requests/OutsideStart.java | 2 -- .../languageserver/requests/BattleNetSignInTest.java | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/BattleNetSignIn.java b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/BattleNetSignIn.java index 471f4b88a..fb3f640fc 100644 --- a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/BattleNetSignIn.java +++ b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/BattleNetSignIn.java @@ -55,8 +55,8 @@ * its token where nothing else reads it; the script then sees the app start the game but no new token, and the user is * told to start Battle.net from the Start menu. * - *

The wc3-e2e-harness does the same (docs/BattleNetSignIn.md there). Both hold the same localhost port as a lock - * from the renewal until the launched client has signed in. + *

Every tool that renews this sign-in holds the same localhost port as a lock from the renewal until the launched + * client has signed in. */ @SuppressWarnings("StringConcatToTextBlock") // Error Prone 2.50 crashes on this source under javac 27. public final class BattleNetSignIn { @@ -425,9 +425,9 @@ private static Path tempDir() { return Path.of(System.getProperty("java.io.tmpdir")); } - /** A copy of the wc3-e2e-harness {@code node/src/runner/battlenet-token.ps1}; keep them equal. */ + /** The renewal script, run in the user's own registry view. */ static final String TOKEN_SCRIPT = "battlenet-token.ps1"; - /** A copy of the wc3-e2e-harness {@code node/src/runner/battlenet-window.ps1}; keep them equal. */ + /** The watcher that keeps the app's window out of sight during the renewal. */ static final String WINDOW_SCRIPT = "battlenet-window.ps1"; /** The watcher's limit without a client: every request the renewal may send, then a launch and a slow sign-in. */ static final long WINDOW_WATCH_SECONDS = TIMEOUT_SECONDS + 150; @@ -540,7 +540,7 @@ private static Optional readBinary(String key, String value) throws IOEx return parseBinary(readCommand(new ProcessBuilder("reg.exe", "query", key, "/v", value)), value); } - // The Node harness takes the same localhost port while it renews the sign-in. + // Every tool that renews this sign-in takes the same localhost port while it does. static int gatePort(Path config) { try { String key = config.toAbsolutePath().normalize().toString().toLowerCase(Locale.ROOT); @@ -558,7 +558,7 @@ private ServerSocket acquireGate(long waitSeconds, Runnable onWait) throws IOExc while (true) { ServerSocket socket = new ServerSocket(); try { - // 127.0.0.1 exactly, as the harness binds it; the loopback name could resolve to ::1 + // 127.0.0.1 exactly, as every holder binds it; the loopback name could resolve to ::1 socket.bind(new InetSocketAddress(InetAddress.getByAddress(new byte[]{127, 0, 0, 1}), gatePort(config))); return socket; } catch (BindException ex) { diff --git a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/OutsideStart.java b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/OutsideStart.java index 52a8678cb..d1221cb8d 100644 --- a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/OutsideStart.java +++ b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/OutsideStart.java @@ -26,8 +26,6 @@ * them started from inside such an app would keep it where the rest of the machine never sees it. A process created * through WMI ({@code Win32_Process.Create}) starts in the user's own context instead, in the same session and on the * same desktop. - * - *

The wc3-e2e-harness does the same ({@code startOutside} in node/src/runner/win32.cjs there). */ final class OutsideStart { /** The {@code SW_} value WMI passes to the new process's first window. */ diff --git a/de.peeeq.wurstscript/src/test/java/de/peeeq/wurstio/languageserver/requests/BattleNetSignInTest.java b/de.peeeq.wurstscript/src/test/java/de/peeeq/wurstio/languageserver/requests/BattleNetSignInTest.java index 2b06ef3e4..84da3dec5 100644 --- a/de.peeeq.wurstscript/src/test/java/de/peeeq/wurstio/languageserver/requests/BattleNetSignInTest.java +++ b/de.peeeq.wurstscript/src/test/java/de/peeeq/wurstio/languageserver/requests/BattleNetSignInTest.java @@ -201,9 +201,9 @@ public void readsOnlyTheRequestedBinaryValueFromRegQuery() { } @Test - public void takesTheSameLockAsTheE2eHarness() { + public void takesTheSharedSignInLockPort() { if (!Orient.isWindowsSystem()) throw new SkipException("Battle.net paths are Windows paths"); - // node/src/runner/battlenet.cjs in wc3-e2e-harness: 33000 + sha256(lower-cased path) as uint32 BE % 10000 + // 33000 + sha256(lower-cased path) as uint32 BE % 10000, the port every tool that renews this sign-in binds assertEquals(BattleNetSignIn.gatePort(Path.of("C:\\Users\\tester\\AppData\\Roaming\\Battle.net\\Battle.net.config")), 36941); }