add tls
This commit is contained in:
@@ -7,7 +7,12 @@ import {
|
||||
processMessage,
|
||||
trackConnection,
|
||||
} from "./websocket-handler";
|
||||
import { getVersionNumber, writeStatNumber, writeStatString, writeSuccess } from "./utility";
|
||||
import {
|
||||
getVersionNumber,
|
||||
writeStatNumber,
|
||||
writeStatString,
|
||||
writeSuccess,
|
||||
} from "./utility";
|
||||
|
||||
import Colors from "colors";
|
||||
import IP from "ip";
|
||||
@@ -61,6 +66,23 @@ async function main() {
|
||||
forgetConnection(ws);
|
||||
},
|
||||
},
|
||||
|
||||
tls: await (async () => {
|
||||
const keyFile = Bun.file("./key.pem");
|
||||
const certFile = Bun.file("./cert.pem");
|
||||
|
||||
if (
|
||||
(await keyFile.exists()) == false ||
|
||||
(await certFile.exists()) == false
|
||||
)
|
||||
return undefined;
|
||||
|
||||
return {
|
||||
key: keyFile,
|
||||
cert: certFile,
|
||||
passphrase: process.env.TLS_PASSPHRASE,
|
||||
};
|
||||
})(),
|
||||
});
|
||||
|
||||
function createFileResponse(requestPath: string): Response {
|
||||
@@ -76,7 +98,7 @@ async function main() {
|
||||
return [
|
||||
["server url", server.url.toString()],
|
||||
["server ip address", IP.address()],
|
||||
["server version", versionNumber]
|
||||
["server version", versionNumber],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -339,7 +339,7 @@
|
||||
setTimeout(connect, 2e3);
|
||||
};
|
||||
function connect() {
|
||||
UDN.connect(`ws://${window.location.host}`);
|
||||
UDN.connect(`wss://${window.location.host}`);
|
||||
}
|
||||
connect();
|
||||
var isDisconnected = new State(true);
|
||||
|
||||
@@ -33,7 +33,7 @@ UDN.ondisconnect = () => {
|
||||
};
|
||||
|
||||
function connect() {
|
||||
UDN.connect(`ws://${window.location.host}`);
|
||||
UDN.connect(`wss://${window.location.host}`);
|
||||
}
|
||||
connect();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user