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