class TRAFFCOUNTER;
class SETTINGS;
class STORE;
-class MODULE_SETTINGS;
+struct MODULE_SETTINGS;
class PLUGIN : private NONCOPYABLE {
public:
class ADMIN;
class TARIFF;
-class TARIFF_DATA;
+struct TARIFF_DATA;
class TARIFFS {
public:
//-----------------------------------------------------------------------------
void AUTH_AO::Unauthorize(USER_PTR u) const
{
-printfd(__FILE__, "AUTH_AO::Unauthorize - login: '%s'\n", u->GetLogin().c_str());
u->Unauthorize(this);
}
//-----------------------------------------------------------------------------
void AUTH_AO::UpdateUserAuthorization(USER_PTR u) const
{
-printfd(__FILE__, "AUTH_AO::UpdateUserAuthorization - login: '%s'\n", u->GetLogin().c_str());
if (u->GetProperty().alwaysOnline)
{
USER_IPS ips = u->GetProperty().ips;
//-----------------------------------------------------------------------------
void AUTH_AO::AddUser(USER_PTR u)
{
-printfd(__FILE__, "AUTH_AO::AddUser - login: '%s'\n", u->GetLogin().c_str());
SetUserNotifiers(u);
usersList.push_back(u);
UpdateUserAuthorization(u);
//-----------------------------------------------------------------------------
void AUTH_AO::DelUser(USER_PTR u)
{
-printfd(__FILE__, "AUTH_AO::DelUser - login: '%s'\n", u->GetLogin().c_str());
Unauthorize(u);
UnSetUserNotifiers(u);
usersList.remove(u);
template <typename varParamType>
void CHG_BEFORE_NOTIFIER<varParamType>::Notify(const varParamType &, const varParamType &)
{
-printfd(__FILE__, "CHG_BEFORE_NOTIFIER::Notify\n");
//EVENT_LOOP_SINGLETON::GetInstance().Enqueue(auth, &AUTH_AO::Unauthorize, user);
auth.Unauthorize(user);
}
template <typename varParamType>
void CHG_AFTER_NOTIFIER<varParamType>::Notify(const varParamType &, const varParamType &)
{
-printfd(__FILE__, "CHG_AFTER_NOTIFIER::Notify\n");
//EVENT_LOOP_SINGLETON::GetInstance().Enqueue(auth, &AUTH_AO::UpdateUserAuthorization, user);
auth.UpdateUserAuthorization(user);
}
//-----------------------------------------------------------------------------
void SETTINGS_IMPL::ErrorCallback(void * data, const char * buf)
{
- printfd(__FILE__, buf);
+ printfd(__FILE__, "SETTINGS_IMPL::ErrorCallback() - %s\n", buf);
SETTINGS_IMPL * settings = static_cast<SETTINGS_IMPL *>(data);
- settings->logger(buf);
+ settings->logger("%s", buf);
}
//-----------------------------------------------------------------------------
int SETTINGS_IMPL::ReadSettings()
if (ReadRules())
{
+ printfd(__FILE__, "TRAFFCOUNTER_IMPL::Start() - Cannot read rules\n");
WriteServLog("TRAFFCOUNTER: Cannot read rules.");
return -1;
}
USER_PTR u;
if (!h)
{
+ printfd(__FILE__, "TRAFFCOUNTER_IMPL::Start() - Cannot get users\n");
WriteServLog("TRAFFCOUNTER: Cannot get users.");
return -1;
}
running = true;
if (pthread_create(&thread, NULL, Run, this))
{
- WriteServLog("TRAFFCOUNTER: Error: Cannot start thread!");
+ printfd(__FILE__, "TRAFFCOUNTER_IMPL::Start() - Cannot start thread\n");
+ WriteServLog("TRAFFCOUNTER: Error: Cannot start thread.");
return -1;
}
return 0;
if (!f)
{
- WriteServLog("File %s cannot be oppened.", rulesFileName.c_str());
+ printfd(__FILE__, "TRAFFCOUNTER_IMPL::ReadRules() - File '%s' cannot be opened.\n", rulesFileName.c_str());
+ WriteServLog("File '%s' cannot be oppened.", rulesFileName.c_str());
return true;
}
r = sscanf(str,"%s %s %s", tp, ta, td);
if (r != 3)
{
- WriteServLog("Error in file %s. There must be 3 parameters. Line %d.", rulesFileName.c_str(), lineNumber);
+ printfd(__FILE__, "TRAFFCOUNTER_IMPL::ReadRules() - Error in file '%s' at line %d. There must be 3 parameters.\n", rulesFileName.c_str(), lineNumber);
+ WriteServLog("Error in file '%s' at line %d. There must be 3 parameters.", rulesFileName.c_str(), lineNumber);
fclose(f);
return true;
}
if (rul.dir == 0xff || rul.proto == 0xff)
{
+ printfd(__FILE__, "TRAFFCOUNTER_IMPL::ReadRules() - Error in file '%s' at line %d.\n", rulesFileName.c_str(), lineNumber);
WriteServLog("Error in file %s. Line %d.",
rulesFileName.c_str(), lineNumber);
fclose(f);
if (ParseAddress(ta, &rul) != 0)
{
+ printfd(__FILE__, "TRAFFCOUNTER_IMPL::ReadRules() - Error in file '%s' at line %d. Error in adress.\n", rulesFileName.c_str(), lineNumber);
WriteServLog("Error in file %s. Error in adress. Line %d.",
rulesFileName.c_str(), lineNumber);
fclose(f);
if (ReadRules(true))
{
+ printfd(__FILE__, "TRAFFCOUNTER_IMPL::Reload() - Failed to reload rules.\n");
WriteServLog("TRAFFCOUNTER: Cannot reload rules. Errors found.");
return -1;
}
FreeRules();
ReadRules();
+printfd(__FILE__, "TRAFFCOUNTER_IMPL::Reload() - Reload rules successfull.\n");
WriteServLog("TRAFFCOUNTER: Reload rules successfull.");
return 0;
}
// port
if (!(rule->proto == tcp || rule->proto == udp || rule->proto == tcp_udp))
{
+ printfd(__FILE__, "TRAFFCOUNTER_IMPL::ParseAddress() - No ports specified for this protocol.\n");
WriteServLog("No ports specified for this protocol.");
return true;
}
if ((ip & rule->mask) != ip)
{
+ printfd(__FILE__, "TRAFFCOUNTER_IMPL::ParseAddress() - Address does'n match mask.\n");
WriteServLog("Address does'n match mask.");
return true;
}
deps: $(SRCS) ../../Makefile.conf
@>deps ;\
for file in $(SRCS); do\
- echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS) -MM -MG $$file` Makefile ../../Makefile.conf" >> deps ;\
+ echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS) -MM $$file` Makefile ../../Makefile.conf" >> deps ;\
echo -e '\t$$(CC) $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS) -c $$<' >> deps ;\
done
char realpathBuf[PATH_MAX];
if(realpath(_fileName, realpathBuf) == NULL){
- error(0, NULL, "realpath(%s) failed: %s", _fileName, strerror(errno));
+ error(0, _fileName, "realpath('%s') failed: %s", _fileName, strerror(errno));
return -1;
}
va_list args;
va_start(args, fmt);
- size_t len = (lineNum!=0?strlen(fileName):0) + strlen(fmt) + 50;
+ char msg[256];
+
+ vsnprintf(msg, 256, fmt, args);
+
+ size_t len = (lineNum!=0?strlen(fileName):0) + strlen(msg) + 50;
char * buf = (char*)mempool->alloc(len);
if(lineNum)
- (void) snprintf(buf, len, "DOTCONF++: file '%s', line %d: %s\n", fileName, lineNum, fmt);
+ (void) snprintf(buf, len, "DOTCONF++: file '%s', line %d: %s\n", fileName, lineNum, msg);
else
- (void) snprintf(buf, len, "DOTCONF++: %s\n", fmt);
+ (void) snprintf(buf, len, "DOTCONF++: file '%s': %s\n", fileName, msg);
if (errorCallback) {
errorCallback(errorCallbackData, buf);