From: Maxim Mamontov <faust@gts.dp.ua>
Date: Thu, 9 Dec 2010 12:51:01 +0000 (+0200)
Subject: Небольшой рефакторинг плагина radius
X-Git-Tag: 2.407-rc3~296
X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/2c1686d0b3dee0f327cda1b55ac7e42b21446416

Небольшой рефакторинг плагина radius
---

diff --git a/projects/stargazer/plugins/other/radius/radius.cpp b/projects/stargazer/plugins/other/radius/radius.cpp
index 8c7d53d1..4dd18c46 100644
--- a/projects/stargazer/plugins/other/radius/radius.cpp
+++ b/projects/stargazer/plugins/other/radius/radius.cpp
@@ -26,8 +26,8 @@
  *
  */
 
+#include <csignal>
 #include <algorithm>
-#include <signal.h>
 
 #include "radius.h"
 #include "common.h"
@@ -71,35 +71,6 @@ return radc.GetPlugin();
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-uint16_t RAD_SETTINGS::GetPort() const
-{
-return port;
-}
-//-----------------------------------------------------------------------------
-int RAD_SETTINGS::GetPassword(string * password) const
-{
-*password = RAD_SETTINGS::password;
-return 0;
-}
-//-----------------------------------------------------------------------------
-int RAD_SETTINGS::GetAuthServices(list<string> * svcs) const
-{
-*svcs = authServices;
-return 0;
-}
-//-----------------------------------------------------------------------------
-int RAD_SETTINGS::GetAcctServices(list<string> * svcs) const
-{
-*svcs = acctServices;
-return 0;
-}
-//-----------------------------------------------------------------------------
-int RAD_SETTINGS::ParseIP(const string & str, uint32_t * IP)
-{
-*IP = inet_addr(str.c_str());
-return *IP == INADDR_NONE ? -1 : 0;
-}
-//-----------------------------------------------------------------------------
 int RAD_SETTINGS::ParseIntInRange(const string & str, int min, int max, int * val)
 {
 if (str2x(str.c_str(), *val))
@@ -279,11 +250,10 @@ return 0;
 //-----------------------------------------------------------------------------
 int RADIUS::Start()
 {
-string password;
+string password(radSettings.GetPassword());
 
-radSettings.GetPassword(&password);
-radSettings.GetAuthServices(&authServices);
-radSettings.GetAcctServices(&acctServices);
+authServices = radSettings.GetAuthServices();
+acctServices = radSettings.GetAcctServices();
 
 InitEncrypt(&ctx, password);
 
diff --git a/projects/stargazer/plugins/other/radius/radius.h b/projects/stargazer/plugins/other/radius/radius.h
index 8d37ab14..e13a7a7f 100644
--- a/projects/stargazer/plugins/other/radius/radius.h
+++ b/projects/stargazer/plugins/other/radius/radius.h
@@ -29,11 +29,12 @@
 #ifndef RADIUS_H
 #define RADIUS_H
 
+#include <pthread.h>
+
+#include <cstring>
+#include <cstdlib>
 #include <string>
 #include <list>
-#include <pthread.h>
-#include <string.h>
-#include <stdlib.h>
 
 #include "os_int.h"
 #include "base_auth.h"
@@ -55,24 +56,24 @@ class RADIUS;
 class RAD_SETTINGS
 {
 public:
-    virtual         ~RAD_SETTINGS(){};
-    const string&   GetStrError() const { return errorStr; };
-    int             ParseSettings(const MODULE_SETTINGS & s);
-    uint16_t        GetPort() const;
-    int             GetPassword(string * password) const;
-    int             GetAuthServices(list<string> * svcs) const;
-    int             GetAcctServices(list<string> * svcs) const;
+    RAD_SETTINGS() : port(0) {}
+    virtual ~RAD_SETTINGS() {}
+    const string & GetStrError() const { return errorStr; }
+    int ParseSettings(const MODULE_SETTINGS & s);
+    uint16_t GetPort() const { return port; }
+    const std::string & GetPassword() const { return password; }
+    const list<string> & GetAuthServices() const { return authServices; }
+    const list<string> & GetAcctServices() const { return acctServices; }
 
 private:
-    int             ParseIntInRange(const string & str, int min, int max, int * val);
-    int             ParseIP(const string & str, uint32_t * routerIP);
-    int             ParseServices(const vector<string> & str, list<string> * lst);
-
-    uint16_t            port;
-    string              errorStr;
-    string              password;
-    list<string>        authServices;
-    list<string>        acctServices;
+    int ParseIntInRange(const string & str, int min, int max, int * val);
+    int ParseServices(const vector<string> & str, list<string> * lst);
+
+    uint16_t port;
+    string errorStr;
+    string password;
+    list<string> authServices;
+    list<string> acctServices;
 };
 //-----------------------------------------------------------------------------
 struct RAD_SESSION {