forked from mirrors/0ad
Pass the controllerSecret to the CNet* constructor
It wasn't clear when to call `SetControllerSecret` now it can't be done wrong. Also the mutex has to be locked less often.
This commit is contained in:
@@ -112,9 +112,10 @@ static CStr DebugName(CNetServerSession* session)
|
||||
*/
|
||||
|
||||
CNetServerWorker::CNetServerWorker(const bool continueSavedGame, const bool useLobbyAuth,
|
||||
std::string password) :
|
||||
std::string password, std::string controllerSecret) :
|
||||
m_ContinuesSavedGame{continueSavedGame},
|
||||
m_LobbyAuth{useLobbyAuth},
|
||||
m_ControllerSecret{std::move(controllerSecret)},
|
||||
m_Password{std::move(password)}
|
||||
{
|
||||
}
|
||||
@@ -155,12 +156,6 @@ CNetServerWorker::~CNetServerWorker()
|
||||
}
|
||||
|
||||
|
||||
void CNetServerWorker::SetControllerSecret(const std::string& secret)
|
||||
{
|
||||
m_ControllerSecret = secret;
|
||||
}
|
||||
|
||||
|
||||
bool CNetServerWorker::CheckPassword(const std::string& password, const std::string& salt) const
|
||||
{
|
||||
return HashCryptographically(m_Password, salt) == password;
|
||||
@@ -1689,8 +1684,10 @@ void CNetServerWorker::SendHolePunchingMessage(const CStr& ipStr, u16 port)
|
||||
|
||||
|
||||
|
||||
CNetServer::CNetServer(const bool continueSavedGame, const bool useLobbyAuth, std::string password) :
|
||||
m_Worker{new CNetServerWorker{continueSavedGame, useLobbyAuth, password}},
|
||||
CNetServer::CNetServer(const bool continueSavedGame, const bool useLobbyAuth, std::string password,
|
||||
std::string controllerSecret) :
|
||||
m_Worker{new CNetServerWorker{continueSavedGame, useLobbyAuth, password,
|
||||
std::move(controllerSecret)}},
|
||||
m_LobbyAuth{useLobbyAuth},
|
||||
m_Password{std::move(password)}
|
||||
{
|
||||
@@ -1759,12 +1756,6 @@ bool CNetServer::IsBanned(const std::string& username) const
|
||||
return it != m_FailedAttempts.end() && it->second >= FAILED_PASSWORD_TRIES_BEFORE_BAN;
|
||||
}
|
||||
|
||||
void CNetServer::SetControllerSecret(const std::string& secret)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_Worker->m_WorkerMutex);
|
||||
m_Worker->SetControllerSecret(secret);
|
||||
}
|
||||
|
||||
void CNetServer::StartGame()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_Worker->m_WorkerMutex);
|
||||
|
||||
Reference in New Issue
Block a user