mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Common: improve type name consistency
CConnectedNetConsoleData is a struct and thus renamed to ConnectedNetConsoleData_s.
This commit is contained in:
parent
7de9196d7d
commit
f2e332efa0
@ -28,9 +28,8 @@ enum class ServerDataResponseType_e : int
|
|||||||
SERVERDATA_RESPONSE_REMOTEBUG,
|
SERVERDATA_RESPONSE_REMOTEBUG,
|
||||||
};
|
};
|
||||||
|
|
||||||
class CConnectedNetConsoleData
|
struct ConnectedNetConsoleData_s
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
SocketHandle_t m_hSocket;
|
SocketHandle_t m_hSocket;
|
||||||
int m_nPayloadLen; // Num bytes for this message.
|
int m_nPayloadLen; // Num bytes for this message.
|
||||||
int m_nPayloadRead; // Num read bytes from input buffer.
|
int m_nPayloadRead; // Num read bytes from input buffer.
|
||||||
@ -42,7 +41,7 @@ public:
|
|||||||
NetConFrameHeader_s m_FrameHeader; // Current frame header.
|
NetConFrameHeader_s m_FrameHeader; // Current frame header.
|
||||||
vector<byte> m_RecvBuffer;
|
vector<byte> m_RecvBuffer;
|
||||||
|
|
||||||
CConnectedNetConsoleData(SocketHandle_t hSocket = -1)
|
ConnectedNetConsoleData_s(SocketHandle_t hSocket = -1)
|
||||||
{
|
{
|
||||||
m_hSocket = hSocket;
|
m_hSocket = hSocket;
|
||||||
m_nPayloadLen = 0;
|
m_nPayloadLen = 0;
|
||||||
|
@ -73,7 +73,7 @@ void CRConClient::RunFrame(void)
|
|||||||
{
|
{
|
||||||
if (IsInitialized() && IsConnected())
|
if (IsInitialized() && IsConnected())
|
||||||
{
|
{
|
||||||
CConnectedNetConsoleData* pData = GetData();
|
ConnectedNetConsoleData_s* pData = GetData();
|
||||||
Assert(pData != nullptr);
|
Assert(pData != nullptr);
|
||||||
|
|
||||||
if (pData)
|
if (pData)
|
||||||
@ -194,7 +194,7 @@ bool CRConClient::Serialize(vector<char>& vecBuf, const char* szReqBuf, const si
|
|||||||
// Purpose: retrieves the remote socket
|
// Purpose: retrieves the remote socket
|
||||||
// Output : SOCKET_ERROR (-1) on failure
|
// Output : SOCKET_ERROR (-1) on failure
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
CConnectedNetConsoleData* CRConClient::GetData(void)
|
ConnectedNetConsoleData_s* CRConClient::GetData(void)
|
||||||
{
|
{
|
||||||
return NetconShared_GetConnData(this, 0);
|
return NetconShared_GetConnData(this, 0);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public:
|
|||||||
bool IsInitialized(void) const;
|
bool IsInitialized(void) const;
|
||||||
bool IsConnected(void);
|
bool IsConnected(void);
|
||||||
|
|
||||||
CConnectedNetConsoleData* GetData(void);
|
ConnectedNetConsoleData_s* GetData(void);
|
||||||
SocketHandle_t GetSocket(void);
|
SocketHandle_t GetSocket(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -155,7 +155,7 @@ void CRConServer::Think(void)
|
|||||||
const netadr_t& netAdr = m_Socket.GetAcceptedSocketAddress(m_nConnIndex);
|
const netadr_t& netAdr = m_Socket.GetAcceptedSocketAddress(m_nConnIndex);
|
||||||
if (!m_WhiteListAddress.CompareAdr(netAdr))
|
if (!m_WhiteListAddress.CompareAdr(netAdr))
|
||||||
{
|
{
|
||||||
const CConnectedNetConsoleData& data = m_Socket.GetAcceptedSocketData(m_nConnIndex);
|
const ConnectedNetConsoleData_s& data = m_Socket.GetAcceptedSocketData(m_nConnIndex);
|
||||||
if (!data.m_bAuthorized)
|
if (!data.m_bAuthorized)
|
||||||
{
|
{
|
||||||
Disconnect("redundant");
|
Disconnect("redundant");
|
||||||
@ -248,7 +248,7 @@ void CRConServer::RunFrame(void)
|
|||||||
const int nCount = m_Socket.GetAcceptedSocketCount();
|
const int nCount = m_Socket.GetAcceptedSocketCount();
|
||||||
for (m_nConnIndex = nCount - 1; m_nConnIndex >= 0; m_nConnIndex--)
|
for (m_nConnIndex = nCount - 1; m_nConnIndex >= 0; m_nConnIndex--)
|
||||||
{
|
{
|
||||||
CConnectedNetConsoleData& data = m_Socket.GetAcceptedSocketData(m_nConnIndex);
|
ConnectedNetConsoleData_s& data = m_Socket.GetAcceptedSocketData(m_nConnIndex);
|
||||||
|
|
||||||
if (CheckForBan(data))
|
if (CheckForBan(data))
|
||||||
{
|
{
|
||||||
@ -277,7 +277,7 @@ bool CRConServer::SendToAll(const char* pMsgBuf, const int nMsgLen) const
|
|||||||
|
|
||||||
for (int i = nCount - 1; i >= 0; i--)
|
for (int i = nCount - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
const CConnectedNetConsoleData& data = m_Socket.GetAcceptedSocketData(i);
|
const ConnectedNetConsoleData_s& data = m_Socket.GetAcceptedSocketData(i);
|
||||||
|
|
||||||
if (data.m_bAuthorized && !data.m_bInputOnly)
|
if (data.m_bAuthorized && !data.m_bInputOnly)
|
||||||
{
|
{
|
||||||
@ -381,7 +381,7 @@ bool CRConServer::Serialize(vector<char>& vecBuf,
|
|||||||
// Input : &request -
|
// Input : &request -
|
||||||
// &data -
|
// &data -
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CRConServer::Authenticate(const netcon::request& request, CConnectedNetConsoleData& data)
|
void CRConServer::Authenticate(const netcon::request& request, ConnectedNetConsoleData_s& data)
|
||||||
{
|
{
|
||||||
if (data.m_bAuthorized)
|
if (data.m_bAuthorized)
|
||||||
{
|
{
|
||||||
@ -455,7 +455,7 @@ bool CRConServer::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CConnectedNetConsoleData& data = m_Socket.GetAcceptedSocketData(m_nConnIndex);
|
ConnectedNetConsoleData_s& data = m_Socket.GetAcceptedSocketData(m_nConnIndex);
|
||||||
|
|
||||||
if (!data.m_bAuthorized &&
|
if (!data.m_bAuthorized &&
|
||||||
request.requesttype() != netcon::request_e::SERVERDATA_REQUEST_AUTH)
|
request.requesttype() != netcon::request_e::SERVERDATA_REQUEST_AUTH)
|
||||||
@ -522,7 +522,7 @@ void CRConServer::Execute(const netcon::request& request) const
|
|||||||
// Purpose: checks for amount of failed attempts and bans netconsole accordingly
|
// Purpose: checks for amount of failed attempts and bans netconsole accordingly
|
||||||
// Input : &data -
|
// Input : &data -
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CRConServer::CheckForBan(CConnectedNetConsoleData& data)
|
bool CRConServer::CheckForBan(ConnectedNetConsoleData_s& data)
|
||||||
{
|
{
|
||||||
if (data.m_bValidated)
|
if (data.m_bValidated)
|
||||||
{
|
{
|
||||||
@ -597,7 +597,7 @@ void CRConServer::Disconnect(const char* szReason) // NETMGR
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CRConServer::Disconnect(const int nIndex, const char* szReason) // NETMGR
|
void CRConServer::Disconnect(const int nIndex, const char* szReason) // NETMGR
|
||||||
{
|
{
|
||||||
CConnectedNetConsoleData& data = m_Socket.GetAcceptedSocketData(nIndex);
|
ConnectedNetConsoleData_s& data = m_Socket.GetAcceptedSocketData(nIndex);
|
||||||
if (data.m_bAuthorized)
|
if (data.m_bAuthorized)
|
||||||
{
|
{
|
||||||
// Inform server owner when authenticated connection has been closed.
|
// Inform server owner when authenticated connection has been closed.
|
||||||
@ -622,7 +622,7 @@ void CRConServer::CloseNonAuthConnection(void)
|
|||||||
int nCount = m_Socket.GetAcceptedSocketCount();
|
int nCount = m_Socket.GetAcceptedSocketCount();
|
||||||
for (int i = nCount - 1; i >= 0; i--)
|
for (int i = nCount - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
CConnectedNetConsoleData& data = m_Socket.GetAcceptedSocketData(i);
|
ConnectedNetConsoleData_s& data = m_Socket.GetAcceptedSocketData(i);
|
||||||
|
|
||||||
if (!data.m_bAuthorized)
|
if (!data.m_bAuthorized)
|
||||||
{
|
{
|
||||||
|
@ -39,13 +39,13 @@ public:
|
|||||||
bool Serialize(vector<char>& vecBuf, const char* pResponseMsg, const size_t nResponseMsgLen, const char* pResponseVal, const size_t nResponseValLen,
|
bool Serialize(vector<char>& vecBuf, const char* pResponseMsg, const size_t nResponseMsgLen, const char* pResponseVal, const size_t nResponseValLen,
|
||||||
const netcon::response_e responseType, const int nMessageId = static_cast<int>(eDLL_T::NETCON), const int nMessageType = static_cast<int>(LogType_t::LOG_NET)) const;
|
const netcon::response_e responseType, const int nMessageId = static_cast<int>(eDLL_T::NETCON), const int nMessageType = static_cast<int>(LogType_t::LOG_NET)) const;
|
||||||
|
|
||||||
void Authenticate(const netcon::request& request, CConnectedNetConsoleData& data);
|
void Authenticate(const netcon::request& request, ConnectedNetConsoleData_s& data);
|
||||||
bool Comparator(const string& svPassword) const;
|
bool Comparator(const string& svPassword) const;
|
||||||
|
|
||||||
virtual bool ProcessMessage(const char* pMsgBuf, const int nMsgLen) override;
|
virtual bool ProcessMessage(const char* pMsgBuf, const int nMsgLen) override;
|
||||||
|
|
||||||
void Execute(const netcon::request& request) const;
|
void Execute(const netcon::request& request) const;
|
||||||
bool CheckForBan(CConnectedNetConsoleData& data);
|
bool CheckForBan(ConnectedNetConsoleData_s& data);
|
||||||
|
|
||||||
virtual void Disconnect(const char* szReason = nullptr) override;
|
virtual void Disconnect(const char* szReason = nullptr) override;
|
||||||
void Disconnect(const int nIndex, const char* szReason = nullptr);
|
void Disconnect(const int nIndex, const char* szReason = nullptr);
|
||||||
|
@ -144,7 +144,7 @@ bool CNetConBase::Connect(const char* pHostName, const int nPort)
|
|||||||
// nMaxLen -
|
// nMaxLen -
|
||||||
// Output: true on success, false otherwise
|
// Output: true on success, false otherwise
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CNetConBase::ProcessBuffer(CConnectedNetConsoleData& data, const char* pRecvBuf, int nRecvLen, const int nMaxLen)
|
bool CNetConBase::ProcessBuffer(ConnectedNetConsoleData_s& data, const char* pRecvBuf, int nRecvLen, const int nMaxLen)
|
||||||
{
|
{
|
||||||
while (nRecvLen > 0)
|
while (nRecvLen > 0)
|
||||||
{
|
{
|
||||||
@ -307,7 +307,7 @@ bool CNetConBase::Send(const SocketHandle_t hSocket, const char* pMsgBuf,
|
|||||||
// nMaxLen -
|
// nMaxLen -
|
||||||
// Output: true on success, false otherwise
|
// Output: true on success, false otherwise
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CNetConBase::Recv(CConnectedNetConsoleData& data, const int nMaxLen)
|
void CNetConBase::Recv(ConnectedNetConsoleData_s& data, const int nMaxLen)
|
||||||
{
|
{
|
||||||
static char szRecvBuf[1024];
|
static char szRecvBuf[1024];
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
virtual bool Connect(const char* pHostName, const int nHostPort = SOCKET_ERROR);
|
virtual bool Connect(const char* pHostName, const int nHostPort = SOCKET_ERROR);
|
||||||
virtual void Disconnect(const char* szReason = nullptr) { NOTE_UNUSED(szReason); };
|
virtual void Disconnect(const char* szReason = nullptr) { NOTE_UNUSED(szReason); };
|
||||||
|
|
||||||
virtual bool ProcessBuffer(CConnectedNetConsoleData& data, const char* pRecvBuf, int nRecvLen, const int nMaxLen = SOCKET_ERROR);
|
virtual bool ProcessBuffer(ConnectedNetConsoleData_s& data, const char* pRecvBuf, int nRecvLen, const int nMaxLen = SOCKET_ERROR);
|
||||||
virtual bool ProcessMessage(const char* /*pMsgBuf*/, int /*nMsgLen*/) { return true; };
|
virtual bool ProcessMessage(const char* /*pMsgBuf*/, int /*nMsgLen*/) { return true; };
|
||||||
|
|
||||||
virtual bool Encrypt(CryptoContext_s& ctx, const char* pInBuf, char* pOutBuf, const size_t nDataLen) const;
|
virtual bool Encrypt(CryptoContext_s& ctx, const char* pInBuf, char* pOutBuf, const size_t nDataLen) const;
|
||||||
@ -31,7 +31,7 @@ public:
|
|||||||
virtual bool Decode(google::protobuf::MessageLite* pMsg, const char* pMsgBuf, const size_t nMsgLen) const;
|
virtual bool Decode(google::protobuf::MessageLite* pMsg, const char* pMsgBuf, const size_t nMsgLen) const;
|
||||||
|
|
||||||
virtual bool Send(const SocketHandle_t hSocket, const char* pMsgBuf, const int nMsgLen) const;
|
virtual bool Send(const SocketHandle_t hSocket, const char* pMsgBuf, const int nMsgLen) const;
|
||||||
virtual void Recv(CConnectedNetConsoleData& data, const int nMaxLen = SOCKET_ERROR);
|
virtual void Recv(ConnectedNetConsoleData_s& data, const int nMaxLen = SOCKET_ERROR);
|
||||||
|
|
||||||
CSocketCreator* GetSocketCreator(void) { return &m_Socket; }
|
CSocketCreator* GetSocketCreator(void) { return &m_Socket; }
|
||||||
netadr_t* GetNetAddress(void) { return &m_Address; }
|
netadr_t* GetNetAddress(void) { return &m_Address; }
|
||||||
|
@ -291,7 +291,7 @@ bool NetconShared_UnpackEnvelope(const CNetConBase* pBase, const char* pMsgBuf,
|
|||||||
// iSocket -
|
// iSocket -
|
||||||
// Output : nullptr on failure
|
// Output : nullptr on failure
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
CConnectedNetConsoleData* NetconShared_GetConnData(CNetConBase* pBase, const int iSocket)
|
ConnectedNetConsoleData_s* NetconShared_GetConnData(CNetConBase* pBase, const int iSocket)
|
||||||
{
|
{
|
||||||
CSocketCreator* pCreator = pBase->GetSocketCreator();
|
CSocketCreator* pCreator = pBase->GetSocketCreator();
|
||||||
Assert(iSocket >= 0 && (pCreator->GetAcceptedSocketCount() == 0
|
Assert(iSocket >= 0 && (pCreator->GetAcceptedSocketCount() == 0
|
||||||
@ -313,7 +313,7 @@ CConnectedNetConsoleData* NetconShared_GetConnData(CNetConBase* pBase, const int
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
SocketHandle_t NetconShared_GetSocketHandle(CNetConBase* pBase, const int iSocket)
|
SocketHandle_t NetconShared_GetSocketHandle(CNetConBase* pBase, const int iSocket)
|
||||||
{
|
{
|
||||||
const CConnectedNetConsoleData* pData = NetconShared_GetConnData(pBase, iSocket);
|
const ConnectedNetConsoleData_s* pData = NetconShared_GetConnData(pBase, iSocket);
|
||||||
if (!pData)
|
if (!pData)
|
||||||
{
|
{
|
||||||
return SOCKET_ERROR;
|
return SOCKET_ERROR;
|
||||||
|
@ -27,7 +27,7 @@ bool NetconClient_Connect(CNetConBase* pBase, const char* pHostAdr, const int nH
|
|||||||
bool NetconShared_PackEnvelope(const CNetConBase* pBase, vector<char>& outMsgBuf, const size_t nMsgLen, google::protobuf::MessageLite* inMsg, const bool bEncrypt, const bool bDebug);
|
bool NetconShared_PackEnvelope(const CNetConBase* pBase, vector<char>& outMsgBuf, const size_t nMsgLen, google::protobuf::MessageLite* inMsg, const bool bEncrypt, const bool bDebug);
|
||||||
bool NetconShared_UnpackEnvelope(const CNetConBase* pBase, const char* pMsgBuf, const size_t nMsgLen, google::protobuf::MessageLite* outMsg, const bool bDebug);
|
bool NetconShared_UnpackEnvelope(const CNetConBase* pBase, const char* pMsgBuf, const size_t nMsgLen, google::protobuf::MessageLite* outMsg, const bool bDebug);
|
||||||
|
|
||||||
CConnectedNetConsoleData* NetconShared_GetConnData(CNetConBase* pBase, const int iSocket);
|
ConnectedNetConsoleData_s* NetconShared_GetConnData(CNetConBase* pBase, const int iSocket);
|
||||||
SocketHandle_t NetconShared_GetSocketHandle(CNetConBase* pBase, const int iSocket);
|
SocketHandle_t NetconShared_GetSocketHandle(CNetConBase* pBase, const int iSocket);
|
||||||
|
|
||||||
#endif // SHARED_RCON_H
|
#endif // SHARED_RCON_H
|
||||||
|
@ -324,7 +324,7 @@ bool CNetCon::RunFrame(void)
|
|||||||
|
|
||||||
if (IsConnected())
|
if (IsConnected())
|
||||||
{
|
{
|
||||||
CConnectedNetConsoleData& pData = GetSocketCreator()->GetAcceptedSocketData(0);
|
ConnectedNetConsoleData_s& pData = GetSocketCreator()->GetAcceptedSocketData(0);
|
||||||
Recv(pData);
|
Recv(pData);
|
||||||
}
|
}
|
||||||
else if (GetPrompting())
|
else if (GetPrompting())
|
||||||
|
@ -35,8 +35,8 @@ public:
|
|||||||
|
|
||||||
SocketHandle_t GetAcceptedSocketHandle(int nIndex) const;
|
SocketHandle_t GetAcceptedSocketHandle(int nIndex) const;
|
||||||
const netadr_t& GetAcceptedSocketAddress(int nIndex) const;
|
const netadr_t& GetAcceptedSocketAddress(int nIndex) const;
|
||||||
CConnectedNetConsoleData& GetAcceptedSocketData(int nIndex);
|
ConnectedNetConsoleData_s& GetAcceptedSocketData(int nIndex);
|
||||||
const CConnectedNetConsoleData& GetAcceptedSocketData(int nIndex) const;
|
const ConnectedNetConsoleData_s& GetAcceptedSocketData(int nIndex) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct AcceptedSocket_t
|
struct AcceptedSocket_t
|
||||||
@ -48,7 +48,7 @@ public:
|
|||||||
|
|
||||||
SocketHandle_t m_hSocket;
|
SocketHandle_t m_hSocket;
|
||||||
netadr_t m_Address;
|
netadr_t m_Address;
|
||||||
CConnectedNetConsoleData m_Data;
|
ConnectedNetConsoleData_s m_Data;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -379,7 +379,7 @@ const netadr_t& CSocketCreator::GetAcceptedSocketAddress(int nIndex) const
|
|||||||
// Input : nIndex -
|
// Input : nIndex -
|
||||||
// Output : CConnectedNetConsoleData*
|
// Output : CConnectedNetConsoleData*
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
CConnectedNetConsoleData& CSocketCreator::GetAcceptedSocketData(int nIndex)
|
ConnectedNetConsoleData_s& CSocketCreator::GetAcceptedSocketData(int nIndex)
|
||||||
{
|
{
|
||||||
Assert(nIndex >= 0 && nIndex < m_AcceptedSockets.Count());
|
Assert(nIndex >= 0 && nIndex < m_AcceptedSockets.Count());
|
||||||
return m_AcceptedSockets[nIndex].m_Data;
|
return m_AcceptedSockets[nIndex].m_Data;
|
||||||
@ -390,7 +390,7 @@ CConnectedNetConsoleData& CSocketCreator::GetAcceptedSocketData(int nIndex)
|
|||||||
// Input : nIndex -
|
// Input : nIndex -
|
||||||
// Output : CConnectedNetConsoleData*
|
// Output : CConnectedNetConsoleData*
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
const CConnectedNetConsoleData& CSocketCreator::GetAcceptedSocketData(int nIndex) const
|
const ConnectedNetConsoleData_s& CSocketCreator::GetAcceptedSocketData(int nIndex) const
|
||||||
{
|
{
|
||||||
Assert(nIndex >= 0 && nIndex < m_AcceptedSockets.Count());
|
Assert(nIndex >= 0 && nIndex < m_AcceptedSockets.Count());
|
||||||
return m_AcceptedSockets[nIndex].m_Data;
|
return m_AcceptedSockets[nIndex].m_Data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user