diff --git a/NEWS b/NEWS index 252961d43..c1deceb9a 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.20.21 (not yet released) +* database + - proxy: add "password" setting ver 0.20.20 (2018/05/22) * protocol diff --git a/doc/user.xml b/doc/user.xml index a7f809db5..944681153 100644 --- a/doc/user.xml +++ b/doc/user.xml @@ -2114,6 +2114,15 @@ run MPD instance. + + + password + + + The password used to log in to the "master" + MPD instance. + + keepalive diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index c2bc33c6c..bd6da2f01 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -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;