Send OPTIONS request to the WebSockets interface once per Timeout interval. This allows some deployment environment to correctly detect the status of the application

This commit is contained in:
NI
2021-04-29 14:02:52 +08:00
parent f982873b4a
commit b87d5437e5
4 changed files with 42 additions and 11 deletions

View File

@@ -200,25 +200,29 @@ function startApp(rootEl) {
await cipher.hmac512(enc.encode(finalKey), enc.encode(rTime))
).slice(0, 32);
},
buildBackendSocketURL() {
let r = "";
buildBackendSocketURLs() {
let r = {
webSocket: "",
keepAlive: "",
};
switch (location.protocol) {
case "https:":
r = "wss://";
r.webSocket = "wss://";
break;
default:
r = "ws://";
r.webSocket = "ws://";
}
r += location.host + socksInterface;
r.webSocket += location.host + socksInterface;
r.keepAlive = location.protocol + "//" + location.host + socksInterface;
return r;
},
buildSocket(key, dialTimeout, heartbeatInterval) {
return new Socket(
this.buildBackendSocketURL(),
this.buildBackendSocketURLs(),
key,
dialTimeout * 1000,
heartbeatInterval * 1000