mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Add missing check
This fixes the bug where RCON address couldn't be set from the '[::]:port' format.
This commit is contained in:
parent
e51336dd5a
commit
39445eecc4
@ -14,7 +14,7 @@ public:
|
||||
virtual bool Encode(google::protobuf::MessageLite* pMsg, char* pMsgBuf, size_t nMsgLen) const;
|
||||
virtual bool Decode(google::protobuf::MessageLite* pMsg, const char* pMsgBuf, size_t nMsgLen) const;
|
||||
|
||||
virtual bool Connect(const char* pHostAdr, const int nHostPort = -1);
|
||||
virtual bool Connect(const char* pHostAdr, const int nHostPort = SOCKET_ERROR);
|
||||
virtual void Disconnect(const char* szReason = nullptr) { NOTE_UNUSED(szReason); };
|
||||
|
||||
virtual bool Send(const SocketHandle_t hSocket, const char* pMsgBuf, int nMsgLen) const;
|
||||
|
@ -48,7 +48,9 @@ bool CL_NetConSerialize(const CNetConBase* pBase, vector<char>& vecBuf, const ch
|
||||
bool CL_NetConConnect(CNetConBase* pBase, const char* pHostAdr, const int nHostPort)
|
||||
{
|
||||
string svLocalHost;
|
||||
if (nHostPort != -1 && strcmp(pHostAdr, "localhost") == 0)
|
||||
const bool bValidSocket = nHostPort != SOCKET_ERROR;
|
||||
|
||||
if (bValidSocket && strcmp(pHostAdr, "localhost") == 0)
|
||||
{
|
||||
char szHostName[512];
|
||||
if (!gethostname(szHostName, sizeof(szHostName)))
|
||||
@ -65,7 +67,11 @@ bool CL_NetConConnect(CNetConBase* pBase, const char* pHostAdr, const int nHostP
|
||||
return false;
|
||||
}
|
||||
|
||||
pNetAdr->SetPort(htons(u_short(nHostPort)));
|
||||
// Pass 'SOCKET_ERROR' if you want to set port from address string instead.
|
||||
if (bValidSocket)
|
||||
{
|
||||
pNetAdr->SetPort(htons(u_short(nHostPort)));
|
||||
}
|
||||
|
||||
CSocketCreator* pCreator = pBase->GetSocketCreator();
|
||||
if (pCreator->ConnectSocket(*pNetAdr, true) == SOCKET_ERROR)
|
||||
|
Loading…
x
Reference in New Issue
Block a user