Enforce signed licenses and seamless track handoff
Independent component release / publish (push) Failing after 11s
Independent component release / publish (push) Failing after 11s
This commit is contained in:
15 files changed
+1367
-98
No files matched your search
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
|
||||
#include "echoion/core/NetworkClient.hpp"
|
||||
#include "echoion/core/licensing/LicenseVerifier.hpp"
|
||||
|
||||
#include <ConfigTypes.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
namespace Echoion::Core::Licensing
|
||||
{
|
||||
class LicenseManager
|
||||
{
|
||||
public:
|
||||
|
||||
LicenseManager(Api::LicensingConfig config,
|
||||
std::shared_ptr<NetworkClient>
|
||||
network,
|
||||
std::filesystem::path stateDirectory);
|
||||
~LicenseManager();
|
||||
|
||||
LicenseManager(const LicenseManager&) = delete;
|
||||
LicenseManager& operator=(const LicenseManager&) = delete;
|
||||
|
||||
/// Load a still-valid cached lease and then attempt an online
|
||||
/// refresh. A failed refresh retains a valid cache; otherwise
|
||||
/// operation remains update-only.
|
||||
void initialize();
|
||||
void shutdown();
|
||||
void refreshNow();
|
||||
|
||||
[[nodiscard]] bool canOperate() const noexcept;
|
||||
[[nodiscard]] LeaseStatus status() const;
|
||||
[[nodiscard]] std::string deviceId() const;
|
||||
|
||||
private:
|
||||
|
||||
[[nodiscard]] Void::Result::Result<LeaseStatus>
|
||||
verifyBundle(std::string_view bundle,
|
||||
std::string_view expectedChallenge);
|
||||
[[nodiscard]] std::string loadOrCreateDeviceId();
|
||||
void installStatus(LeaseStatus status);
|
||||
void installFailure(std::string reason,
|
||||
bool retainValidLease = true);
|
||||
void run(std::stop_token stopToken);
|
||||
|
||||
Api::LicensingConfig config_;
|
||||
std::shared_ptr<NetworkClient> network_;
|
||||
std::filesystem::path stateDirectory_;
|
||||
Void::Update::Keyring rootKeys_;
|
||||
std::string deviceId_;
|
||||
std::atomic<bool> operational_{false};
|
||||
std::atomic<std::int64_t> operationalUntilUnix_{0};
|
||||
mutable std::mutex mutex_;
|
||||
LeaseStatus status_;
|
||||
std::jthread refreshThread_;
|
||||
std::uint64_t minimumSequence_{0};
|
||||
};
|
||||
} // namespace Echoion::Core::Licensing
|
||||
Reference in new issue
Block a user