Prevent accidental DoS of users if server sends a rapid feed of data to the console.

Configurable speed in environment file.
This commit is contained in:
Dane Everitt 2016-10-23 21:31:29 -04:00
parent 55c9f0f2f2
commit 045864aa96
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 39 additions and 2 deletions

View file

@ -4,6 +4,8 @@ APP_KEY=SomeRandomString3232RandomString
APP_THEME=default
APP_TIMEZONE=UTC
APP_CLEAR_TASKLOG=720
CONSOLE_PUSH_FREQ=250
CONSOLE_PUSH_COUNT=10
DB_HOST=localhost
DB_PORT=3306

View file

@ -271,3 +271,17 @@ li.btn.btn-default.pill:active,li.btn.btn-default.pill:focus,li.btn.btn-default.
.fuelux .wizard .steps-container {
background-color: #eee;
}
#consoleThrottled {
z-index: 999;
top: 0px;
opacity: 0.6;
left: 0;
position: absolute;
margin: 0 15px;
border-radius: 4px 4px 0 0;
}
#consoleThrottled:hover {
opacity: 1;
}

View file

@ -48,7 +48,11 @@
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div id="terminal"></div>
<div class="alert alert-info hidden" id="consoleThrottled">
The console is currently being throttled due to the speed at which data is being sent. Messages are being queued and will appear as the queue is worked through.
</div>
<div id="terminal">
</div>
</div>
<div class="col-md-12" style="text-align:center;">
<hr />
@ -364,10 +368,27 @@ $(window).load(function () {
});
// New Console Data Recieved
var outputQueue = [];
socket.on('console', function (data) {
terminal.echo(data.line);
outputQueue.push(data.line);
});
window.setInterval(pushOutputQueue, {{ env('CONSOLE_PUSH_FREQ', 250) }});
function pushOutputQueue()
{
if (outputQueue.length > {{ env('CONSOLE_PUSH_COUNT', 10) }}) {
$('#consoleThrottled').removeClass('hidden');
} else {
$('#consoleThrottled').addClass('hidden');
}
for (var i = 0; i < {{ env('CONSOLE_PUSH_COUNT', 10) }}; i++)
{
terminal.echo(outputQueue[0]);
outputQueue.shift();
}
}
// Update Listings on Initial Status
socket.on('initial_status', function (data) {
currentStatus = data.status;