This commit is contained in:
Hri7566 2021-04-12 12:41:44 -04:00
parent fc6ecacaee
commit 199defed76
4 changed files with 34 additions and 19 deletions

View File

@ -7,5 +7,6 @@ module.exports = Object.seal({
// defaultLobbyColor: "#19b4b9",
defaultLobbyColor: "#5e32a8",
defaultLobbyColor2: "#801014",
adminpass: process.env.ADMINPASS
adminpass: process.env.ADMINPASS,
ssl: false
});

View File

@ -44,7 +44,7 @@ module.exports = (cl) => {
}
})
cl.on("m", (msg, admin) => {
if (!cl.quotas.cursor.attempt() && !admin) return;
// if (!cl.quotas.cursor.attempt() && !admin) return;
if (!(cl.channel && cl.participantId)) return;
if (!msg.hasOwnProperty("x")) msg.x = null;
if (!msg.hasOwnProperty("y")) msg.y = null;

View File

@ -196,16 +196,16 @@ class Room extends EventEmitter {
}
isLobby(_id) {
if (_id.startsWith("lobby")) {
return true;
let lobbynum = _id.split("lobby")[1];
if (_id == "lobby") {
return true;
}
let lobbynum = _id.split("lobby")[1];
if (!(parseInt(lobbynum).toString() == lobbynum)) return false;
for (let i in lobbynum) {
if (parseInt(lobbynum[i]) >= 0) {
if (parseInt(i) + 1 == lobbynum.length) return true;
} else {
return false;
}

View File

@ -1,26 +1,40 @@
const Client = require("./Client.js");
const banned = require('../banned.json');
const https = require("https");
const http = require("http");
const fs = require('fs');
class Server extends EventEmitter {
constructor(config) {
super();
EventEmitter.call(this);
this.https_server = https.createServer({
key: fs.readFileSync('ssl/privkey.pem', 'utf8'),
cert: fs.readFileSync('ssl/cert.pem'),
ca: fs.readFileSync('ssl/chain.pem')
});
this.wss = new WebSocket.Server({
server: this.https_server,
backlog: 100,
verifyClient: (info) => {
if (banned.includes((info.req.connection.remoteAddress).replace("::ffff:", ""))) return false;
return true;
}
});
this.https_server.listen(config.port);
if (config.ssl == true) {
this.https_server = https.createServer({
key: fs.readFileSync('ssl/privkey.pem', 'utf8'),
cert: fs.readFileSync('ssl/cert.pem'),
ca: fs.readFileSync('ssl/chain.pem')
});
this.wss = new WebSocket.Server({
server: this.https_server,
backlog: 100,
verifyClient: (info) => {
if (banned.includes((info.req.connection.remoteAddress).replace("::ffff:", ""))) return false;
return true;
}
});
this.https_server.listen(config.port);
} else {
this.wss = new WebSocket.Server({
port: 8443,
backlog: 100,
verifyClient: (info) => {
if (banned.includes((info.req.connection.remoteAddress).replace("::ffff:", ""))) return false;
return true;
}
});
}
console.log(`Server started on port ${config.port}`);
this.connectionid = 0;
this.connections = new Map();