256 limit handling.

This commit is contained in:
cora32 2015-08-09 14:22:02 +03:00
parent d87320e7ff
commit 0179b11188
6 changed files with 34 additions and 7 deletions

View File

@ -3,6 +3,10 @@
#include "FileUpdater.h" #include "FileUpdater.h"
bool HikVis::isInitialized = false; bool HikVis::isInitialized = false;
int HikVis::hikCounter = 0;
int HikVis::hikPart = 0;
int HikVis::rviCounter = 0;
int HikVis::rviPart = 0;
const char headerSAFARI[128] = { const char headerSAFARI[128] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x52, 0x00, 0x00, 0x00, 0x7b, 0x22, 0x4d, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x52, 0x00, 0x00, 0x00, 0x7b, 0x22, 0x4d, 0x4f,
@ -307,7 +311,7 @@ int rvi_login_ptr(const char *sDVRIP, int wDVRPort, const char *login, const cha
char buff[32] = { 0 }; char buff[32] = { 0 };
recvWT(sock, buff, 16, gTimeOut, &bTO); recvWT(sock, buff, 16, gTimeOut, &bTO);
Activity += strlen(buff); Activity += strlen(buff);
stt->doEmitionAddIncData(QString(sDVRIP) + ":" + QString(wDVRPort), QString(buff)); stt->doEmitionAddIncData(QString(sDVRIP) + ":" + QString::number(wDVRPort), QString(buff));
shutdown(sock, SD_BOTH); shutdown(sock, SD_BOTH);
closesocket(sock); closesocket(sock);

View File

@ -10,6 +10,11 @@ public: static bool isInitialized;
private: lopaStr hikLogin(const char * sDVRIP, int wDVRPort); private: lopaStr hikLogin(const char * sDVRIP, int wDVRPort);
lopaStr rviLogin(const char * sDVRIP, int wDVRPort); lopaStr rviLogin(const char * sDVRIP, int wDVRPort);
public:
static int hikCounter;
static int rviCounter;
static int hikPart;
static int rviPart;
public: public:
static bool checkHikk(const char * sDVRIP, int port); static bool checkHikk(const char * sDVRIP, int port);
static bool checkRVI(const char * sDVRIP, int port); static bool checkRVI(const char * sDVRIP, int port);

View File

@ -1180,8 +1180,8 @@ struct Corac {
int index; int index;
std::string ip; std::string ip;
}; };
void MainStarter::startImportScan(){ void MainStarter::startImportScan(){
if (MainStarter::flCounter == 0) if (MainStarter::flCounter == 0)
{ {
stt->doEmitionRedFoundData("Empty IP list."); stt->doEmitionRedFoundData("Empty IP list.");
@ -1417,7 +1417,11 @@ int thread_cleanup(void)
return 1; return 1;
} }
#include "HikvisionLogin.h"
void MainStarter::start(const char* targets, const char* ports) { void MainStarter::start(const char* targets, const char* ports) {
HikVis::hikCounter = 0;
HikVis::rviCounter = 0;
saveBackup = true; saveBackup = true;
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);

View File

@ -2531,7 +2531,11 @@ void parseFlag(int flag, char* ip, int port, int size, const std::string &header
char fileName[256] = { 0 }; char fileName[256] = { 0 };
char date[64] = { 0 }; char date[64] = { 0 };
strcpy(date, Utils::getStartDate().c_str()); strcpy(date, Utils::getStartDate().c_str());
sprintf(fileName, "./result_files-%s/hikkafile_%s.csv", date, date); if (HikVis::hikCounter >= 256) {
HikVis::hikCounter = 0;
HikVis::hikPart++;
}
sprintf(fileName, "./result_files-%s/hikkafile_%s_part_%d.csv", date, date, HikVis::hikPart);
FILE *f = fopen(fileName, "a"); FILE *f = fopen(fileName, "a");
if (f != NULL) { if (f != NULL) {
char string[1024] = { 0 }; char string[1024] = { 0 };
@ -2541,6 +2545,7 @@ void parseFlag(int flag, char* ip, int port, int size, const std::string &header
fclose(f); fclose(f);
} }
else stt->doEmitionRedFoundData("Cannot open csv - \"" + QString(fileName)); else stt->doEmitionRedFoundData("Cannot open csv - \"" + QString(fileName));
HikVis::hikCounter++;
hikkaStop = false; hikkaStop = false;
}; };
return; return;
@ -2560,8 +2565,12 @@ void parseFlag(int flag, char* ip, int port, int size, const std::string &header
char fileName[256] = { 0 }; char fileName[256] = { 0 };
char date[64] = { 0 }; char date[64] = { 0 };
strcpy(date, Utils::getStartDate().c_str()); strcpy(date, Utils::getStartDate().c_str());
sprintf(fileName, "./result_files-%s/rvifile_%s(%s).xml", if (HikVis::rviCounter >= 256) {
date, date, Utils::getStartTime().c_str()); HikVis::rviCounter = 0;
HikVis::rviPart++;
}
sprintf(fileName, "./result_files-%s/rvifile_%s(%s)_part_%d.xml",
date, date, Utils::getStartTime().c_str(), HikVis::rviPart);
char string[1024] = { 0 }; char string[1024] = { 0 };
FILE *fc = fopen(fileName, "r"); FILE *fc = fopen(fileName, "r");
@ -2585,8 +2594,8 @@ void parseFlag(int flag, char* ip, int port, int size, const std::string &header
fclose(f); fclose(f);
} }
else stt->doEmitionRedFoundData("Cannot open xml - \"" + QString::fromLocal8Bit(fileName) + " Err:" + QString::number(GetLastError())); else stt->doEmitionRedFoundData("Cannot open xml - \"" + QString::fromLocal8Bit(fileName) + " Err:" + QString::number(GetLastError()));
} }
HikVis::rviCounter++;
rviStop = false; rviStop = false;
}; };
return; return;

View File

@ -3334,6 +3334,11 @@ nesca_3::nesca_3(bool isWM, QWidget *parent = 0) : QMainWindow(parent)
SetValidators(); SetValidators();
ConnectEvrthng(); ConnectEvrthng();
HikVis::hikCounter = 0;
HikVis::rviCounter = 0;
HikVis::hikPart = 0;
HikVis::rviPart = 0;
QTime time = QTime::currentTime(); QTime time = QTime::currentTime();
qsrand((uint)time.msec()); qsrand((uint)time.msec());

View File

@ -50,7 +50,7 @@ public:
public: public:
static int perc; static int perc;
static int savedTabIndex; static int savedTabIndex;
protected: protected:
bool eventFilter(QObject* obj, QEvent *event); bool eventFilter(QObject* obj, QEvent *event);
void run(); void run();