diff --git a/src/config.cpp b/src/config.cpp index cadf06589cf787a78904285291a6b403bc34a449..fefd782f0ee30fb07864000581853f9e94be0511 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -29,10 +29,16 @@ #endif #endif +#include "iostream" +#include "boost/version.hpp" + +#define BOOST_MAJOR_VERSION BOOST_VERSION / 100000 +#define BOOST_MINOR_VERSION BOOST_VERSION / 100 % 1000 + using namespace boost::program_options; namespace Transport { -int getRandomPort(const std::string &s) { +static int getRandomPort(const std::string &s) { unsigned long r = 0; BOOST_FOREACH(char c, s) { r += (int) c; @@ -72,14 +78,14 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description ("service.protocol", value()->default_value(""), "Protocol") ("service.pidfile", value()->default_value("/var/run/spectrum2/$jid.pid"), "Full path to pid file") ("service.working_dir", value()->default_value("/var/lib/spectrum2/$jid"), "Working dir") - ("service.allowed_servers", value()->default_value(""), "Only users from these servers can connect") + ("service.allowed_servers", value >()->multitoken(), "Only users from these servers can connect") ("service.server_mode", value()->default_value(false), "True if Spectrum should behave as server") ("service.users_per_backend", value()->default_value(100), "Number of users per one legacy network backend") ("service.backend_host", value()->default_value("localhost"), "Host to bind backend server to") ("service.backend_port", value()->default_value("0"), "Port to bind backend server to") ("service.cert", value()->default_value(""), "PKCS#12 Certificate.") ("service.cert_password", value()->default_value(""), "PKCS#12 Certificate password.") - ("service.admin_jid", value()->default_value(""), "Administrator jid.") + ("service.admin_jid", value >()->multitoken(), "Administrator jid.") ("service.admin_password", value()->default_value(""), "Administrator password.") ("service.reuse_old_backends", value()->default_value(true), "True if Spectrum should use old backends which were full in the past.") ("service.idle_reconnect_time", value()->default_value(0), "Time in seconds after which idle users are reconnected to let their backend die.") @@ -101,6 +107,8 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description ("registration.local_username_label", value()->default_value("Local username:"), "Label for local usernme field") ("registration.local_account_server", value()->default_value("localhost"), "The server on which the local accounts will be checked for validity") ("registration.local_account_server_timeout", value()->default_value(10000), "Timeout when checking local user on local_account_server (msecs)") + ("gateway_responder.prompt", value()->default_value("Contact ID"), "Value of field") + ("gateway_responder.label", value()->default_value("Enter legacy network contact ID."), "Label for add contact ID field") ("database.type", value()->default_value("none"), "Database type.") ("database.database", value()->default_value("/var/lib/spectrum2/$jid/database.sql"), "Database used to store data") ("database.server", value()->default_value("localhost"), "Database server.") @@ -195,8 +203,17 @@ bool Config::load(std::istream &ifs) { } bool Config::load(const std::string &configfile, const std::string &jid) { - options_description opts("Transport options"); - return load(configfile, opts, jid); + try { + options_description opts("Transport options"); + return load(configfile, opts, jid); + } catch ( const boost::program_options::multiple_occurrences& e ) { +#if (BOOST_MAJOR_VERSION >= 1 && BOOST_MINOR_VERSION >= 42) + std::cerr << configfile << " parsing error: " << e.what() << " from option: " << e.get_option_name() << std::endl; +#else + std::cerr << configfile << " parsing error: " << e.what() << std::endl; +#endif + return false; + } } bool Config::reload() {