CCF/include/ccf/actors.h

58 строки
981 B
C++
Исходник Обычный вид История

2019-04-26 18:27:27 +03:00
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the Apache 2.0 License.
#pragma once
#include <cstdint>
#include <string>
2019-04-26 18:27:27 +03:00
namespace ccf
{
enum class ActorsType : uint64_t
{
members = 0,
users,
nodes,
acme_challenge,
// not to be used
unknown
};
inline bool is_valid_actor(const std::string& actor)
{
if (
actor != "gov" && actor != "app" && actor != "node" &&
actor != ".well-known/acme-challenge")
{
return false;
}
return true;
}
2020-06-23 13:42:13 +03:00
constexpr auto get_actor_prefix(ActorsType at)
{
switch (at)
{
case ActorsType::members:
{
return "gov";
}
case ActorsType::users:
{
return "app";
}
case ActorsType::nodes:
{
return "node";
}
case ActorsType::acme_challenge:
2022-06-21 21:03:29 +03:00
{
return ".well-known/acme-challenge";
2022-06-21 21:03:29 +03:00
}
2020-06-23 13:42:13 +03:00
default:
{
return "";
}
}
}
2019-04-26 18:27:27 +03:00
}