-int RADIUS::ParseSettings()
-{
- try {
- m_config = STG::Config(m_settings);
- return reconnect() ? 0 : -1;
- } catch (const std::runtime_error& ex) {
- m_logger("Failed to parse settings. %s", ex.what());
- return -1;
- }
-}
-
-int RADIUS::Start()
-{
- if (m_running)
- return 0;
-
- int res = pthread_create(&m_thread, NULL, run, this);
- if (res == 0)
- return 0;
-
- m_error = strerror(res);
- m_logger("Failed to create thread: '" + m_error + "'.");
- return -1;
-}
-
-int RADIUS::Stop()
-{
- std::set<std::string>::const_iterator it = m_logins.begin();
- for (; it != m_logins.end(); ++it)
- m_users->Unauthorize(*it, this, "Stopping RADIUS plugin.");
- m_logins.clear();
-
- if (m_stopped)
- return 0;
-
- m_running = false;
-
- for (size_t i = 0; i < 25 && !m_stopped; i++) {
- struct timespec ts = {0, 200000000};
- nanosleep(&ts, NULL);
- }
-
- if (m_stopped) {
- pthread_join(m_thread, NULL);
- return 0;
- }
-
- if (m_config.connectionType == Config::UNIX)
- unlink(m_config.bindAddress.c_str());
-
- m_error = "Failed to stop thread.";
- m_logger(m_error);
- return -1;
-}
-//-----------------------------------------------------------------------------
-void* RADIUS::run(void* d)
-{
- sigset_t signalSet;
- sigfillset(&signalSet);
- pthread_sigmask(SIG_BLOCK, &signalSet, NULL);
-
- static_cast<RADIUS *>(d)->runImpl();
-
- return NULL;
-}
-
-bool RADIUS::reconnect()
-{
- if (!m_conns.empty())