diff --git a/client-data/tools/document/document.js b/client-data/tools/document/document.js index 6a625fba..59668076 100644 --- a/client-data/tools/document/document.js +++ b/client-data/tools/document/document.js @@ -25,12 +25,12 @@ // File size as data url, approximately 1/3 larger than as bytestream //TODO: internationalization let size = image.src.toString().length; - if (size > 1048576) { //TODO: get correct size from config + if (size > Tools.server_config.MAX_DOCUMENT_SIZE) { alert("File too large"); throw new Error("File too large"); } - if (Tools.svg.querySelectorAll("image").length > 5) { //TODO: get correct amount from config + if (Tools.svg.querySelectorAll("image").length > Tools.server_config.MAX_DOCUMENT_COUNT) { alert("Too many documents exist already"); throw new Error("Too many documents exist already"); } diff --git a/server/client_configuration.js b/server/client_configuration.js index 495775e3..9c0a1ad1 100644 --- a/server/client_configuration.js +++ b/server/client_configuration.js @@ -2,6 +2,8 @@ const config = require("./configuration"); /** Settings that should be handed through to the clients */ module.exports = { + "MAX_DOCUMENT_SIZE": config.MAX_DOCUMENT_SIZE, + "MAX_DOCUMENT_COUNT": config.MAX_DOCUMENT_COUNT, "MAX_BOARD_SIZE": config.MAX_BOARD_SIZE, "MAX_EMIT_COUNT": config.MAX_EMIT_COUNT, "MAX_EMIT_COUNT_PERIOD": config.MAX_EMIT_COUNT_PERIOD, diff --git a/server/configuration.js b/server/configuration.js index 1c1b90be..0df1beac 100644 --- a/server/configuration.js +++ b/server/configuration.js @@ -27,10 +27,11 @@ module.exports = { MAX_BOARD_SIZE: parseInt(process.env['WBO_MAX_BOARD_SIZE']) || 65536, /** Maximum size of uploaded documents default 1MB */ - MAX_DOUMENT_SIZE: parseInt(process.env['WBO_MAX_DOCUMENT_SIZE']) || 1048576, + MAX_DOCUMENT_SIZE: parseInt(process.env['WBO_MAX_DOCUMENT_SIZE']) || 1048576, /** Maximum number of documents allowed */ - MAX_DOCUMENTS: parseInt(process.env['WBO_MAX_DOCUMENTS']) || 5, + MAX_DOCUMENT_COUNT: parseInt(process.env['WBO_MAX_DOCUMENT_COUNT']) || 5, + /** Maximum messages per user over the given time period before banning them */ MAX_EMIT_COUNT: parseInt(process.env['WBO_MAX_EMIT_COUNT']) || 128, diff --git a/server/sockets.js b/server/sockets.js index dd671d36..0e780a4d 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -113,7 +113,7 @@ function socketConnection(socket) { } }); - if (!message.data.size || message.data.size > config.MAX_DOUMENT_SIZE) { + if (!message.data.size || message.data.size > config.MAX_DOCUMENT_SIZE) { console.warn("Received too large file"); return; }