Commit 12ec6bcb by 刘帅

加入白名单验证

parent cb967bce
...@@ -35,9 +35,10 @@ namespace FmMd5{ ...@@ -35,9 +35,10 @@ namespace FmMd5{
in.seekg(0, ios_base::end); in.seekg(0, ios_base::end);
int nFileLen = in.tellg(); int nFileLen = in.tellg();
in.seekg(0,ios_base::beg);
double iCount=ceil((double)nFileLen/1024); double iCount=ceil((double)nFileLen/1024);
iCount=iCount-minusCount; iCount=iCount-minusCount;
if (iCount <= minusCount) if (iCount <=0)
{ {
return ""; return "";
} }
...@@ -57,7 +58,8 @@ namespace FmMd5{ ...@@ -57,7 +58,8 @@ namespace FmMd5{
if (i == iCount) if (i == iCount)
{ {
md5.update(buffer, length); //md5.update(buffer, length);
break;
} }
} }
......
...@@ -42,11 +42,17 @@ int main(int argc, char *argv[]) ...@@ -42,11 +42,17 @@ int main(int argc, char *argv[])
qDebug() << "verify failed! this application can not run."; qDebug() << "verify failed! this application can not run.";
return 0; return 0;
} }
QFmClient client;
if(!client.verifyWhitelists())
{
OutputDebugStringA("verify whitelists failed");
return 0;
}
InitLogger(); InitLogger();
QLOG_INFO()<<"start FmclientUi..."; QLOG_INFO()<<"start FmclientUi...";
Widget w; Widget w;
scanner s; scanner s;
QFmClient client; //QFmClient client;
QObject::connect(&client,&QFmClient::HideUi, &w, &Widget::hide,Qt::QueuedConnection); QObject::connect(&client,&QFmClient::HideUi, &w, &Widget::hide,Qt::QueuedConnection);
QObject::connect(&client,&QFmClient::ShowUi, &w, &Widget::showRequesting,Qt::QueuedConnection); QObject::connect(&client,&QFmClient::ShowUi, &w, &Widget::showRequesting,Qt::QueuedConnection);
QObject::connect(&client, &QFmClient::ShowRefundUi, &s, &scanner::showRefund); QObject::connect(&client, &QFmClient::ShowRefundUi, &s, &scanner::showRefund);
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#include <QTimer> #include <QTimer>
#include "QsLog/QsLog.h" #include "QsLog/QsLog.h"
#include "utility.h" #include "utility.h"
#include "base/md5.h"
#include "base/FmPee.h"
#include "scanner.h" #include "scanner.h"
#ifdef WIN32 #ifdef WIN32
...@@ -998,6 +999,52 @@ void QFmClient::SetTransactionId(QString fmId) ...@@ -998,6 +999,52 @@ void QFmClient::SetTransactionId(QString fmId)
emit ContinueRefund(); emit ContinueRefund();
} }
bool QFmClient::verifyWhitelists()
{
if(!Init("115.159.63.201", 29534, 34952, 30, 5))
{
qDebug() << "Init failed!";
return false;
}
QString filePath = QCoreApplication::applicationFilePath();
std::string sign = FmMd5::FileDigest(filePath.toStdString().c_str(),2).c_str();
OutputDebugStringA(sign.c_str());
QJsonObject verifyObject;
verifyObject.insert("reqtype", 31);
verifyObject.insert("ver", 1);
verifyObject.insert("sign", QString(sign.c_str()));
strcpy(_sendbuf, QString(QJsonDocument(verifyObject).toJson()).toStdString().c_str());
if (0 != Try2ConnectZhProxy())
{
OutputDebugStringA( "connect to proxy failed");
return false;
}
if(0 != SendData2ZhProxyAndWaitRspData())
{
OutputDebugStringA( "SendData2ZhProxyAndWaitRspData() failed");
return false;
}
OutputDebugStringA(_recvbuf);
QByteArray recvdata(_recvbuf);
QJsonParseError json_error;
QJsonDocument doc = QJsonDocument::fromJson(recvdata, &json_error);
if(json_error.error != QJsonParseError::NoError || !doc.isObject())
{
OutputDebugStringA("error request json data!");
return false;
}
QJsonObject json = doc.object();
if(json.contains("statusCode") && json["statusCode"].toInt() == 100)
{
return true;
}
else
{
return false;
}
}
void QFmClient::run() void QFmClient::run()
{ {
if(!Init("115.159.63.201", 29534, 34952, 30, 5)) if(!Init("115.159.63.201", 29534, 34952, 30, 5))
......
...@@ -68,6 +68,7 @@ public: ...@@ -68,6 +68,7 @@ public:
int sendAESData2Proxy(int sock, char *buf, int length); int sendAESData2Proxy(int sock, char *buf, int length);
int recvAESDataFromProxy(int sock, char *buf, int maxBufferLength); int recvAESDataFromProxy(int sock, char *buf, int maxBufferLength);
void outputHex(char* out, int length); void outputHex(char* out, int length);
bool verifyWhitelists(); //白名单验证
public slots: public slots:
void SetTransactionId(QString fmId); //退款流程1, 从输入获取长码 void SetTransactionId(QString fmId); //退款流程1, 从输入获取长码
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment