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

@ -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;