* Radius. Block if (BUILD_MOD_RADIUS) added.
* Radius. Catalog radius with radius.h and radius.cpp files added.
* Declaration of methods GetVersion, SendMessage, SetUsers, Start added.
* Definition of method SendMessage added.
* The option for BUILD_MOD_RADIUS added.
* Header files <string>, <vector>, <list> added. Virtual methods Start,
Stop declaration added. Private methods AddUser, DelUser, GetUser,
UpdateUserAuthorization added. Class member variable errorStr, users,
userList, isRunning, m_conns, m_onAddUserConn, m_onDelUserConn added.
* Header files <functional>, "stg/user.h" added. Overriding virtual
methods Start, Stop added.
* Private methods SetUserNotifiers, UnSetUserNotifiers declaration added.
* Header file <cassert> added. Definition methods GetUser, AddUser, DelUser,
UpdateUserAuthorization added.
* Unnecessary block private removed. Unnecessary header files removed.
* Unnecessary methods removed. Unnecessary header files removed.
* Overriding virtual methods Start, Stop, Reload, IsRunning, ParseSettings, GetStrErroor,
GetStartPosition, GetStopPosition, SendMessage added. Class member
variable errorStr, isRunning added.
* Definition of methods Start, Stop, SendMessage removed.
* Header file <string> added. The functions PrintHelp, PrintVersion added.
Parsing command line parameters added. The parameter of function settings
when it call changed.
* Radius. Variable bool noDaemon added. Parameter -f/--f added to parsing
command line. The call of function ForkAndWait changed - it is called if the variable
noDaemon is false.
* Radius. Command line parameter 'path' value fixed in the function
PrintHelp. Parsing command line parameters fixed. The key
-f/--foreground added to parsing command line parameters.
* Radius. Return value in the function GetVersion changed.
* Radius. Unnecessary check 'argc = i + 2' removed from parsing command
line parameters.
* The macro NO_DAEMON removed. The logic driven by the macro changed to
command line argument f analysis.
* Radius. The check variable noDaemon added when create function call.
* Radius. The variable startFile definition moved to block if(!noDaemon)
in main function.
# General modules
option ( BUILD_MOD_AO "Build AlwaysOnline STG module." ON )
# General modules
option ( BUILD_MOD_AO "Build AlwaysOnline STG module." ON )
+option ( BUILD_MOD_RADIUS "Build Radius STG module." ON )
option ( BUILD_MOD_IA "Buils InetAccess STG module." ON )
option ( BUILD_MOD_SGCONFIG "Build SGConfig STG module." ON )
option ( BUILD_MOD_PING "Build Ping STG module." ON )
option ( BUILD_MOD_IA "Buils InetAccess STG module." ON )
option ( BUILD_MOD_SGCONFIG "Build SGConfig STG module." ON )
option ( BUILD_MOD_PING "Build Ping STG module." ON )
#include <fstream>
#include <vector>
#include <fstream>
#include <vector>
#include <set>
#include <csignal>
#include <cerrno>
#include <set>
#include <csignal>
#include <cerrno>
#include <sys/stat.h> // S_IRUSR
#include <fcntl.h> // create
#include <sys/stat.h> // S_IRUSR
#include <fcntl.h> // create
-#ifdef DEBUG
- #define NO_DAEMON (1)
-#endif
-
#define START_FILE "/._ST_ART_ED_"
using STG::SettingsImpl;
#define START_FILE "/._ST_ART_ED_"
using STG::SettingsImpl;
return 0;
}
//-----------------------------------------------------------------------------
return 0;
}
//-----------------------------------------------------------------------------
int ForkAndWait(const std::string& confDir)
int ForkAndWait(const std::string& confDir)
-#else
-int ForkAndWait(const std::string&)
-#endif
const auto pid = fork();
const auto startFile = confDir + START_FILE;
unlink(startFile.c_str());
const auto pid = fork();
const auto startFile = confDir + START_FILE;
unlink(startFile.c_str());
//-----------------------------------------------------------------------------
void KillExecuters()
{
//-----------------------------------------------------------------------------
void KillExecuters()
{
+
+void PrintHelp(const std::string& programName)
+{
+ std::cout << "Usage: " << programName << "[-h/--help] [-v/--version] [-f/--foreground] [<conf-dir-path>]\n"
+ << "\t --help, -h - print this help;\n"
+ << "\t --version, -v - print version;\n"
+ << "\t --foreground, -f - do not go into background;\n"
+ << "\t <conf-dir-path> - path to the directory where the configuration file is located.\n";
+}
+
+void PrintVersion(const std::string& programName)
+{
+ std::cout << programName << "\n"
+ << "Stargazer version" << " " << SERVER_VERSION << "\n";
+}
//-----------------------------------------------------------------------------
} // namespace anonymous
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
} // namespace anonymous
//-----------------------------------------------------------------------------
- SettingsImpl settings(argc == 2 ? argv[1] : "");
+ std::string path;
+ bool noDaemon(false);
+
+ if (argc == 1)
+ path = "";
+ else
+ {
+ for (int i = 1; i < argc; ++i)
+ {
+ const std::string arg(argv[i]);
+ if (arg == "--help" || arg == "-h")
+ {
+ PrintHelp(argv[0]);
+ return 0;
+ }
+ if (arg == "--version" || arg == "-v")
+ {
+ PrintVersion(argv[0]);
+ return 0;
+ }
+ if (arg == "--foreground" || arg == "-f")
+ noDaemon = true;
+ else
+ path = arg;
+ }
+ }
+
+ SettingsImpl settings(path);
if (settings.ReadSettings())
{
if (settings.ReadSettings())
{
-#ifndef NO_DAEMON
- const auto startFile = settings.GetConfDir() + START_FILE;
-#endif
-
- if (ForkAndWait(settings.GetConfDir()) < 0)
- STG::Logger::get()("Fork error!");
- return -1;
+ if (ForkAndWait(settings.GetConfDir()) < 0)
+ {
+ STG::Logger::get()("Fork error!");
+ return -1;
+ }
}
auto& WriteServLog = STG::Logger::get();
}
auto& WriteServLog = STG::Logger::get();
WriteServLog("Stg started successfully.");
WriteServLog("+++++++++++++++++++++++++++++++++++++++++++++");
WriteServLog("Stg started successfully.");
WriteServLog("+++++++++++++++++++++++++++++++++++++++++++++");
-#ifndef NO_DAEMON
- creat(startFile.c_str(), S_IRUSR);
-#endif
+ if (!noDaemon)
+ {
+ const auto startFile = settings.GetConfDir() + START_FILE;
+ creat(startFile.c_str(), S_IRUSR);
+ }
bool running = true;
while (running)
bool running = true;
while (running)
endif ()
endif ( BUILD_MOD_AO )
endif ()
endif ( BUILD_MOD_AO )
+if ( BUILD_MOD_RADIUS )
+ add_library ( mod_radius MODULE other/radius/radius.cpp )
+ target_link_libraries ( mod_radius scriptexecuter logger common )
+ set_target_properties ( mod_radius PROPERTIES PREFIX "" )
+
+ if ( CLANG_TIDY_EXE )
+ set_target_properties ( mod_radius PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}" )
+ endif ()
+ if ( INCLUDE_WHAT_YOU_USE_EXE )
+ set_target_properties ( mod_radius PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "${DO_INCLUDE_WHAT_YOU_USE}" )
+ endif ()
+endif ( BUILD_MOD_RADIUS )
+
if ( BUILD_MOD_IA )
add_library ( mod_auth_ia MODULE authorization/inetaccess/inetaccess.cpp )
target_link_libraries ( mod_auth_ia scriptexecuter crypto logger common )
if ( BUILD_MOD_IA )
add_library ( mod_auth_ia MODULE authorization/inetaccess/inetaccess.cpp )
target_link_libraries ( mod_auth_ia scriptexecuter crypto logger common )
--- /dev/null
+#include "radius.h"
+
+using STG::RADIUS;
+
+extern "C" STG::Plugin* GetPlugin()
+{
+ static RADIUS plugin;
+ return &plugin;
+}
+
+std::string RADIUS::GetVersion() const
+{
+ return "Radius v.1.0";
+}
+
+RADIUS::RADIUS()
+{
+}
+
--- /dev/null
+#pragma once
+
+#include "stg/auth.h"
+#include <string>
+
+namespace STG
+{
+ class RADIUS : public Auth
+ {
+ public:
+ RADIUS();
+
+ int Start() override { return 0; }
+ int Stop() override { return 0; }
+ int Reload(const ModuleSettings & /*ms*/) override { return 0; }
+ bool IsRunning() override { return isRunning; }
+ int ParseSettings() override { return 0; }
+ const std::string & GetStrError() const override { return errorStr; }
+ std::string GetVersion() const override;
+ uint16_t GetStartPosition() const override { return 0; }
+ uint16_t GetStopPosition() const override { return 0; }
+
+ int SendMessage(const Message & msg, uint32_t ip) const override { return 0; }
+
+ private:
+ mutable std::string errorStr;
+ bool isRunning;
+
+ };
+}