mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
RCON QOL improvements
This commit is contained in:
parent
fdb6663c91
commit
23f37bfa50
@ -247,6 +247,9 @@ void CRConServer::Authenticate(const cl_rcon::request& cl_request, CConnectedNet
|
||||
pData->m_bAuthorized = true;
|
||||
m_pSocket->CloseListenSocket();
|
||||
this->CloseNonAuthConnection();
|
||||
|
||||
std::string svAuth = this->Serialize(s_pszAuthMessage, "", sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH);
|
||||
::send(pData->m_hSocket, svAuth.c_str(), static_cast<int>(svAuth.size()), MSG_NOSIGNAL);
|
||||
}
|
||||
else // Bad password.
|
||||
{
|
||||
@ -430,6 +433,13 @@ bool CRConServer::CheckForBan(CConnectedNetConsoleData* pData)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CRConServer::CloseConnection(void) // NETMGR
|
||||
{
|
||||
CConnectedNetConsoleData* pData = m_pSocket->GetAcceptedSocketData(m_nConnIndex);
|
||||
if (pData->m_bAuthorized)
|
||||
{
|
||||
// Inform server owner when authenticated connection has been closed.
|
||||
CNetAdr2 netAdr2 = m_pSocket->GetAcceptedSocketAddress(m_nConnIndex);
|
||||
DevMsg(eDLL_T::SERVER, "Net console '%s' closed RCON connection\n", netAdr2.GetIPAndPort().c_str());
|
||||
}
|
||||
m_pSocket->CloseAcceptedSocket(m_nConnIndex);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
constexpr char s_pszNoAuthMessage[] = "This server is password protected for console access. Must send 'PASS <password>' command.\n\r";
|
||||
constexpr char s_pszWrongPwMessage[] = "Password incorrect.\n\r";
|
||||
constexpr char s_pszBannedMessage[] = "Go away.\n\r";
|
||||
constexpr char s_pszAuthMessage[] = "RCON authentication succesfull.\n\r";
|
||||
|
||||
class CRConServer
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ bool CNetCon::Init(void)
|
||||
|
||||
if (nError != 0)
|
||||
{
|
||||
std::cerr << "Failed to start Winsock via WSAStartup: (" << NET_ErrorString(WSAGetLastError()) << ")." << std::endl;
|
||||
std::cerr << "Failed to start Winsock via WSAStartup: (" << NET_ErrorString(WSAGetLastError()) << ")" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ bool CNetCon::Shutdown(void)
|
||||
int nError = ::WSACleanup();
|
||||
if (nError != 0)
|
||||
{
|
||||
std::cerr << "Failed to stop winsock via WSACleanup: (" << NET_ErrorString(WSAGetLastError()) << ")." << std::endl;
|
||||
std::cerr << "Failed to stop winsock via WSACleanup: (" << NET_ErrorString(WSAGetLastError()) << ")" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -241,7 +241,7 @@ void CNetCon::Send(const std::string& svMessage) const
|
||||
int nSendResult = ::send(m_pSocket->GetAcceptedSocketData(0)->m_hSocket, svMessage.c_str(), svMessage.size(), MSG_NOSIGNAL);
|
||||
if (nSendResult == SOCKET_ERROR)
|
||||
{
|
||||
std::cout << "Failed to send message: (SOCKET_ERROR)." << std::endl;
|
||||
std::cout << "Failed to send message: (SOCKET_ERROR)" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,7 +261,7 @@ void CNetCon::Recv(void)
|
||||
if (nPendingLen <= 0 && m_abConnEstablished) // EOF or error.
|
||||
{
|
||||
this->Disconnect();
|
||||
std::cout << "Server closed connection." << std::endl;
|
||||
std::cout << "Server closed connection" << std::endl;
|
||||
return;
|
||||
}
|
||||
}//////////////////////////////////////////////
|
||||
@ -277,7 +277,7 @@ void CNetCon::Recv(void)
|
||||
if (nRecvLen == 0 && m_abConnEstablished) // Socket was closed.
|
||||
{
|
||||
this->Disconnect();
|
||||
std::cout << "Server closed connection." << std::endl;
|
||||
std::cout << "Server closed connection" << std::endl;
|
||||
break;
|
||||
}
|
||||
if (nRecvLen < 0 && !m_pSocket->IsSocketBlocking())
|
||||
|
@ -115,7 +115,8 @@ void ConCommand::Init(void)
|
||||
// CLIENT DLL |
|
||||
ConCommand* cl_showconsole = new ConCommand("cl_showconsole", "Opens the game console.", FCVAR_CLIENTDLL | FCVAR_RELEASE, _CGameConsole_f_CompletionFunc, nullptr);
|
||||
ConCommand* cl_showbrowser = new ConCommand("cl_showbrowser", "Opens the server browser.", FCVAR_CLIENTDLL | FCVAR_RELEASE, _CCompanion_f_CompletionFunc, nullptr);
|
||||
ConCommand* rcon = new ConCommand("rcon", "Forward RCON query to remote server. | Usage: rcon \"<query>\".", FCVAR_CLIENTDLL | FCVAR_RELEASE, _RCON_CmdQuery_f_CompletionFunc, nullptr);
|
||||
ConCommand* rcon = new ConCommand("rcon", "Forward RCON query to remote server. | Usage: rcon \"<query>\".", FCVAR_CLIENTDLL | FCVAR_RELEASE, _RCON_CmdQuery_f_CompletionFunc, nullptr);
|
||||
ConCommand* rcon_disconnect = new ConCommand("rcon_disconnect", "Disconnect from RCON server.", FCVAR_CLIENTDLL | FCVAR_RELEASE, _RCON_Disconnect_f_CompletionFunc, nullptr);
|
||||
#endif // !DEDICATED
|
||||
//-------------------------------------------------------------------------
|
||||
// FILESYSTEM API |
|
||||
|
@ -789,4 +789,20 @@ void _RCON_CmdQuery_f_CompletionFunc(CCommand* cmd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
_RCON_CmdQuery_f_CompletionFunc
|
||||
|
||||
Disconnect from RCON server
|
||||
=====================
|
||||
*/
|
||||
void _RCON_Disconnect_f_CompletionFunc(CCommand* cmd)
|
||||
{
|
||||
if (g_pRConClient->IsConnected())
|
||||
{
|
||||
g_pRConClient->Disconnect();
|
||||
DevMsg(eDLL_T::CLIENT, "User closed RCON connection\n");
|
||||
}
|
||||
}
|
||||
#endif // !DEDICATED
|
||||
|
@ -35,6 +35,7 @@ void _NET_SetKey_f_CompletionFunc(CCommand* cmd);
|
||||
void _NET_GenerateKey_f_CompletionFunc(CCommand* cmd);
|
||||
#ifndef DEDICATED
|
||||
void _RCON_CmdQuery_f_CompletionFunc(CCommand* cmd);
|
||||
void _RCON_Disconnect_f_CompletionFunc(CCommand* cmd);
|
||||
#endif // !DEDICATED
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user