diff --git a/FileDownloader.cpp b/FileDownloader.cpp new file mode 100644 index 0000000..fa1bdd0 --- /dev/null +++ b/FileDownloader.cpp @@ -0,0 +1,51 @@ +#include "FileDownloader.h" +#include "Connector.h" +#include "FileUpdater.h" +#include "istream" + +int getCL(std::string *buffer) { + + std::size_t pos1 = buffer->find("Content-Length:"); + if(pos1 == std::string::npos) { + stt->doEmitionFoundData("Cannot find Content-Length."); + return -1; + } + int pos2 = buffer->find("\r\n", pos1); + if(pos2 == std::string::npos) { + stt->doEmitionFoundData("Weird reply."); + return -1; + } + + std::string res = buffer->substr(pos1 + 15, pos2 - pos1 - 15); + return stoi(res); +} + +void checkWeb(const char *fileName, long *ptr, void *func(void)) { + std::string buffer; + Connector::nConnect(std::string("localhost/nesca/" + std::string(fileName)).c_str(), 8080, &buffer); + + std::cout<doEmitionFoundData("File " + QString(fileName) + " downloaded."); + } +} + +void loadNegatives(){ +} + +void FileDownloader::checkWebFiles() { + //checkWeb("negatives.txt", &FileUpdater::oldNegLstSize, (void*(*)(void))loadNegatives); + //checkWeb("login.txt", (void*(*)(void))loadLogins); + //checkWeb("pass.txt", (void*(*)(void))loadPass); + //checkWeb("sshpass.txt", (void*(*)(void))loadSSHPass); + //checkWeb("wflogin.txt", (void*(*)(void))loadWFLogins); + //checkWeb("wfpass.txt", (void*(*)(void))loadWFPass); +} + diff --git a/FileDownloader.h b/FileDownloader.h new file mode 100644 index 0000000..6bb6a7d --- /dev/null +++ b/FileDownloader.h @@ -0,0 +1,9 @@ +#ifndef FILEDOWNLOADER_H +#define FILEDOWNLOADER_H + +class FileDownloader { +public: + static void checkWebFiles(); +}; + +#endif // FILEDOWNLOADER_H diff --git a/nesca.pro b/nesca.pro index ec62f8d..f28d132 100644 --- a/nesca.pro +++ b/nesca.pro @@ -42,7 +42,8 @@ SOURCES +=\ FTPAuth.cpp \ Threader.cpp \ SSHAuth.cpp \ - FileUpdater.cpp + FileUpdater.cpp \ + FileDownloader.cpp HEADERS += ActivityDrawerTh_HorNet.h \ @@ -71,7 +72,8 @@ HEADERS += ActivityDrawerTh_HorNet.h \ FTPAuth.h \ Threader.h \ SSHAuth.h \ - FileUpdater.h + FileUpdater.h \ + FileDownloader.h FORMS += nesca_3.ui diff --git a/nesca.pro.user b/nesca.pro.user index 71414b8..9d0b304 100644 --- a/nesca.pro.user +++ b/nesca.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/nesca_startModule.cpp b/nesca_startModule.cpp index 0beeb5f..d9c0a95 100644 --- a/nesca_startModule.cpp +++ b/nesca_startModule.cpp @@ -5,6 +5,7 @@ #include "Connector.h" #include "Threader.h" #include "FileUpdater.h" +#include "FileDownloader.h" #include QJsonArray *jsonArr = new QJsonArray(); @@ -1764,6 +1765,8 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder) { void runAuxiliaryThreads() { std::thread lpThread(FileUpdater::updateLists); lpThread.detach(); + std::thread fuThread(FileDownloader::checkWebFiles); + fuThread.detach(); std::thread saverThread(_saver); saverThread.detach(); std::thread trackerThread(_tracker);