2023-07-10 08:36:19 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
#include "ProtocolBase.h"
|
|
|
|
|
|
|
|
|
|
class ReqClientCfgParams {
|
|
|
|
|
public:
|
|
|
|
|
std::string identifier;
|
|
|
|
|
|
|
|
|
|
AIGC_JSON_HELPER(identifier)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ReqHeartParams {
|
|
|
|
|
public:
|
|
|
|
|
std::string message;
|
|
|
|
|
|
|
|
|
|
AIGC_JSON_HELPER(message)
|
2023-07-14 09:29:02 +00:00
|
|
|
|
AIGC_JSON_HELPER_DEFAULT(message = TEXT("PING"))
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class RspHeartParams : public ResponseStatus {
|
|
|
|
|
public:
|
|
|
|
|
std::string message;
|
|
|
|
|
|
|
|
|
|
AIGC_JSON_HELPER(message)
|
|
|
|
|
AIGC_JSON_HELPER_BASE((ResponseStatus *)this)
|
|
|
|
|
AIGC_JSON_HELPER_DEFAULT(message = TEXT("PONG"))
|
2023-07-10 08:36:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ReqGetUserCfgParams {
|
|
|
|
|
public:
|
|
|
|
|
std::string user;
|
|
|
|
|
std::string token;
|
|
|
|
|
|
|
|
|
|
AIGC_JSON_HELPER(user, token)
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-14 09:29:02 +00:00
|
|
|
|
class RspUserSevrCfgParams {
|
|
|
|
|
public:
|
|
|
|
|
int svrListenPort;
|
|
|
|
|
std::string svrPrivateKey;
|
|
|
|
|
std::string svrAddress;
|
|
|
|
|
|
|
|
|
|
AIGC_JSON_HELPER(svrListenPort, svrPrivateKey, svrAddress)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ReqStartTunnelParams {
|
|
|
|
|
public:
|
|
|
|
|
bool isStart;
|
|
|
|
|
AIGC_JSON_HELPER(isStart)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ReqUserSetCliCfgParams {
|
|
|
|
|
public:
|
|
|
|
|
std::string cliPublicKey;
|
|
|
|
|
std::string cliNetwork;
|
|
|
|
|
std::string cliTunnelAddr;
|
|
|
|
|
|
|
|
|
|
AIGC_JSON_HELPER(cliPublicKey, cliNetwork, cliTunnelAddr)
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-10 08:36:19 +00:00
|
|
|
|
class VitrualMathineCfg {
|
|
|
|
|
public:
|
|
|
|
|
int vmId;
|
|
|
|
|
std::string vmName;
|
|
|
|
|
std::string svrPublicKey;
|
|
|
|
|
std::string vmNetwork;
|
|
|
|
|
std::string scgGateway;
|
|
|
|
|
|
|
|
|
|
AIGC_JSON_HELPER(vmId, vmName, svrPublicKey, vmNetwork, scgGateway)
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-14 09:29:02 +00:00
|
|
|
|
class RspUsrCliConfigParams {
|
2023-07-10 08:36:19 +00:00
|
|
|
|
public:
|
|
|
|
|
int scgCtrlAppId;
|
|
|
|
|
int scgTunnelAppId;
|
|
|
|
|
std::string cliPrivateKey;
|
2023-07-14 09:29:02 +00:00
|
|
|
|
std::string cliPublicKey;
|
2023-07-10 08:36:19 +00:00
|
|
|
|
std::string cliAddress;
|
|
|
|
|
std::list<VitrualMathineCfg> vmConfig;
|
|
|
|
|
|
2023-07-14 09:29:02 +00:00
|
|
|
|
AIGC_JSON_HELPER(scgCtrlAppId, scgTunnelAppId, cliPrivateKey, cliPublicKey, cliAddress, vmConfig)
|
2023-07-10 08:36:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-07-14 09:29:02 +00:00
|
|
|
|
#define GET_CLIENTCFG_PATH TEXT("/tunnel/getuserconfig")
|
|
|
|
|
#define GET_SERVERCFG_PATH TEXT("/tunnel/getserverconfig")
|
|
|
|
|
|
|
|
|
|
#define SET_CLIENTCFG_PATH TEXT("/tunnel/setconfig")
|
|
|
|
|
#define SET_CLIENTSTART_TUNNEL TEXT("/tunnel/start")
|
|
|
|
|
#define SET_CLIENTHEART_PATH TEXT("/tunnel/heart")
|
|
|
|
|
|
|
|
|
|
int InitControlServer(const TCHAR *pUserSvrUrl);
|
|
|
|
|
|
|
|
|
|
template<class T1, class T2>
|
|
|
|
|
int ProtolPostMessage(const TCHAR *pUrlPath,
|
|
|
|
|
ProtocolRequest<T1> *pReq,
|
|
|
|
|
ProtocolResponse<T2> *pRsp,
|
|
|
|
|
bool platformServer = true);
|
|
|
|
|
|
|
|
|
|
extern template int ProtolPostMessage(const TCHAR *pUrlPath,
|
|
|
|
|
ProtocolRequest<ReqGetUserCfgParams> *pReq,
|
|
|
|
|
ProtocolResponse<RspUserSevrCfgParams> *pRsp,
|
|
|
|
|
bool platformServer);
|
|
|
|
|
|
|
|
|
|
extern template int ProtolPostMessage(const TCHAR *pUrlPath,
|
|
|
|
|
ProtocolRequest<ReqGetUserCfgParams> *pReq,
|
|
|
|
|
ProtocolResponse<RspUsrCliConfigParams> *pRsp,
|
|
|
|
|
bool platformServer);
|
|
|
|
|
|
|
|
|
|
extern template int ProtolPostMessage(const TCHAR *pUrlPath,
|
|
|
|
|
ProtocolRequest<ReqUserSetCliCfgParams> *pReq,
|
|
|
|
|
ProtocolResponse<ResponseStatus> *pRsp,
|
|
|
|
|
bool platformServer);
|
|
|
|
|
|
|
|
|
|
extern template int ProtolPostMessage(const TCHAR *pUrlPath,
|
|
|
|
|
ProtocolRequest<ReqStartTunnelParams> *pReq,
|
|
|
|
|
ProtocolResponse<ResponseStatus> *pRsp,
|
|
|
|
|
bool platformServer);
|
|
|
|
|
|
|
|
|
|
extern template int ProtolPostMessage(const TCHAR *pUrlPath,
|
|
|
|
|
ProtocolRequest<ReqHeartParams> *pReq,
|
|
|
|
|
ProtocolResponse<RspHeartParams> *pRsp,
|
|
|
|
|
bool platformServer);
|