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: "#19b4b9",
defaultLobbyColor: "#5e32a8", defaultLobbyColor: "#5e32a8",
defaultLobbyColor2: "#801014", 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) => { 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 (!(cl.channel && cl.participantId)) return;
if (!msg.hasOwnProperty("x")) msg.x = null; if (!msg.hasOwnProperty("x")) msg.x = null;
if (!msg.hasOwnProperty("y")) msg.y = null; if (!msg.hasOwnProperty("y")) msg.y = null;

View File

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

View File

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