From b08fe09e296524daf4de7ed16e0bed224f5008a2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 7 Dec 2015 09:50:26 +0000 Subject: tracklist: support limiting maximum tracklist size This defaults to 16384? This is what mpd uses by default as well. Of course folks interacting with dtas-player directly can override this: dtas-tl max INTEGER dtas-tl max This is NOT meant to be a hard security measure for local users talking to dtas-player directly. It is only to prevent accidentally stupid things like flooding the playlist with a broken script and to prevent remote users from DoS-ing us via the to-be-written mpd proxy/emulation layer. Remember: dtas-player itself will ALWAYS remain capable of executing arbitrary code :) --- lib/dtas/player/client_handler.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/dtas/player/client_handler.rb') diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb index 500704a..119aa31 100644 --- a/lib/dtas/player/client_handler.rb +++ b/lib/dtas/player/client_handler.rb @@ -566,6 +566,7 @@ module DTAS::Player::ClientHandler # :nodoc: end begin track_id = @tl.add_track(path, after_track_id, set_as_current) + return io.emit('ERR FULL') unless track_id rescue ArgumentError => e return io.emit("ERR #{e.message}") end @@ -593,6 +594,13 @@ module DTAS::Player::ClientHandler # :nodoc: set_bool(io, 'tl shuffle', v) { |b| @tl.shuffle = b } io.emit('OK') end + when 'max' + case v = msg.shift + when nil then io.emit("tl max #{@tl.max}") + when %r{\A(\d[\d_]*)\z} then io.emit("tl max #{@tl.max = $1.to_i}") + else + return io.emit('ERR tl max must a non-negative integer') + end when "remove" track_id = msg.shift or return io.emit("ERR track_id not specified") track_id = track_id.to_i -- cgit v1.2.3-24-ge0c7