Only send password on connection when explicitly asked to (fixes #788)

This commit is contained in:
def 2017-07-15 17:29:20 +02:00
parent 49eb0128f2
commit fba3815ddc
4 changed files with 13 additions and 6 deletions

View file

@ -87,7 +87,7 @@ public:
inline float LocalTime() const { return m_LocalTime; }
// actions
virtual void Connect(const char *pAddress) = 0;
virtual void Connect(const char *pAddress, const char *pPassword = NULL) = 0;
virtual void Disconnect() = 0;
// dummy

View file

@ -299,6 +299,7 @@ CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta)
m_RconAuthed[0] = 0;
m_RconAuthed[1] = 0;
m_RconPassword[0] = '\0';
m_Password[0] = '\0';
// version-checking
m_aVersionStr[0] = '0';
@ -403,7 +404,7 @@ void CClient::SendInfo()
{
CMsgPacker Msg(NETMSG_INFO);
Msg.AddString(GameClient()->NetVersion(), 128);
Msg.AddString(g_Config.m_Password, 128);
Msg.AddString(m_Password, 128);
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH);
}
@ -664,7 +665,7 @@ void CClient::GenerateTimeoutCodes()
}
}
void CClient::Connect(const char *pAddress)
void CClient::Connect(const char *pAddress, const char *pPassword)
{
char aBuf[512];
int Port = 8303;
@ -685,6 +686,11 @@ void CClient::Connect(const char *pAddress)
net_host_lookup("localhost", &m_ServerAddress, m_NetClient[0].NetType());
}
if(!pPassword)
m_Password[0] = 0;
else
str_copy(m_Password, pPassword, sizeof(m_Password));
m_RconAuthed[0] = 0;
if(m_ServerAddress.port == 0)
m_ServerAddress.port = Port;
@ -2791,7 +2797,7 @@ void CClient::Run()
// send client info
CMsgPacker MsgInfo(NETMSG_INFO);
MsgInfo.AddString(GameClient()->NetVersion(), 128);
MsgInfo.AddString(g_Config.m_Password, 128);
MsgInfo.AddString(m_Password, 128);
SendMsgExY(&MsgInfo, MSGFLAG_VITAL|MSGFLAG_FLUSH, true, 1);
// update netclient

View file

@ -108,6 +108,7 @@ class CClient : public IClient, public CDemoPlayer::IListener
int m_RconAuthed[2];
char m_RconPassword[32];
int m_UseTempRconCommands;
char m_Password[32];
// version-checking
char m_aVersionStr[10];
@ -252,7 +253,7 @@ public:
void OnEnterGame();
virtual void EnterGame();
virtual void Connect(const char *pAddress);
virtual void Connect(const char *pAddress, const char *pPassword = NULL);
void DisconnectWithReason(const char *pReason);
virtual void Disconnect();

View file

@ -1277,7 +1277,7 @@ int CMenus::Render()
static int s_ButtonTryAgain = 0;
if(DoButton_Menu(&s_ButtonTryAgain, Localize("Try again"), 0, &TryAgain) || m_EnterPressed)
{
Client()->Connect(g_Config.m_UiServerAddress);
Client()->Connect(g_Config.m_UiServerAddress, g_Config.m_Password);
}
Box.HSplitBottom(60.f, &Box, &Part);