From 87695c32502e52759eee95cb8ded775884aeee21 Mon Sep 17 00:00:00 2001 From: Burrowdev Date: Sat, 17 Oct 2026 01:13:09 +0300 Subject: [PATCH] Client 1.2.0: the game page may open an address in the system browser (openPage); start in den on by default and the Guide login choice; the ping measured over an open connection; no Nagle delay on the relay --- app/gamePreload.js | 1 + app/index.html | 15 ++++++++++----- app/main.js | 22 ++++++++++++++++------ app/package.json | 2 +- app/relay.js | 4 ++++ 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/app/gamePreload.js b/app/gamePreload.js index f6f645d..cbc08f9 100644 --- a/app/gamePreload.js +++ b/app/gamePreload.js @@ -5,6 +5,7 @@ const { ipcRenderer, contextBridge } = require("electron"); const sendWhitelist = new Set() .add("initialized") .add("fps") + .add("openPage") .add("printImage") .add("reloadGame") .add("reportError") diff --git a/app/index.html b/app/index.html index 6826610..8d064ef 100644 --- a/app/index.html +++ b/app/index.html @@ -387,7 +387,7 @@ - + @@ -678,14 +678,15 @@ }; // servers reachable by strangers ignore these choices unless told - // otherwise; member or not is the player's choice on a server that says - // so (membershipChoice), the other account types stay locked there. + // otherwise; member or not, and guide or not, are the player's choice on + // a server that says so (membershipChoice), the other account types stay + // locked there. const MEMBERSHIP_TYPES = ["", "0", "2"]; const showWhetherChoicesApply = flashVars => { const honoured = flashVars.loginChoices !== false; const membership = honoured || flashVars.membershipChoice === true; for (const field of document.querySelectorAll("[data-choice]")) { - field.disabled = field.id === "account-type" ? !membership : !honoured; + field.disabled = ["account-type", "guide"].includes(field.id) ? !membership : !honoured; } for (const option of $("account-type").options) { option.disabled = !honoured && !MEMBERSHIP_TYPES.includes(option.value); @@ -694,7 +695,7 @@ $("account-type").value = ""; } $("choices-hint").hidden = honoured; - $("choices-hint").textContent = honoured ? "" : membership ? "Developer and Guide are locked by this server." : "Locked by this server."; + $("choices-hint").textContent = honoured ? "" : membership ? "Developer is locked by this server." : "Locked by this server."; }; const getJson = async (url, options) => { @@ -1138,6 +1139,10 @@ else if (event.channel === "reportError") { reportError(event.args[0]); } + else if (event.channel === "openPage") { + // main.js opens http and https addresses only + window.client.openPage(String(event.args[0])); + } }); $("loading").hidden = false; clearTimeout(loadingTimer); diff --git a/app/main.js b/app/main.js index 8aa4598..83fee20 100644 --- a/app/main.js +++ b/app/main.js @@ -236,11 +236,7 @@ const mayLoad = details => { // header), and this client's page is a file. so the calls the page // needs are made from here, where a request carries no origin. const API_CALLS = {status: ["GET", "/api/status"], register: ["POST", "/api/register"], ban: ["POST", "/api/ban"]}; -ipcMain.handle("api", (event, serverUrl, call, body) => new Promise(resolve => { - if (!API_CALLS[call] || !/^https?:\/\//.test(String(serverUrl))) { - resolve({status: 0, body: {}}); - return; - } +const apiRequest = (serverUrl, call, body) => new Promise(resolve => { const [method, apiPath] = API_CALLS[call]; const started = Date.now(); const request = net.request({method, url: new URL(apiPath, serverUrl).href, partition: API_PARTITION}); @@ -273,7 +269,21 @@ ipcMain.handle("api", (event, serverUrl, call, body) => new Promise(resolve => { request.write(JSON.stringify(body || {})); } request.end(); -})); +}); +ipcMain.handle("api", async (event, serverUrl, call, body) => { + if (!API_CALLS[call] || !/^https?:\/\//.test(String(serverUrl))) { + return {status: 0, body: {}}; + } + const first = await apiRequest(serverUrl, call, body); + if (call !== "status" || first.status === 0) { + return first; + } + // the ping. the first request may have had to make the connection (and + // a packet of that lost costs a whole second, or three); the one right + // after it goes over that connection, which is what the game's own does. + const second = await apiRequest(serverUrl, call, body); + return second.status === 0 ? first : second; +}); // the server's captcha (its lib/captcha.js). cloudflare's widget does not // run in the login page, which is a file, so it is the server's own diff --git a/app/package.json b/app/package.json index e620502..f94e15e 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "aj-private-client", "productName": "Burrow", - "version": "1.1.1", + "version": "1.2.0", "description": "The client for the Burrow private server", "main": "boot.js", "license": "UNLICENSED" diff --git a/app/relay.js b/app/relay.js index 019431c..b9ac7d0 100644 --- a/app/relay.js +++ b/app/relay.js @@ -33,6 +33,10 @@ module.exports.use = (remoteHost, port, secure) => new Promise(resolve => { } const relay = net.createServer(local => { const remote = secure ? tls.connect({host: remoteHost, port}) : net.connect(port, remoteHost); + // the game sends small messages, often two at once: without these the + // second waits for the first's answer from the other end (Nagle). + local.setNoDelay(true); + remote.setNoDelay(true); local.pipe(remote); remote.pipe(local); const close = () => {