mirror of
https://github.com/burrow-dev/burrow-client.git
synced 2026-11-20 17:37:50 -05:00
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
This commit is contained in:
1 parent
0b45a60b04
commit
87695c3250
5 files changed
+32
-12
No files matched your search
@@ -5,6 +5,7 @@ const { ipcRenderer, contextBridge } = require("electron");
|
|||||||
const sendWhitelist = new Set()
|
const sendWhitelist = new Set()
|
||||||
.add("initialized")
|
.add("initialized")
|
||||||
.add("fps")
|
.add("fps")
|
||||||
|
.add("openPage")
|
||||||
.add("printImage")
|
.add("printImage")
|
||||||
.add("reloadGame")
|
.add("reloadGame")
|
||||||
.add("reportError")
|
.add("reportError")
|
||||||
|
|||||||
+10
-5
@@ -387,7 +387,7 @@
|
|||||||
<label>Starting room
|
<label>Starting room
|
||||||
<input id="starting-room" type="text" spellcheck="false" placeholder="jamaa_township.room_main">
|
<input id="starting-room" type="text" spellcheck="false" placeholder="jamaa_township.room_main">
|
||||||
</label>
|
</label>
|
||||||
<label class="check"><input id="start-in-den" type="checkbox"> Start in den</label>
|
<label class="check"><input id="start-in-den" type="checkbox" checked> Start in den</label>
|
||||||
<label class="check"><input id="start-muted" type="checkbox"> Start muted</label>
|
<label class="check"><input id="start-muted" type="checkbox"> Start muted</label>
|
||||||
<label class="check"><input id="use-gpu" type="checkbox"> Use GPU</label>
|
<label class="check"><input id="use-gpu" type="checkbox"> Use GPU</label>
|
||||||
<p class="hint" id="gpu-hint" style="margin-top: -6px" hidden>Applies after restart.</p>
|
<p class="hint" id="gpu-hint" style="margin-top: -6px" hidden>Applies after restart.</p>
|
||||||
@@ -678,14 +678,15 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// servers reachable by strangers ignore these choices unless told
|
// servers reachable by strangers ignore these choices unless told
|
||||||
// otherwise; member or not is the player's choice on a server that says
|
// otherwise; member or not, and guide or not, are the player's choice on
|
||||||
// so (membershipChoice), the other account types stay locked there.
|
// a server that says so (membershipChoice), the other account types stay
|
||||||
|
// locked there.
|
||||||
const MEMBERSHIP_TYPES = ["", "0", "2"];
|
const MEMBERSHIP_TYPES = ["", "0", "2"];
|
||||||
const showWhetherChoicesApply = flashVars => {
|
const showWhetherChoicesApply = flashVars => {
|
||||||
const honoured = flashVars.loginChoices !== false;
|
const honoured = flashVars.loginChoices !== false;
|
||||||
const membership = honoured || flashVars.membershipChoice === true;
|
const membership = honoured || flashVars.membershipChoice === true;
|
||||||
for (const field of document.querySelectorAll("[data-choice]")) {
|
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) {
|
for (const option of $("account-type").options) {
|
||||||
option.disabled = !honoured && !MEMBERSHIP_TYPES.includes(option.value);
|
option.disabled = !honoured && !MEMBERSHIP_TYPES.includes(option.value);
|
||||||
@@ -694,7 +695,7 @@
|
|||||||
$("account-type").value = "";
|
$("account-type").value = "";
|
||||||
}
|
}
|
||||||
$("choices-hint").hidden = honoured;
|
$("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) => {
|
const getJson = async (url, options) => {
|
||||||
@@ -1138,6 +1139,10 @@
|
|||||||
else if (event.channel === "reportError") {
|
else if (event.channel === "reportError") {
|
||||||
reportError(event.args[0]);
|
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;
|
$("loading").hidden = false;
|
||||||
clearTimeout(loadingTimer);
|
clearTimeout(loadingTimer);
|
||||||
|
|||||||
+16
-6
@@ -236,11 +236,7 @@ const mayLoad = details => {
|
|||||||
// header), and this client's page is a file. so the calls the page
|
// 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.
|
// 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"]};
|
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 => {
|
const apiRequest = (serverUrl, call, body) => new Promise(resolve => {
|
||||||
if (!API_CALLS[call] || !/^https?:\/\//.test(String(serverUrl))) {
|
|
||||||
resolve({status: 0, body: {}});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const [method, apiPath] = API_CALLS[call];
|
const [method, apiPath] = API_CALLS[call];
|
||||||
const started = Date.now();
|
const started = Date.now();
|
||||||
const request = net.request({method, url: new URL(apiPath, serverUrl).href, partition: API_PARTITION});
|
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.write(JSON.stringify(body || {}));
|
||||||
}
|
}
|
||||||
request.end();
|
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
|
// 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
|
// run in the login page, which is a file, so it is the server's own
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "aj-private-client",
|
"name": "aj-private-client",
|
||||||
"productName": "Burrow",
|
"productName": "Burrow",
|
||||||
"version": "1.1.1",
|
"version": "1.2.0",
|
||||||
"description": "The client for the Burrow private server",
|
"description": "The client for the Burrow private server",
|
||||||
"main": "boot.js",
|
"main": "boot.js",
|
||||||
"license": "UNLICENSED"
|
"license": "UNLICENSED"
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ module.exports.use = (remoteHost, port, secure) => new Promise(resolve => {
|
|||||||
}
|
}
|
||||||
const relay = net.createServer(local => {
|
const relay = net.createServer(local => {
|
||||||
const remote = secure ? tls.connect({host: remoteHost, port}) : net.connect(port, remoteHost);
|
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);
|
local.pipe(remote);
|
||||||
remote.pipe(local);
|
remote.pipe(local);
|
||||||
const close = () => {
|
const close = () => {
|
||||||
|
|||||||
Reference in new issue
Block a user