finally added https

This commit is contained in:
Mystikfluu 2022-04-24 00:41:07 +02:00
parent 235701b646
commit 5ad7b29c70

View File

@ -22,7 +22,7 @@ const HASHES_DB = 10000
const HASHES_COOKIE = 10 const HASHES_COOKIE = 10
const HASHES_DIFF = HASHES_DB - HASHES_COOKIE const HASHES_DIFF = HASHES_DB - HASHES_COOKIE
const DID_I_FINALLY_ADD_HTTPS = false const DID_I_FINALLY_ADD_HTTPS = true
const con = mysql.createConnection({ const con = mysql.createConnection({
host: "localhost", host: "localhost",
@ -257,7 +257,7 @@ router.post("/api/post", async function(req,res) {
if (err) throw err; if (err) throw err;
console.log(result); console.log(result);
wss.clients.forEach(function(ws) { wss.clients.forEach(function(ws) {
ws.send("new_post") ws.send("new_post " + res.locals.username)
}); });
res.send("success") res.send("success")
}); });
@ -425,10 +425,18 @@ router.post("/login",async function(req,res) {
app.use(router) app.use(router)
const httpServer = http.createServer(app); const httpServer = http.createServer(app);
httpServer.listen(25566); httpServer.listen(25567);
const privateKey = fs.readFileSync("C:/Certbot/live/ws.zerotwohub.tk/privkey.pem").toString()
const certificate = fs.readFileSync("C:/Certbot/live/ws.zerotwohub.tk/cert.pem").toString()
const credentials = {key: privateKey, cert: certificate};
const httpsServer = https.createServer(credentials, app);
httpsServer.listen(25566);
const wss = new WebSocket({ const wss = new WebSocket({
server: httpServer, server: httpsServer,
perMessageDeflate: { perMessageDeflate: {
zlibDeflateOptions: { zlibDeflateOptions: {
chunkSize: 1024, chunkSize: 1024,