This commit is contained in:
cora32 2015-12-29 13:58:43 +03:00
parent 38567a9177
commit aeeb2d6e4b
2 changed files with 53 additions and 18 deletions

View File

@ -130,11 +130,12 @@ size_t nWriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
//return realsize;
}
int Connector::nConnect(const char* ip, const int port, std::string *buffer,
int pConnect(const char* ip, const int port, std::string *buffer,
const char *postData,
const std::vector<std::string> *customHeaders,
const std::string *lpString,
bool digestMode){
bool digestMode)
{
buffer->clear();
int res = 0;
CURL *curl = curl_easy_init();
@ -238,7 +239,8 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
if (res == 5) {
stt->doEmitionRedFoundData("The given proxy host could not be resolved.");
return -2;
} else if (res == 8) {
}
else if (res == 8) {
stt->doEmitionFoundData("Strange ftp reply. (" +
QString::number(res) + ") " + QString(ip) +
":" + QString::number(port));
@ -264,12 +266,42 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str()));
return sz;
} else {
}
else {
stt->doEmitionRedFoundData("Curl error.");
return -1;
};
}
void eraser(std::string *buffer, const std::string delim1, const std::string delim2) {
int pos = -1;
while ((pos = buffer->find(delim1)) != -1) {
int ePos = buffer->find(delim2, pos);
if (ePos != -1) {
buffer->erase(pos, ePos - pos - 1 + delim2.length());
}
else {
buffer->erase(pos, buffer->length() - pos - 1);
}
}
}
void cutoutComments(std::string *buffer) {
eraser(buffer, "<!--", "-->");
eraser(buffer, "/*", "*/");
eraser(buffer, "//", "\n");
}
int Connector::nConnect(const char* ip, const int port, std::string *buffer,
const char *postData,
const std::vector<std::string> *customHeaders,
const std::string *lpString,
bool digestMode){
int res = pConnect(ip, port, buffer, postData, customHeaders, lpString, digestMode);
cutoutComments(buffer);
return buffer->size();
}
bool portCheck(const char * sDVRIP, int wDVRPort) {
// sockaddr_in sa;
// sa.sin_family = AF_INET;

View File

@ -3208,7 +3208,7 @@ int handleFramesets(std::string *buffcpy, char* ip, int port, int flag) {
Connector con;
int framePos = pos + 9;
int counter = 0;
while (framePos != -1) {
framePos = buffcpy->find("<frame ", framePos + 1);
if (-1 == framePos) {
@ -3233,6 +3233,9 @@ int handleFramesets(std::string *buffcpy, char* ip, int port, int flag) {
int quotePos2 = frameString.find_first_of("\"'", quotePos1 + 1);
if (quotePos1 != quotePos2) {
if (counter++ > 5) {
return 0;
};
std::string location = frameString.substr(quotePos1 + 1, quotePos2 - quotePos1 - 1);
std::string tIP = std::string(ip) + (location[0] == '/' ? "" : "/") + location;
std::string buff;