From 0cea67ee706d73acbd07a48e5d3b758ba016c1a8 Mon Sep 17 00:00:00 2001 From: Jakob Ovrum <> Date: Sat, 19 Jan 2019 17:36:14 +0100 Subject: [PATCH] shout output plugin: add support for TLS --- doc/plugins.rst | 2 ++ src/output/plugins/ShoutOutputPlugin.cxx | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/doc/plugins.rst b/doc/plugins.rst index 3e6d6dd08..0e09b35ab 100644 --- a/doc/plugins.rst +++ b/doc/plugins.rst @@ -974,6 +974,8 @@ You must set a format. - Set the timeout for the shout connection in seconds. Defaults to 2 seconds. * - **protocol icecast2|icecast1|shoutcast** - Specifies the protocol that wil be used to connect to the server. The default is "icecast2". + * - **tls disabled|auto|auto_no_plain|rfc2818|rfc2817** + - Specifies what kind of TLS to use. The default is "disabled" (no TLS). * - **mount URI** - Mounts the :program:`MPD` stream in the specified URI. * - **user USERNAME** diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx index df9df58e4..81ba5fe42 100644 --- a/src/output/plugins/ShoutOutputPlugin.cxx +++ b/src/output/plugins/ShoutOutputPlugin.cxx @@ -141,6 +141,25 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block) protocol = SHOUT_PROTOCOL_HTTP; } + unsigned tls; + value = block.GetBlockValue("tls"); + if (value != nullptr) { + if (0 == strcmp(value, "disabled")) + tls = SHOUT_TLS_DISABLED; + else if(0 == strcmp(value, "auto")) + tls = SHOUT_TLS_AUTO; + else if(0 == strcmp(value, "auto_no_plain")) + tls = SHOUT_TLS_AUTO_NO_PLAIN; + else if(0 == strcmp(value, "rfc2818")) + tls = SHOUT_TLS_RFC2818; + else if(0 == strcmp(value, "rfc2817")) + tls = SHOUT_TLS_RFC2817; + else + throw FormatRuntimeError("invalid shout TLS option \"%s\"", value); + } else { + tls = SHOUT_TLS_DISABLED; + } + if (shout_set_host(shout_conn, host) != SHOUTERR_SUCCESS || shout_set_port(shout_conn, port) != SHOUTERR_SUCCESS || shout_set_password(shout_conn, passwd) != SHOUTERR_SUCCESS || @@ -151,6 +170,7 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block) shout_set_format(shout_conn, shout_format) != SHOUTERR_SUCCESS || shout_set_protocol(shout_conn, protocol) != SHOUTERR_SUCCESS || + shout_set_tls(shout_conn, tls) != SHOUTERR_SUCCESS || shout_set_agent(shout_conn, "MPD") != SHOUTERR_SUCCESS) throw std::runtime_error(shout_get_error(shout_conn));