Commit a8b9e5b9 authored by Max Kellermann's avatar Max Kellermann

db/proxy: add "password" setting

Closes #283
parent 04f928e2
ver 0.20.21 (not yet released)
* database
- proxy: add "password" setting
ver 0.20.20 (2018/05/22)
* protocol
......
......@@ -2116,6 +2116,15 @@ run</programlisting>
</row>
<row>
<entry>
<varname>password</varname>
</entry>
<entry>
The password used to log in to the "master"
<application>MPD</application> instance.
</entry>
</row>
<row>
<entry>
<varname>keepalive</varname>
<parameter>yes|no</parameter>
</entry>
......
......@@ -82,6 +82,7 @@ class ProxyDatabase final : public Database, SocketMonitor, IdleMonitor {
DatabaseListener &listener;
const std::string host;
const std::string password;
const unsigned port;
const bool keepalive;
......@@ -359,6 +360,7 @@ ProxyDatabase::ProxyDatabase(EventLoop &_loop, DatabaseListener &_listener,
SocketMonitor(_loop), IdleMonitor(_loop),
listener(_listener),
host(block.GetBlockValue("host", "")),
password(block.GetBlockValue("password", "")),
port(block.GetBlockValue("port", 0u)),
keepalive(block.GetBlockValue("keepalive", false))
{
......@@ -402,6 +404,10 @@ ProxyDatabase::Connect()
try {
CheckError(connection);
if (!password.empty() &&
!mpd_run_password(connection, password.c_str()))
ThrowError(connection);
} catch (...) {
mpd_connection_free(connection);
connection = nullptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment