Compare commits
5
Commits
b38ad590a9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
315fbebc03 | ||
|
|
3127665ecb | ||
|
|
dad2b61a50 | ||
|
|
ae5479b583 | ||
|
|
baf547c71d |
@@ -4,6 +4,12 @@ project(dnf-utils)
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
|
||||
set(TENCENT_NETBAR_SDK ${CMAKE_CURRENT_SOURCE_DIR}/tencent_netbar)
|
||||
|
||||
set(ACE_CLIENT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ace_sdk/client)
|
||||
set(ACE_SERVER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ace_sdk/server)
|
||||
|
||||
add_subdirectory(bsdiff)
|
||||
add_subdirectory(bzip2)
|
||||
add_subdirectory(libnpk)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
set(WTL_DIR $ENV{LIBRARIES_SDK_ROOT}/wtl)
|
||||
|
||||
set(CYCLONE_DIR $ENV{CYCLONE_SDK_ROOT})
|
||||
set(cyclone_DIR $ENV{CYCLONE_SDK_ROOT}/lib/cmake/cyclone)
|
||||
find_package(cyclone REQUIRED)
|
||||
|
||||
set(RapidJSON_DIR $ENV{LIBRARIES_SDK_ROOT}/rapidjson/cmake)
|
||||
find_package(RapidJSON REQUIRED)
|
||||
@@ -14,8 +15,6 @@ set(CURL_DIR $ENV{LIBRARIES_SDK_ROOT}/libcurl/lib/cmake/CURL)
|
||||
find_package(CURL CONFIG REQUIRED)
|
||||
|
||||
set(GAME_PROTO_DIR ${CMAKE_CURRENT_SOURCE_DIR}/aCommon/proto)
|
||||
set(ACE_CLIENT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/aCommon/ace_sdk/client)
|
||||
set(ACE_SERVER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/aCommon/ace_sdk/server)
|
||||
|
||||
set(Protobuf_DIR $ENV{LIBRARIES_SDK_ROOT}/protobuf/cmake)
|
||||
find_package(Protobuf CONFIG REQUIRED)
|
||||
|
||||
@@ -21,6 +21,9 @@ bool AceClientInterface::init()
|
||||
if(ret!= ACE_SDK_RESULT_OK)
|
||||
{
|
||||
printf(">>ACE fail to init ace sdk client, ret : %d\n", ret);
|
||||
char szTemp[256];
|
||||
snprintf(szTemp, sizeof(szTemp), "Failed to init ACE SDK client! Error code: %x", ret);
|
||||
MessageBoxA(NULL, szTemp, "Error", MB_OK | MB_ICONERROR);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -52,19 +52,14 @@ target_include_directories(aClient
|
||||
PRIVATE
|
||||
${ACE_CLIENT_DIR}/include
|
||||
${WTL_DIR}/include
|
||||
${CYCLONE_DIR}/include
|
||||
${GAME_PROTO_DIR}
|
||||
)
|
||||
|
||||
target_link_directories(aClient
|
||||
PRIVATE
|
||||
${CYCLONE_DIR}/lib
|
||||
${TENCENT_NETBAR_SDK}/include
|
||||
)
|
||||
|
||||
target_link_libraries(aClient
|
||||
PRIVATE
|
||||
aGameProto
|
||||
cyclone.lib
|
||||
cyclone::cyclone
|
||||
ws2_32.lib
|
||||
shlwapi.lib
|
||||
winmm.lib
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include "stdafx.h"
|
||||
#include "NetbarInterface.h"
|
||||
#include "iigw_api_client.h"
|
||||
#include "GameProto.h"
|
||||
#include "GameProto.pb.h"
|
||||
#include "GameClient.h"
|
||||
|
||||
#include <iigw_api_client.h>
|
||||
|
||||
TencentNetbarInterface::TencentNetbarInterface()
|
||||
{
|
||||
m_requestStatus.store(RS_NotRequest);
|
||||
|
||||
@@ -14,12 +14,10 @@ protobuf_generate(
|
||||
target_include_directories(aGameProto
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
|
||||
PRIVATE
|
||||
${CYCLONE_DIR}/include
|
||||
)
|
||||
|
||||
target_link_libraries(aGameProto
|
||||
PUBLIC
|
||||
protobuf::libprotobuf
|
||||
cyclone::cyclone
|
||||
)
|
||||
|
||||
@@ -1,8 +1,201 @@
|
||||
#include "stdafx.h"
|
||||
#include "AceReportInterface.h"
|
||||
#include "GameServer.h"
|
||||
#include "GameProto.pb.h"
|
||||
#include "CurlHelper.h"
|
||||
#include "AceInterface.h"
|
||||
|
||||
std::string buildReportRequestUrl(const std::string& baseUrl, const std::string& user,
|
||||
const std::string& token, uint32_t timeStamp, const std::string& body)
|
||||
#include "rapidjson/document.h"
|
||||
#include "rapidjson/stringbuffer.h"
|
||||
#include "rapidjson/writer.h"
|
||||
#include "rapidjson/prettywriter.h"
|
||||
|
||||
#include "libEncrypt_MD5.h"
|
||||
|
||||
const char* kReportProto = "http";
|
||||
const char* kReportHost = "service-exp.light.oa.com";
|
||||
const char* kReportUrl = "report/report_log_data";
|
||||
const char* kReportUser = "719_report";
|
||||
const char* kReportToken = "HaPjIyPBgVJSLsnZJGQjpAHKGLycsQSS";
|
||||
|
||||
std::string buildReportRequestJson(GameClient* client, Game::GameReportReq* request, uint32_t timeStamp)
|
||||
{
|
||||
return "";
|
||||
rapidjson::Document root;
|
||||
root.SetObject();
|
||||
rapidjson::Document::AllocatorType& allocator = root.GetAllocator();
|
||||
|
||||
rapidjson::Value emptyString("");
|
||||
|
||||
|
||||
//informant_account_type
|
||||
rapidjson::Value accountType(1);//ACE_SDK_ACCOUNT_TYPE_QQ=1
|
||||
root.AddMember("informant_account_type", accountType, allocator);
|
||||
|
||||
//informant_account_id
|
||||
rapidjson::Value openIDValue(client->gameAccoundID.c_str(), static_cast<rapidjson::SizeType>(client->gameAccoundID.length()), allocator);
|
||||
root.AddMember("informant_account_id", openIDValue, allocator);
|
||||
|
||||
//informant_app_id
|
||||
rapidjson::Value appID(AceInterface::kGameID);
|
||||
root.AddMember("informant_app_id", appID, allocator);
|
||||
|
||||
//informant_plat_id
|
||||
rapidjson::Value platID(2);
|
||||
root.AddMember("informant_plat_id", platID, allocator);
|
||||
|
||||
//informant_world_id
|
||||
rapidjson::Value worldID(client->gameWorldID);
|
||||
root.AddMember("informant_world_id", worldID, allocator);
|
||||
|
||||
//informant_name
|
||||
rapidjson::Value informantAccountID(client->gameAccoundID.c_str(), static_cast<rapidjson::SizeType>(client->gameAccoundID.length()), allocator);
|
||||
root.AddMember("informant_account_id", informantAccountID, allocator);
|
||||
|
||||
//informant_name
|
||||
rapidjson::Value informantName(client->gameAccoundID.c_str(), static_cast<rapidjson::SizeType>(client->gameAccoundID.length()), allocator);
|
||||
root.AddMember("informant_name", informantName, allocator);
|
||||
|
||||
//informant_roleid
|
||||
rapidjson::Value informantRoleID(client->gameAccoundID.c_str(), static_cast<rapidjson::SizeType>(client->gameAccoundID.length()), allocator);
|
||||
root.AddMember("informant_roleid", informantRoleID, allocator);
|
||||
|
||||
//informant_area
|
||||
rapidjson::Value areaID(3);
|
||||
root.AddMember("informant_area", areaID, allocator);
|
||||
|
||||
//reported_account_type
|
||||
rapidjson::Value reportedAccountType(1);//ACE_SDK_ACCOUNT_TYPE_QQ=1
|
||||
root.AddMember("reported_account_type", reportedAccountType, allocator);
|
||||
|
||||
//reported_account_id
|
||||
rapidjson::Value reportedIDValue(request->reported_account_id().c_str(), static_cast<rapidjson::SizeType>(request->reported_account_id().length()), allocator);
|
||||
root.AddMember("reported_account_id", reportedIDValue, allocator);
|
||||
|
||||
//reported_app_id
|
||||
rapidjson::Value reportedAppID(AceInterface::kGameID);
|
||||
root.AddMember("reported_app_id", reportedAppID, allocator);
|
||||
|
||||
//reported_plat_id
|
||||
rapidjson::Value reportedPlatID(2);
|
||||
root.AddMember("reported_plat_id", reportedPlatID, allocator);
|
||||
|
||||
//reported_world_id
|
||||
rapidjson::Value reportedWorldIDValue(request->reported_world_id());
|
||||
root.AddMember("reported_world_id", reportedWorldIDValue, allocator);
|
||||
|
||||
//reported_name
|
||||
rapidjson::Value reportedName(request->reported_name().c_str(), static_cast<rapidjson::SizeType>(request->reported_name().length()), allocator);
|
||||
root.AddMember("reported_name", reportedName, allocator);
|
||||
|
||||
//reported_roleid
|
||||
rapidjson::Value reportedRoldID(request->reported_roleid().c_str(), static_cast<rapidjson::SizeType>(request->reported_roleid().length()), allocator);
|
||||
root.AddMember("reported_roleid", reportedRoldID, allocator);
|
||||
|
||||
//reported_area
|
||||
rapidjson::Value reportedAreaID(3);
|
||||
root.AddMember("reported_area", reportedAreaID, allocator);
|
||||
|
||||
//report_time
|
||||
rapidjson::Value reportTime(timeStamp);
|
||||
root.AddMember("report_time", reportTime, allocator);
|
||||
|
||||
//business_data
|
||||
rapidjson::Value business_data(rapidjson::kObjectType);
|
||||
|
||||
//business_data:report_category
|
||||
rapidjson::Value reportCategory(request->report_category());
|
||||
business_data.AddMember("report_category", reportCategory, allocator);
|
||||
|
||||
//business_data:report_reason
|
||||
rapidjson::Value reportReasonArray(rapidjson::kArrayType);
|
||||
for (const auto& reason : request->report_reason())
|
||||
{
|
||||
reportReasonArray.PushBack(reason, allocator);
|
||||
}
|
||||
business_data.AddMember("report_reason", reportReasonArray, allocator);
|
||||
|
||||
//business_data::report_scene
|
||||
rapidjson::Value reportScene(request->report_scene());
|
||||
business_data.AddMember("report_scene", reportScene, allocator);
|
||||
|
||||
//business_data::reported_profile_url
|
||||
rapidjson::Value reportedProfileUrl(request->reported_profile_url().c_str(), static_cast<rapidjson::SizeType>(request->reported_profile_url().length()), allocator);
|
||||
business_data.AddMember("reported_profile_url", reportedProfileUrl, allocator);
|
||||
|
||||
//business_data::report_battle_id
|
||||
rapidjson::Value reportBattleID(request->report_battle_id().c_str(), static_cast<rapidjson::SizeType>(request->report_battle_id().length()), allocator);
|
||||
business_data.AddMember("report_battle_id", reportBattleID, allocator);
|
||||
|
||||
//business_data::report_battle_time
|
||||
rapidjson::Value reportBattleTime(request->report_battle_time());
|
||||
business_data.AddMember("report_battle_time", reportBattleTime, allocator);
|
||||
|
||||
//business_data::report_desc
|
||||
rapidjson::Value reportDesc(request->report_desc().c_str(), static_cast<rapidjson::SizeType>(request->report_desc().length()), allocator);
|
||||
business_data.AddMember("report_desc", reportDesc, allocator);
|
||||
|
||||
//business_data::report_content
|
||||
rapidjson::Value reportContent(request->report_content().c_str(), static_cast<rapidjson::SizeType>(request->report_content().length()), allocator);
|
||||
business_data.AddMember("report_content", reportContent, allocator);
|
||||
|
||||
root.AddMember("business_data", business_data, allocator);
|
||||
|
||||
rapidjson::StringBuffer sb;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
|
||||
root.Accept(writer);
|
||||
std::string outputJson = sb.GetString();
|
||||
|
||||
return outputJson;
|
||||
}
|
||||
|
||||
std::string buildReportRequestUrl(const std::string& requestBody, uint32_t timeStamp)
|
||||
{
|
||||
uint32_t randomSerial = rand();
|
||||
|
||||
MD5Context md5Context;
|
||||
md5Init(&md5Context);
|
||||
md5Update(&md5Context, (uint8_t*)requestBody.c_str(), (uint32_t)requestBody.size());
|
||||
std::string requestBodyMD5 = md5ToString(md5Finalize(&md5Context));
|
||||
|
||||
char szStringC[1024] = { 0 };
|
||||
snprintf(szStringC, 1024, "serial=%u×tamp=%u&user=%s&body_md5=%s&token=%s",
|
||||
randomSerial, timeStamp, kReportUser, requestBodyMD5.c_str(), kReportToken);
|
||||
md5Init(&md5Context);
|
||||
md5Update(&md5Context, (uint8_t*)szStringC, (uint32_t)strlen(szStringC));
|
||||
std::string signString = md5ToString(md5Finalize(&md5Context));
|
||||
|
||||
char szRequestURL[1024] = { 0 };
|
||||
snprintf(szRequestURL, 1024, "%s://%s/%s?serial=%u×tamp=%u&user=%s&sign=%s",
|
||||
kReportProto, kReportHost, kReportUrl,
|
||||
randomSerial, timeStamp, kReportUser, signString.c_str());
|
||||
|
||||
return szRequestURL;
|
||||
}
|
||||
|
||||
bool AceReportInterface::onReceiveReportRequest(GameClient* client, Game::GameReportReq* request)
|
||||
{
|
||||
uint32_t timeStamp = (uint32_t)(time(0) & 0xFFFFFFFF);
|
||||
|
||||
std::string requestBody = buildReportRequestJson(client, request, timeStamp);
|
||||
std::string requestUrl = buildReportRequestUrl(requestBody, timeStamp);
|
||||
|
||||
std::string result;
|
||||
int32_t retCode = curlRequest(requestUrl, requestBody, result, true);
|
||||
|
||||
int32_t errorCode = 0;
|
||||
std::string errorInfo;
|
||||
|
||||
if (retCode != 0)
|
||||
{
|
||||
CY_LOG(cyclone::L_ERROR, "NetbarInterface::onReceiveNetbarStatusRequest curlRequest failed, retCode=%d", retCode);
|
||||
|
||||
char szTemp[256] = { 0 };
|
||||
snprintf(szTemp, 256, "Curl request failed, retCode=%d", retCode);
|
||||
errorInfo = szTemp;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,4 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
struct GameClient;
|
||||
namespace Game
|
||||
{
|
||||
class GameReportReq;
|
||||
}
|
||||
|
||||
std::string buildReportRequestUrl();
|
||||
class AceReportInterface
|
||||
{
|
||||
public:
|
||||
static bool onReceiveReportRequest(GameClient* client, Game::GameReportReq* request);
|
||||
};
|
||||
|
||||
@@ -41,22 +41,18 @@ add_executable(aServer
|
||||
|
||||
target_include_directories(aServer
|
||||
PRIVATE
|
||||
${CYCLONE_DIR}/include
|
||||
${ACE_SERVER_DIR}/include
|
||||
${RAPIDJSON_INCLUDE_DIRS}
|
||||
${GAME_PROTO_DIR}
|
||||
)
|
||||
|
||||
target_link_directories(aServer
|
||||
PRIVATE
|
||||
${CYCLONE_DIR}/lib
|
||||
../../libTinyEncrypt
|
||||
)
|
||||
|
||||
target_link_libraries(aServer
|
||||
PRIVATE
|
||||
aGameProto
|
||||
cyclone.lib
|
||||
cyclone::cyclone
|
||||
ws2_32.lib
|
||||
shlwapi.lib
|
||||
CURL::libcurl_static
|
||||
libTinyEncrypt
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "GameServer.h"
|
||||
#include "AceInterface.h"
|
||||
#include "NetbarInterface.h"
|
||||
#include "AceReportInterface.h"
|
||||
#include "GameProto.pb.h"
|
||||
|
||||
GameServer* GameServer::getSingleton()
|
||||
@@ -286,6 +287,7 @@ void GameServer::onReportRequest(cyclone::TcpConnectionPtr conn, Game::GameRepor
|
||||
GameClient* client = getClient(conn->get_id());
|
||||
assert(client);
|
||||
|
||||
AceReportInterface::onReceiveReportRequest(client, request);
|
||||
}
|
||||
|
||||
void GameServer::onNetbarRequest(cyclone::TcpConnectionPtr conn, Game::NetbaraStatusReq* request)
|
||||
@@ -295,5 +297,5 @@ void GameServer::onNetbarRequest(cyclone::TcpConnectionPtr conn, Game::NetbaraSt
|
||||
GameClient* client = getClient(conn->get_id());
|
||||
assert(client);
|
||||
|
||||
NetbarInterface::onReceiveNetbarReportRequest(client, request);
|
||||
NetbarInterface::onReceiveNetbarStatusRequest(client, request);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ std::string buildRequestUrl()
|
||||
return "http://api-test.netbar.itrpc.woa.com/netbar.cafe.rewards.rewards/Rewards";
|
||||
}
|
||||
|
||||
bool NetbarInterface::onReceiveNetbarReportRequest(GameClient* client, Game::NetbaraStatusReq* request)
|
||||
bool NetbarInterface::onReceiveNetbarStatusRequest(GameClient* client, Game::NetbaraStatusReq* request)
|
||||
{
|
||||
std::string requestBody = buildRequestJson(client, request);
|
||||
std::string requestUrl = buildRequestUrl();
|
||||
@@ -79,7 +79,7 @@ bool NetbarInterface::onReceiveNetbarReportRequest(GameClient* client, Game::Net
|
||||
|
||||
if(retCode != 0)
|
||||
{
|
||||
CY_LOG(cyclone::L_ERROR, "NetbarInterface::onReceiveNetbarReportRequest curlRequest failed, retCode=%d", retCode);
|
||||
CY_LOG(cyclone::L_ERROR, "NetbarInterface::onReceiveNetbarStatusRequest curlRequest failed, retCode=%d", retCode);
|
||||
|
||||
char szTemp[256] = { 0 };
|
||||
snprintf(szTemp, 256, "Curl request failed, retCode=%d", retCode);
|
||||
|
||||
@@ -9,5 +9,5 @@ namespace Game
|
||||
class NetbarInterface
|
||||
{
|
||||
public:
|
||||
static bool onReceiveNetbarReportRequest(GameClient* client, Game::NetbaraStatusReq* request);
|
||||
static bool onReceiveNetbarStatusRequest(GameClient* client, Game::NetbaraStatusReq* request);
|
||||
};
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
srand(time(0));
|
||||
|
||||
//init ace interface
|
||||
if (!AceInterface::initAceInterface())
|
||||
{
|
||||
|
||||
@@ -199,7 +199,7 @@ std::string md5ToString(const MD5Digest& digest)
|
||||
{
|
||||
char buf[33] = { 0 };
|
||||
for (size_t i = 0; i < 16; ++i) {
|
||||
sprintf_s(buf + i * 2, 3, "%02x", digest[i]);
|
||||
sprintf_s(buf + i * 2, 3, "%02X", digest[i]);
|
||||
}
|
||||
return std::string(buf);
|
||||
}
|
||||
@@ -211,7 +211,7 @@ bool string2MD5(const char* md5_string, MD5Digest& md5)
|
||||
}
|
||||
for (size_t i = 0; i < 16; ++i) {
|
||||
unsigned int byte;
|
||||
if (sscanf_s(md5_string + i * 2, "%02x", &byte) != 1) {
|
||||
if (sscanf_s(md5_string + i * 2, "%02X", &byte) != 1) {
|
||||
return false; // Failed to parse byte
|
||||
}
|
||||
md5[i] = static_cast<uint8_t>(byte);
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# 腾讯网吧特权组件
|
||||
|
||||
前端对接:https://iwiki.woa.com/p/4008054268
|
||||
后端对接(腾讯内网): https://iwiki.woa.com/p/1440190556
|
||||
后端对接: https://iwiki.woa.com/p/4008196267
|
||||
|
||||
# 示例代码
|
||||
```cpp
|
||||
#include <Windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "iigw_api_client.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
HMODULE hModule = ::LoadLibraryW(L"iigw_client_api.dll");
|
||||
if (hModule) {
|
||||
char* open_id = "979591";// "4724195171999796436";
|
||||
unsigned int game_id = 1;// 16300;
|
||||
iepm_qqwb::IQQNetbarIIGWPlugin *plugin =
|
||||
iepm_qqwb::CreateQQNetbarIIGWPlugin(hModule);
|
||||
if (plugin) {
|
||||
unsigned int zone_id = 0;
|
||||
char* tick_buff = nullptr;// "27A50B44430AAD6BFFBE09BA875E48BB";
|
||||
int tick_buflen = 0;// sizeof(tick_buff);
|
||||
iepm_qqwb::NetbarLv netbarlv = {0};
|
||||
|
||||
int ret = plugin->ReqNetbarLv2(
|
||||
20, // game_id=1(DNF的game_id)
|
||||
101, // zone_id=0(目前不重要的参数,暂时设置为0)
|
||||
"979591", // open_id (DNF目前还是使用的QQ号登录,这里传入用户的QQ号)
|
||||
iepm_qqwb::at_qq, // type (open_id的类型,这里使用qq号类型)
|
||||
nullptr, // ticketBuff, 传入空
|
||||
0, // ticketLen, 传入0
|
||||
&netbarlv, // netbarlv, 输出参数
|
||||
3000
|
||||
);
|
||||
|
||||
|
||||
if (ret == 0 && netbarlv.tokenLen > 0) {
|
||||
// do something
|
||||
printf("ret=%d, tokenLen=%d\n", ret, netbarlv.tokenLen);
|
||||
printf("ip=%s\n", netbarlv.ip);
|
||||
printf("token=%s\n", netbarlv.tokenBuff);
|
||||
printf("macSize=%d, macs='%s'\n", netbarlv.macSize, netbarlv.macs);
|
||||
}
|
||||
|
||||
ret = plugin->IsNetbarMachine(1, "979591", iepm_qqwb::at_qq);
|
||||
if(ret==IIGW_MSG_STATUS_NOT_IN_NETBAR)
|
||||
printf("IsNetbarMachine ret='IIGW_MSG_STATUS_NOT_IN_NETBAR'\n");
|
||||
else if (ret == IIGW_MSG_STATUS_NETBAR_PC)
|
||||
printf("IsNetbarMachine ret='IIGW_MSG_STATUS_NETBAR_PC'\n");
|
||||
else
|
||||
printf("IsNetbarMachine ret=%d\n", ret);
|
||||
}
|
||||
|
||||
::FreeLibrary(hModule);
|
||||
} else {
|
||||
DWORD err = ::GetLastError();
|
||||
printf("LoadLibraryW fail, err=%d\n", err);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
```
|
||||
Binary file not shown.
Reference in New Issue
Block a user