mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-18 09:52:44 +01:00
Codechange: make NetworkAuthenticationMethodMask an EnumBitSet
This commit is contained in:
@@ -386,7 +386,7 @@ NetworkAuthenticationServerHandler::ResponseResult X25519AuthenticationHandler::
|
||||
|
||||
/* virtual */ NetworkAuthenticationMethod CombinedAuthenticationClientHandler::GetAuthenticationMethod() const
|
||||
{
|
||||
return this->current_handler != nullptr ? this->current_handler->GetAuthenticationMethod() : NETWORK_AUTH_METHOD_END;
|
||||
return this->current_handler != nullptr ? this->current_handler->GetAuthenticationMethod() : NetworkAuthenticationMethod::End;
|
||||
}
|
||||
|
||||
|
||||
@@ -406,7 +406,7 @@ void CombinedAuthenticationServerHandler::Add(CombinedAuthenticationServerHandle
|
||||
{
|
||||
Debug(net, 9, "Sending {} authentication request", this->GetName());
|
||||
|
||||
p.Send_uint8(this->handlers.back()->GetAuthenticationMethod());
|
||||
p.Send_uint8(to_underlying(this->handlers.back()->GetAuthenticationMethod()));
|
||||
this->handlers.back()->SendRequest(p);
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ void CombinedAuthenticationServerHandler::Add(CombinedAuthenticationServerHandle
|
||||
|
||||
/* virtual */ NetworkAuthenticationMethod CombinedAuthenticationServerHandler::GetAuthenticationMethod() const
|
||||
{
|
||||
return this->CanBeUsed() ? this->handlers.back()->GetAuthenticationMethod() : NETWORK_AUTH_METHOD_END;
|
||||
return this->CanBeUsed() ? this->handlers.back()->GetAuthenticationMethod() : NetworkAuthenticationMethod::End;
|
||||
}
|
||||
|
||||
/* virtual */ bool CombinedAuthenticationServerHandler::CanBeUsed() const
|
||||
@@ -479,15 +479,15 @@ std::unique_ptr<NetworkAuthenticationServerHandler> NetworkAuthenticationServerH
|
||||
{
|
||||
auto secret = X25519SecretKey::CreateRandom();
|
||||
auto handler = std::make_unique<CombinedAuthenticationServerHandler>();
|
||||
if (password_provider != nullptr && HasBit(client_supported_method_mask, NETWORK_AUTH_METHOD_X25519_PAKE)) {
|
||||
if (password_provider != nullptr && client_supported_method_mask.Test(NetworkAuthenticationMethod::X25519_PAKE)) {
|
||||
handler->Add(std::make_unique<X25519PAKEServerHandler>(secret, password_provider));
|
||||
}
|
||||
|
||||
if (authorized_key_handler != nullptr && HasBit(client_supported_method_mask, NETWORK_AUTH_METHOD_X25519_AUTHORIZED_KEY)) {
|
||||
if (authorized_key_handler != nullptr && client_supported_method_mask.Test(NetworkAuthenticationMethod::X25519_AuthorizedKey)) {
|
||||
handler->Add(std::make_unique<X25519AuthorizedKeyServerHandler>(secret, authorized_key_handler));
|
||||
}
|
||||
|
||||
if (!handler->CanBeUsed() && HasBit(client_supported_method_mask, NETWORK_AUTH_METHOD_X25519_KEY_EXCHANGE_ONLY)) {
|
||||
if (!handler->CanBeUsed() && client_supported_method_mask.Test(NetworkAuthenticationMethod::X25519_KeyExchangeOnly)) {
|
||||
/* Fall back to the plain handler when neither password, nor authorized keys are configured. */
|
||||
handler->Add(std::make_unique<X25519KeyExchangeOnlyServerHandler>(secret));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user