#include "stg/users.h"
#include "stg/user_property.h"
#include "stg/common.h"
+#include "stg/plugin_creator.h"
#include "ao.h"
-class AO_CREATOR
-{
-private:
- AUTH_AO * ao;
-
-public:
- AO_CREATOR()
- : ao(new AUTH_AO())
- {
- };
- ~AO_CREATOR()
- {
- delete ao;
- };
-
- AUTH_AO * GetPlugin()
- {
- return ao;
- };
-};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-AO_CREATOR aoc;
+PLUGIN_CREATOR<AUTH_AO> aoc;
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+PLUGIN * GetPlugin()
+{
+return aoc.GetPlugin();
+}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-PLUGIN * GetPlugin()
-{
-return aoc.GetPlugin();
-}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
const string AUTH_AO::GetVersion() const
{
return "Always Online authorizator v.1.0";
#include "stg/tariff.h"
#include "stg/user_property.h"
#include "stg/settings.h"
+#include "stg/plugin_creator.h"
#include "inetaccess.h"
extern volatile const time_t stgTime;
void Decrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8);
void Encrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8);
-//-----------------------------------------------------------------------------
-class IA_CREATOR
-{
-private:
- AUTH_IA * ia;
-
-public:
- IA_CREATOR()
- : ia(new AUTH_IA())
- {
- };
- ~IA_CREATOR()
- {
- delete ia;
- };
-
- AUTH_IA * GetPlugin()
- {
- return ia;
- };
-};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-IA_CREATOR iac;
+PLUGIN_CREATOR<AUTH_IA> iac;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include "stg/user.h"
#include "stg/common.h"
#include "stg/user_property.h"
+#include "stg/plugin_creator.h"
#include "stress.h"
-class STRESS_CREATOR
-{
-private:
- AUTH_STRESS * dc;
-
-public:
- STRESS_CREATOR()
- {
- printfd(__FILE__, "constructor STRESS_CREATOR\n");
- dc = new AUTH_STRESS();
- };
- ~STRESS_CREATOR()
- {
- printfd(__FILE__, "destructor STRESS_CREATOR\n");
- delete dc;
- };
-
- PLUGIN * GetPlugin()
- {
- return dc;
- };
-};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-STRESS_CREATOR stressc;
+PLUGIN_CREATOR<AUTH_STRESS> stressc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include <netinet/in.h>
#include <arpa/inet.h>
+#include "stg/plugin_creator.h"
#include "debug_cap.h"
#include "../../../traffcounter.h"
#include "libpal.h"
fclose(f);
}
//-----------------------------------------------------------------------------
-
-class CAP_DEBUG_CREATOR
-{
-private:
- DEBUG_CAP * dc;
-
-public:
- CAP_DEBUG_CREATOR()
- : dc(new DEBUG_CAP())
- {
- };
- ~CAP_DEBUG_CREATOR()
- {
- delete dc;
- };
-
- DEBUG_CAP * GetCapturer()
- {
- return dc;
- };
-};
-//-----------------------------------------------------------------------------
-RAW_PACKET MakeTCPPacket(const char * src,
- const char * dst,
- uint16_t sport,
- uint16_t dport,
- uint16_t len);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-CAP_DEBUG_CREATOR cdc;
+PLUGIN_CREATOR<DEBUG_CAP> cdc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
BASE_PLUGIN * GetPlugin()
{
-return cdc.GetCapturer();
+return cdc.GetPlugin();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+RAW_PACKET MakeTCPPacket(const char * src,
+ const char * dst,
+ uint16_t sport,
+ uint16_t dport,
+ uint16_t len);
const string DEBUG_CAP::GetVersion() const
{
return "Debug_cap v.0.01a";
#include "stg/common.h"
#include "stg/raw_ip_packet.h"
#include "stg/traffcounter.h"
+#include "stg/plugin_creator.h"
#include "cap_nf.h"
-class CAP_NF_CREATOR {
-public:
- CAP_NF_CREATOR()
- : nf(new NF_CAP())
- {
- }
-
- ~CAP_NF_CREATOR()
- {
- delete nf;
- }
-
- NF_CAP * GetCapturer() { return nf; }
-private:
- NF_CAP * nf;
-} cnc;
+PLUGIN_CREATOR<NF_CAP> cnc;
PLUGIN * GetPlugin()
{
-return cnc.GetCapturer();
+return cnc.GetPlugin();
}
NF_CAP::NF_CAP()
#include "stg/common.h"
#include "stg/traffcounter.h"
+#include "sg/plugin_creator.h"
#include "divert_cap.h"
#define BUFF_LEN (16384) /* max mtu -> lo=16436 TODO why?*/
pollfd pollddiv;
DIVERT_DATA cddiv; //capture data
//-----------------------------------------------------------------------------
-class DIVERT_CAP_CREATOR {
-private:
- DIVERT_CAP * divc;
-
-public:
- DIVERT_CAP_CREATOR()
- : divc(new DIVERT_CAP())
- {
- }
- ~DIVERT_CAP_CREATOR()
- {
- delete divc;
- }
-
- DIVERT_CAP * GetCapturer()
- {
- return divc;
- }
-};
-//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-DIVERT_CAP_CREATOR dcc;
+PLUGIN_CREATOR<DIVERT_CAP> dcc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
PLUGIN * GetPlugin()
{
-return dcc.GetCapturer();
+return dcc.GetPlugin();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include <signal.h>
#include <unistd.h>
-#include "ether_cap.h"
#include "stg/common.h"
#include "stg/raw_ip_packet.h"
#include "stg/traffcounter.h"
+#include "stg/plugin_creator.h"
+#include "ether_cap.h"
//#define CAP_DEBUG 1
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-class BPF_CAP_CREATOR {
-private:
- BPF_CAP * bpfc;
-
-public:
- BPF_CAP_CREATOR()
- : bpfc(new BPF_CAP())
- {
- }
- ~BPF_CAP_CREATOR()
- {
- delete bpfc;
- }
- BPF_CAP * GetCapturer()
- {
- return bpfc;
- }
-};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-BPF_CAP_CREATOR bcc;
+PLUGIN_CREATOR<BPF_CAP> bcc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
PLUGIN * GetPlugin()
{
-return bcc.GetCapturer();
+return bcc.GetPlugin();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include <sys/ioctl.h>
#include <net/if.h>
-#include "ether_cap.h"
#include "stg/common.h"
#include "stg/raw_ip_packet.h"
#include "stg/traffcounter.h"
+#include "stg/plugin_creator.h"
+#include "ether_cap.h"
//#define CAP_DEBUG 1
-//-----------------------------------------------------------------------------
-class ETHER_CAP_CREATOR {
-private:
- ETHER_CAP * ec;
-
-public:
- ETHER_CAP_CREATOR()
- : ec(new ETHER_CAP())
- {
- }
- ~ETHER_CAP_CREATOR()
- {
- delete ec;
- }
-
- ETHER_CAP * GetCapturer()
- {
- return ec;
- }
-};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-ETHER_CAP_CREATOR ecc;
+PLUGIN_CREATOR<ETHER_CAP> ecc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
PLUGIN * GetPlugin()
{
-return ecc.GetCapturer();
+return ecc.GetPlugin();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include "stg/raw_ip_packet.h"
#include "stg/traffcounter.h"
+#include "stg/plugin_creator.h"
#include "ipq_cap.h"
extern "C"
#include "libipq.h"
}
-class IPQ_CAP_CREATOR {
-private:
- IPQ_CAP * ic;
-
-public:
- IPQ_CAP_CREATOR()
- : ic(new IPQ_CAP())
- {
- }
- ~IPQ_CAP_CREATOR()
- {
- delete ic;
- }
-
- IPQ_CAP * GetCapturer()
- {
- return ic;
- }
-};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-IPQ_CAP_CREATOR icc;
+PLUGIN_CREATOR<IPQ_CAP> icc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
PLUGIN * GetPlugin()
{
-return icc.GetCapturer();
+return icc.GetPlugin();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include "stg/admin.h"
#include "stg/module_settings.h"
#include "stg/settings.h"
+#include "stg/plugin_creator.h"
#include "rpcconfig.h"
#include "info_methods.h"
#include "admins_methods.h"
#include "messages_methods.h"
-class RPC_CONFIG_CREATOR {
-private:
- RPC_CONFIG * rpcconfig;
-
-public:
- RPC_CONFIG_CREATOR()
- : rpcconfig(new RPC_CONFIG())
- {
- }
- ~RPC_CONFIG_CREATOR()
- {
- delete rpcconfig;
- }
-
- RPC_CONFIG * GetPlugin()
- {
- return rpcconfig;
- }
-};
-
-RPC_CONFIG_CREATOR rpcc;
+PLUGIN_CREATOR<RPC_CONFIG> rpcc;
RPC_CONFIG_SETTINGS::RPC_CONFIG_SETTINGS()
: errorStr(),
+#include "stg/plugin_creator.h"
#include "stgconfig.h"
-class STGCONFIG_CREATOR
-{
-private:
- STGCONFIG2 * stgconfig;
-
-public:
- STGCONFIG_CREATOR()
- : stgconfig(new STGCONFIG2())
- {
- };
- ~STGCONFIG_CREATOR()
- {
- delete stgconfig;
- };
-
- STGCONFIG2 * GetPlugin()
- {
- return stgconfig;
- };
-};
-
-STGCONFIG_CREATOR stgc;
+PLUGIN_CREATOR<STGCONFIG2> stgc;
BASE_PLUGIN * GetPlugin()
{
#include "stg/tariffs.h"
#include "stg/admins.h"
#include "stg/users.h"
+#include "stg/plugin_creator.h"
#include "stgconfig.h"
-class STGCONFIG_CREATOR
-{
-private:
- STG_CONFIG * stgconfig;
-
-public:
- STGCONFIG_CREATOR()
- : stgconfig(new STG_CONFIG())
- {
- };
- ~STGCONFIG_CREATOR()
- {
- delete stgconfig;
- };
-
- STG_CONFIG * GetPlugin()
- {
- return stgconfig;
- };
-};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-STGCONFIG_CREATOR stgc;
+PLUGIN_CREATOR<STG_CONFIG> stgc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include <functional>
#include <algorithm>
+#include "stg/plugin_creator.h"
#include "stgconfig.h"
#include "../../../tariffs.h"
#include "../../../admins.h"
#include "../../../users.h"
-class STGCONFIG_CREATOR
-{
-private:
- STG_CONFIG * stgconfig;
-
-public:
- STGCONFIG_CREATOR()
- : stgconfig(new STG_CONFIG())
- {
- };
- ~STGCONFIG_CREATOR()
- {
- delete stgconfig;
- };
-
- STG_CONFIG * GetPlugin()
- {
- return stgconfig;
- };
-};
-
-STGCONFIG_CREATOR stgc;
+PLUGIN_CREATOR<STG_CONFIG> stgc;
BASE_PLUGIN * GetPlugin()
{
#include <unistd.h>
#include <signal.h>
+#include "stg/plugin_creator.h"
#include "xrconfig.h"
#include "../../../tariff2.h"
#include "../../../admins.h"
#include "../../../users.h"
-class XR_CONFIG_CREATOR
-{
-private:
- XR_CONFIG * xrconfig;
-
-public:
- XR_CONFIG_CREATOR()
- : xrconfig(new XR_CONFIG())
- {
- };
- ~XR_CONFIG_CREATOR()
- {
- delete xrconfig;
- };
-
- XR_CONFIG * GetPlugin()
- {
- return xrconfig;
- };
-};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-XRCONFIG_CREATOR xrc;
+PLUGIN_CREATOR<XR_CONFIG> xrc;
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+BASE_PLUGIN * GetPlugin()
+{
+return xrc.GetPlugin();
+}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-BASE_PLUGIN * GetPlugin()
-{
-return xrc.GetPlugin();
-}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
const string XR_CONFIG::GetVersion() const
{
return "XR_configurator v.0.01";
#include "stg/user.h"
#include "stg/locker.h"
#include "stg/user_property.h"
+#include "stg/plugin_creator.h"
#include "ping.h"
-class PING_CREATOR
-{
-private:
- PING * ping;
-
-public:
- PING_CREATOR()
- : ping(new PING())
- {
- };
- ~PING_CREATOR()
- {
- delete ping;
- };
-
- PING * GetPlugin()
- {
- return ping;
- };
-};
+PLUGIN_CREATOR<PING> pc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-PING_CREATOR pc;
+PLUGIN * GetPlugin()
+{
+return pc.GetPlugin();
+}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-PLUGIN * GetPlugin()
-{
-return pc.GetPlugin();
-}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
PING_SETTINGS::PING_SETTINGS()
: pingDelay(0)
{
#include "stg/common.h"
#include "stg/user_conf.h"
#include "stg/user_property.h"
+#include "stg/plugin_creator.h"
#include "radius.h"
extern volatile const time_t stgTime;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-class RAD_CREATOR {
-private:
- RADIUS * rad;
-
-public:
- RAD_CREATOR()
- : rad(new RADIUS())
- {
- }
- ~RAD_CREATOR()
- {
- delete rad;
- }
-
- RADIUS * GetPlugin()
- {
- return rad;
- }
-};
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-RAD_CREATOR radc;
+PLUGIN_CREATOR<RADIUS> radc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include "stg/common.h"
#include "stg/locker.h"
#include "stg/user_property.h"
+#include "stg/plugin_creator.h"
#include "rscript.h"
#include "ur_functor.h"
#include "send_functor.h"
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-class RS_CREATOR
-{
-private:
- REMOTE_SCRIPT * rs;
-
-public:
- RS_CREATOR()
- : rs(new REMOTE_SCRIPT())
- {
- };
- ~RS_CREATOR()
- {
- delete rs;
- };
-
- REMOTE_SCRIPT * GetPlugin()
- {
- return rs;
- };
-};
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-RS_CREATOR rsc;
+PLUGIN_CREATOR<REMOTE_SCRIPT> rsc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include <algorithm>
#include "stg/common.h"
+#include "stg/plugin_creator.h"
#include "smux.h"
#include "utils.h"
-class SMUX_CREATOR
-{
-private:
- SMUX * smux;
-
-public:
- SMUX_CREATOR() : smux(new SMUX()) {}
- ~SMUX_CREATOR() { delete smux; }
-
- SMUX * GetPlugin() { return smux; }
-};
-
-SMUX_CREATOR sac;
+PLUGIN_CREATOR<SMUX> sac;
PLUGIN * GetPlugin()
{
#include "stg/blowfish.h"
#include "stg/logger.h"
#include "stg/locker.h"
+#include "stg/plugin_creator.h"
#include "file_store.h"
#define DELETED_USERS_DIR "deleted_users"
const int pt_mega = 1024 * 1024;
//-----------------------------------------------------------------------------
-class BAK_FILE
-{
-public:
-
- //-------------------------------------------------------------------------
- BAK_FILE(const string & fileName, bool removeBak)
- : f(NULL),
- removeBak(false)
- {
- bakSuccessed = false;
- BAK_FILE::removeBak = removeBak;
- fileNameBak = fileName + ".bak";
- if (rename(fileName.c_str(), fileNameBak.c_str()))
- {
- printfd(__FILE__, "BAK_FILE::BAK_FILE - rename failed. Message: '%s'\n", strerror(errno));
- }
- else
- {
- bakSuccessed = true;
- }
-
- }
- //-------------------------------------------------------------------------
- ~BAK_FILE()
- {
- if(bakSuccessed && removeBak)
- {
- if (unlink(fileNameBak.c_str()))
- {
- printfd(__FILE__, "BAK_FILE::~BAK_FILE - unlink failed. Message: '%s'\n", strerror(errno));
- }
- }
- }
- //-------------------------------------------------------------------------
-
-private:
- FILE * f;
- bool bakSuccessed;
- string fileNameBak;
- bool removeBak;
-};
-//-----------------------------------------------------------------------------
-class FILES_STORE_CREATOR
-{
-private:
- FILES_STORE * fs;
-
-public:
- FILES_STORE_CREATOR()
- : fs(new FILES_STORE())
- {
- };
- ~FILES_STORE_CREATOR()
- {
- delete fs;
- };
-
- FILES_STORE * GetStore()
- {
- return fs;
- };
-};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-FILES_STORE_CREATOR fsc;
+PLUGIN_CREATOR<FILES_STORE> fsc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
STORE * GetStore()
{
-return fsc.GetStore();
+return fsc.GetPlugin();
}
//-----------------------------------------------------------------------------
FILES_STORE_SETTINGS::FILES_STORE_SETTINGS()
string fileName;
fileName = storeSettings.GetUsersDir() + "/" + login + "/conf";
-//BAK_FILE bakFile(fileName, storeSettings.GetRemoveBak());
-
CONFIGFILE cfstat(fileName, true);
int e = cfstat.Error();
string fileName;
fileName = storeSettings.GetUsersDir() + "/" + login + "/stat";
-//BAK_FILE bakFile(fileName, storeSettings.GetRemoveBak());
-
{
CONFIGFILE cfstat(fileName, true);
int e = cfstat.Error();
#include <vector>
#include <algorithm>
-using namespace std;
-
-#include "firebird_store.h"
#include "stg/ibpp.h"
+#include "stg/plugin_creator.h"
+#include "firebird_store.h"
-class FIREBIRD_STORE_CREATOR
-{
-public:
- FIREBIRD_STORE_CREATOR()
- : frb(new FIREBIRD_STORE())
- {
- };
- ~FIREBIRD_STORE_CREATOR()
- {
- delete frb;
- };
- FIREBIRD_STORE * GetStore() { return frb; };
-private:
- FIREBIRD_STORE * frb;
-} frsc;
+using namespace std;
+PLUGIN_CREATOR<FIREBIRD_STORE> frsc;
//-----------------------------------------------------------------------------
STORE * GetStore()
{
#include "stg/user_conf.h"
#include "stg/user_stat.h"
#include "stg/blowfish.h"
+#include "stg/plugin_creator.h"
#include "mysql_store.h"
#define adm_enc_passwd "cjeifY8m3"
return 0;
}
-class MYSQL_STORE_CREATOR
-{
-private:
- MYSQL_STORE * ms;
-
-public:
- MYSQL_STORE_CREATOR()
- : ms(new MYSQL_STORE())
- {
- };
- ~MYSQL_STORE_CREATOR()
- {
- delete ms;
- };
-
- MYSQL_STORE * GetStore()
- {
- return ms;
- };
-} msc;
+PLUGIN_CREATOR<MYSQL_STORE> msc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include <libpq-fe.h>
-#include "postgresql_store.h"
-#include "postgresql_store_utils.h"
#include "stg/module_settings.h"
+#include "stg/plugin_creator.h"
+#include "postgresql_store_utils.h"
+#include "postgresql_store.h"
-class POSTGRESQL_STORE_CREATOR
-{
-public:
- POSTGRESQL_STORE_CREATOR()
- : pqStore(new POSTGRESQL_STORE())
- {
- };
- ~POSTGRESQL_STORE_CREATOR()
- {
- delete pqStore;
- };
- POSTGRESQL_STORE * GetStore() { return pqStore; };
-private:
- POSTGRESQL_STORE * pqStore;
-} pqStoreeCreator;
+PLUGIN_CREATOR<POSTGRESQL_STORE> pqStoreeCreator;
//-----------------------------------------------------------------------------
STORE * GetStore()
{
-return pqStoreeCreator.GetStore();
+return pqStoreeCreator.GetPlugin();
}
//-----------------------------------------------------------------------------