output/httpd: add config option "dscp"

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1401
This commit is contained in:
Max Kellermann 2022-01-10 22:37:33 +01:00
parent 219c416a1e
commit be72d45356
2 changed files with 18 additions and 0 deletions

View File

@ -994,6 +994,13 @@ It is highly recommended to configure a fixed format, because a stream cannot sw
- Binds the HTTP server to the specified port. - Binds the HTTP server to the specified port.
* - **bind_to_address ADDR** * - **bind_to_address ADDR**
- Binds the HTTP server to the specified address (IPv4, IPv6 or local socket). Multiple addresses in parallel are not supported. - Binds the HTTP server to the specified address (IPv4, IPv6 or local socket). Multiple addresses in parallel are not supported.
* - **dscp_class CLASS**
- Sets a DSCP (`Differentiated Services Code Point
<https://en.wikipedia.org/wiki/Differentiated_services>`__)
class for outgoing traffic. This can either be a name
(``CS*``, ``LE``, ``AF*``, ``EF``) or numeric (decimal or
hexadecimal). A reasonable choice for this setting is ``CS3``
("broadcast video").
* - **encoder NAME** * - **encoder NAME**
- Chooses an encoder plugin. A list of encoder plugins can be found in the encoder plugin reference :ref:`encoder_plugins`. - Chooses an encoder plugin. A list of encoder plugins can be found in the encoder plugin reference :ref:`encoder_plugins`.
* - **max_clients MC** * - **max_clients MC**

View File

@ -28,11 +28,13 @@
#include "Page.hxx" #include "Page.hxx"
#include "IcyMetaDataServer.hxx" #include "IcyMetaDataServer.hxx"
#include "event/Call.hxx" #include "event/Call.hxx"
#include "net/DscpParser.hxx"
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "util/DeleteDisposer.hxx" #include "util/DeleteDisposer.hxx"
#include "config/Net.hxx" #include "config/Net.hxx"
#include <cassert> #include <cassert>
#include <stdexcept>
#include <string.h> #include <string.h>
@ -49,6 +51,15 @@ HttpdOutput::HttpdOutput(EventLoop &_loop, const ConfigBlock &block)
website(block.GetBlockValue("website", "Set website in config")), website(block.GetBlockValue("website", "Set website in config")),
clients_max(block.GetBlockValue("max_clients", 0U)) clients_max(block.GetBlockValue("max_clients", 0U))
{ {
if (const auto *p = block.GetBlockParam("dscp_class"))
p->With([this](const char *s){
const int value = ParseDscpClass(s);
if (value < 0)
throw std::runtime_error("Not a valid DSCP class");
ServerSocket::SetDscpClass(value);
});
/* set up bind_to_address */ /* set up bind_to_address */
ServerSocketAddGeneric(*this, block.GetBlockValue("bind_to_address"), block.GetBlockValue("port", 8000U)); ServerSocketAddGeneric(*this, block.GetBlockValue("bind_to_address"), block.GetBlockValue("port", 8000U));