Reuse VoidLibrary rate limiting and export stable C ABI
This commit is contained in:
7 files changed
+188
-107
No files matched your search
@@ -0,0 +1,56 @@
|
|||||||
|
name: Independent component release
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: [v*]
|
||||||
|
schedule:
|
||||||
|
- cron: '17 2 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: echoion-release-serial
|
||||||
|
steps:
|
||||||
|
- name: Check out component
|
||||||
|
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
ssh-key: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Check out pinned public release tools
|
||||||
|
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
||||||
|
with:
|
||||||
|
repository: Void/Echoion
|
||||||
|
ref: ${{ vars.ECHOION_RELEASE_TOOLS_REF }}
|
||||||
|
path: .echoion-release-tools
|
||||||
|
fetch-depth: 0
|
||||||
|
ssh-key: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Build, publish, and merge feed transaction
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.COMPONENT_OBJECT_STORAGE_ACCESS_KEY }}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.COMPONENT_OBJECT_STORAGE_SECRET_KEY }}
|
||||||
|
AWS_DEFAULT_REGION: ${{ vars.COMPONENT_OBJECT_STORAGE_REGION }}
|
||||||
|
ECHOION_COMPONENT_SSH_KEY: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
|
||||||
|
ECHOION_DISTRIBUTION_BASE_URL: ${{ vars.ECHOION_DISTRIBUTION_BASE_URL }}
|
||||||
|
ECHOION_FEED_BASE_URL: ${{ vars.ECHOION_FEED_BASE_URL }}
|
||||||
|
ECHOION_FEED_COMMIT_SIGNING_KEY: ${{ secrets.RELEASE_FEED_GIT_SIGNING_KEY }}
|
||||||
|
ECHOION_FEED_PRIVATE_KEY: ${{ secrets.RELEASE_FEED_ED25519_PRIVATE_KEY }}
|
||||||
|
ECHOION_FEED_REPOSITORY: ssh://gitea@git.faumaray.ru/Void/Echoion.git
|
||||||
|
ECHOION_FEED_SIGNING_KEY_ID: ${{ vars.ECHOION_FEED_SIGNING_KEY_ID }}
|
||||||
|
ECHOION_OBJECT_STORAGE_BUCKET: ${{ vars.COMPONENT_OBJECT_STORAGE_BUCKET }}
|
||||||
|
ECHOION_OBJECT_STORAGE_ENDPOINT: ${{ vars.COMPONENT_OBJECT_STORAGE_ENDPOINT }}
|
||||||
|
ECHOION_OBJECT_STORAGE_PREFIX: ${{ vars.COMPONENT_OBJECT_STORAGE_PREFIX }}
|
||||||
|
ECHOION_RELEASE_TAG_ALLOWED_SIGNERS: ${{ secrets.RELEASE_TAG_ALLOWED_SIGNERS }}
|
||||||
|
GITEA_API_URL: ${{ gitea.api_url }}
|
||||||
|
GITEA_EVENT_NAME: ${{ gitea.event_name }}
|
||||||
|
GITEA_REF_NAME: ${{ gitea.ref_name }}
|
||||||
|
GITEA_RUN_NUMBER: ${{ gitea.run_number }}
|
||||||
|
GITEA_SHA: ${{ gitea.sha }}
|
||||||
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
|
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
|
||||||
|
RELEASE_TOOLS_REF: ${{ vars.ECHOION_RELEASE_TOOLS_REF }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
[[ "$RELEASE_TOOLS_REF" =~ ^[0-9a-f]{40}$ ]]
|
||||||
|
test "$(git -C .echoion-release-tools rev-parse HEAD)" = "$RELEASE_TOOLS_REF"
|
||||||
|
.echoion-release-tools/scripts/release-component.sh component.release.json
|
||||||
+6
-2
@@ -1,8 +1,11 @@
|
|||||||
cmake_minimum_required(VERSION 4.0.0)
|
cmake_minimum_required(VERSION 4.0.0)
|
||||||
if(NOT DEFINED ECHOION_PRODUCT_VERSION)
|
if(NOT DEFINED ECHOION_PRODUCT_VERSION)
|
||||||
set(ECHOION_PRODUCT_VERSION 2.0.0)
|
set(ECHOION_PRODUCT_VERSION 0.0.0)
|
||||||
endif()
|
endif()
|
||||||
project(EchoionWeb VERSION "${ECHOION_PRODUCT_VERSION}" LANGUAGES CXX)
|
if(NOT DEFINED ECHOION_COMPONENT_VERSION)
|
||||||
|
set(ECHOION_COMPONENT_VERSION "${ECHOION_PRODUCT_VERSION}")
|
||||||
|
endif()
|
||||||
|
project(EchoionWeb VERSION "${ECHOION_COMPONENT_VERSION}" LANGUAGES CXX)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
set(CMAKE_CXX_STANDARD 26)
|
set(CMAKE_CXX_STANDARD 26)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
@@ -73,6 +76,7 @@ target_link_libraries(EchoionWeb
|
|||||||
Void::Data
|
Void::Data
|
||||||
Void::Log
|
Void::Log
|
||||||
Void::Async
|
Void::Async
|
||||||
|
Void::Resilience
|
||||||
PRIVATE
|
PRIVATE
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
Boost::beast
|
Boost::beast
|
||||||
|
|||||||
+3
-2
@@ -1,14 +1,15 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"contractId": "echoion.module.web",
|
"contractId": "echoion.module.web",
|
||||||
"descriptor": "Void::Plugin::ModuleDescriptor",
|
"descriptor": "echoion_module_descriptor_v1",
|
||||||
|
"querySymbol": "echoion_module_abi_query",
|
||||||
"moduleId": "EchoionWeb",
|
"moduleId": "EchoionWeb",
|
||||||
"activation": "restart-required",
|
"activation": "restart-required",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
"moduleId": "EchoionApi",
|
"moduleId": "EchoionApi",
|
||||||
"versionRange": "^2.0.0",
|
"versionRange": "^2.0.0",
|
||||||
"abiHash": "sha256:336492a52097dd12f222bb6d9acab19e8eb6a502eab45bb78127bce6d733fbd3"
|
"abiHash": "sha256:d50293d345a97e52f9844088bdd42277f566bc815a21b7636d3e053f06c6c113"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"componentId": "EchoionWeb",
|
||||||
|
"productCompatibility": ">=2.0.0 <3.0.0",
|
||||||
|
"publishNightly": true,
|
||||||
|
"cmakeOptions": {
|
||||||
|
"ECHOION_BUILD_WEB": "ON"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <Void/Resilience/KeyedRateLimiter.hpp>
|
||||||
|
#include <Void/Resilience/RateLimiter.hpp>
|
||||||
#include <boost/asio/ip/address.hpp>
|
#include <boost/asio/ip/address.hpp>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@@ -10,7 +12,6 @@
|
|||||||
#include <span>
|
#include <span>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <unordered_map>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Echoion::Web::Security
|
namespace Echoion::Web::Security
|
||||||
@@ -23,8 +24,8 @@ namespace Echoion::Web::Security
|
|||||||
|
|
||||||
CidrBlock(asio::ip::address network, unsigned int prefixLength);
|
CidrBlock(asio::ip::address network, unsigned int prefixLength);
|
||||||
|
|
||||||
[[nodiscard]] bool contains(
|
[[nodiscard]] bool
|
||||||
const asio::ip::address& address) const noexcept;
|
contains(const asio::ip::address &address) const noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -34,16 +35,17 @@ namespace Echoion::Web::Security
|
|||||||
|
|
||||||
using ParsedCidrs = std::expected<std::vector<CidrBlock>, std::string>;
|
using ParsedCidrs = std::expected<std::vector<CidrBlock>, std::string>;
|
||||||
|
|
||||||
[[nodiscard]] ParsedCidrs parseTrustedProxyCidrs(
|
[[nodiscard]] ParsedCidrs
|
||||||
std::span<const std::string> cidrs);
|
parseTrustedProxyCidrs(std::span<const std::string> cidrs);
|
||||||
|
|
||||||
[[nodiscard]] std::string effectiveClientAddress(
|
[[nodiscard]] std::string
|
||||||
const asio::ip::address& immediatePeer,
|
effectiveClientAddress(const asio::ip::address &immediatePeer,
|
||||||
std::optional<std::string_view> forwardedFor,
|
std::optional<std::string_view> forwardedFor,
|
||||||
std::span<const CidrBlock> trustedProxies);
|
std::span<const CidrBlock> trustedProxies);
|
||||||
|
|
||||||
[[nodiscard]] bool validShortSlug(std::string_view slug) noexcept;
|
[[nodiscard]] bool validShortSlug(std::string_view slug) noexcept;
|
||||||
[[nodiscard]] bool validRedirectLocation(std::string_view location) noexcept;
|
[[nodiscard]] bool
|
||||||
|
validRedirectLocation(std::string_view location) noexcept;
|
||||||
|
|
||||||
class ShortLinkRateLimiter
|
class ShortLinkRateLimiter
|
||||||
{
|
{
|
||||||
@@ -72,25 +74,12 @@ namespace Echoion::Web::Security
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct TokenBucket {
|
|
||||||
double tokens = 0.0;
|
|
||||||
TimePoint updated{};
|
|
||||||
bool initialized = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PeerBucket {
|
|
||||||
TokenBucket bucket;
|
|
||||||
TimePoint lastSeen{};
|
|
||||||
};
|
|
||||||
|
|
||||||
static void refill(TokenBucket& bucket, double rate, double burst,
|
|
||||||
TimePoint now) noexcept;
|
|
||||||
void evictIdle(TimePoint now, bool force);
|
void evictIdle(TimePoint now, bool force);
|
||||||
|
|
||||||
Config config_;
|
Config config_;
|
||||||
mutable std::mutex mutex_;
|
mutable std::mutex mutex_;
|
||||||
TokenBucket global_;
|
Void::Resilience::TokenBucket global_;
|
||||||
std::unordered_map<std::string, PeerBucket> peers_;
|
Void::Resilience::KeyedRateLimiter<std::string> peers_;
|
||||||
TimePoint nextSweep_{};
|
TimePoint nextSweep_{};
|
||||||
bool sweepInitialized_ = false;
|
bool sweepInitialized_ = false;
|
||||||
};
|
};
|
||||||
|
|||||||
+28
-59
@@ -18,7 +18,7 @@ namespace Echoion::Web::Security
|
|||||||
constexpr std::size_t MAX_REDIRECT_LENGTH = 8192;
|
constexpr std::size_t MAX_REDIRECT_LENGTH = 8192;
|
||||||
|
|
||||||
asio::ip::address
|
asio::ip::address
|
||||||
normalizeMappedAddress(const asio::ip::address& address)
|
normalizeMappedAddress(const asio::ip::address &address)
|
||||||
{
|
{
|
||||||
if (address.is_v6() && address.to_v6().is_v4_mapped()) {
|
if (address.is_v6() && address.to_v6().is_v4_mapped()) {
|
||||||
return asio::ip::make_address_v4(asio::ip::v4_mapped,
|
return asio::ip::make_address_v4(asio::ip::v4_mapped,
|
||||||
@@ -27,12 +27,12 @@ namespace Echoion::Web::Security
|
|||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isTrusted(const asio::ip::address& address,
|
bool isTrusted(const asio::ip::address &address,
|
||||||
std::span<const CidrBlock>
|
std::span<const CidrBlock>
|
||||||
trustedProxies) noexcept
|
trustedProxies) noexcept
|
||||||
{
|
{
|
||||||
return std::ranges::any_of(trustedProxies,
|
return std::ranges::any_of(trustedProxies,
|
||||||
[&address](const CidrBlock& network) {
|
[&address](const CidrBlock &network) {
|
||||||
return network.contains(address);
|
return network.contains(address);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ namespace Echoion::Web::Security
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CidrBlock::contains(const asio::ip::address& address) const noexcept
|
bool CidrBlock::contains(const asio::ip::address &address) const noexcept
|
||||||
{
|
{
|
||||||
asio::ip::address candidate = address;
|
asio::ip::address candidate = address;
|
||||||
if (network_.is_v4() && candidate.is_v6()) {
|
if (network_.is_v4() && candidate.is_v6()) {
|
||||||
@@ -73,7 +73,7 @@ namespace Echoion::Web::Security
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto matches = [this](const auto& lhs, const auto& rhs) {
|
const auto matches = [this](const auto &lhs, const auto &rhs) {
|
||||||
for (std::size_t index = 0; index < lhs.size(); ++index) {
|
for (std::size_t index = 0; index < lhs.size(); ++index) {
|
||||||
const auto consumed = static_cast<unsigned int>(index * 8);
|
const auto consumed = static_cast<unsigned int>(index * 8);
|
||||||
const auto remaining =
|
const auto remaining =
|
||||||
@@ -145,7 +145,7 @@ namespace Echoion::Web::Security
|
|||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string effectiveClientAddress(const asio::ip::address& immediatePeer,
|
std::string effectiveClientAddress(const asio::ip::address &immediatePeer,
|
||||||
std::optional<std::string_view>
|
std::optional<std::string_view>
|
||||||
forwardedFor,
|
forwardedFor,
|
||||||
std::span<const CidrBlock>
|
std::span<const CidrBlock>
|
||||||
@@ -213,7 +213,7 @@ namespace Echoion::Web::Security
|
|||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto& url = *parsed;
|
const auto &url = *parsed;
|
||||||
if ((url.scheme_id() != boost::urls::scheme::http &&
|
if ((url.scheme_id() != boost::urls::scheme::http &&
|
||||||
url.scheme_id() != boost::urls::scheme::https) ||
|
url.scheme_id() != boost::urls::scheme::https) ||
|
||||||
!url.has_authority() || url.has_userinfo() ||
|
!url.has_authority() || url.has_userinfo() ||
|
||||||
@@ -240,7 +240,11 @@ namespace Echoion::Web::Security
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ShortLinkRateLimiter::ShortLinkRateLimiter(Config config) : config_(config)
|
ShortLinkRateLimiter::ShortLinkRateLimiter(Config config)
|
||||||
|
: config_(config), global_(config.globalBurst, config.globalRate),
|
||||||
|
peers_(
|
||||||
|
config.peerBurst, config.peerRate, [] { return Clock::now(); },
|
||||||
|
config.maxPeers)
|
||||||
{
|
{
|
||||||
if (!std::isfinite(config_.globalRate) || config_.globalRate < 0.0 ||
|
if (!std::isfinite(config_.globalRate) || config_.globalRate < 0.0 ||
|
||||||
!std::isfinite(config_.globalBurst) || config_.globalBurst < 1.0 ||
|
!std::isfinite(config_.globalBurst) || config_.globalBurst < 1.0 ||
|
||||||
@@ -252,7 +256,6 @@ namespace Echoion::Web::Security
|
|||||||
throw std::invalid_argument(
|
throw std::invalid_argument(
|
||||||
"invalid short-link rate limiter settings");
|
"invalid short-link rate limiter settings");
|
||||||
}
|
}
|
||||||
peers_.reserve(config_.maxPeers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShortLinkRateLimiter::allow(std::string_view peer)
|
bool ShortLinkRateLimiter::allow(std::string_view peer)
|
||||||
@@ -264,44 +267,36 @@ namespace Echoion::Web::Security
|
|||||||
{
|
{
|
||||||
std::lock_guard lock(mutex_);
|
std::lock_guard lock(mutex_);
|
||||||
evictIdle(now, false);
|
evictIdle(now, false);
|
||||||
refill(global_, config_.globalRate, config_.globalBurst, now);
|
if (global_.available_at(now) < 1.0) {
|
||||||
if (global_.tokens < 1.0) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string peerKey{peer};
|
const std::string peerKey{peer};
|
||||||
auto found = peers_.find(peerKey);
|
auto available = peers_.remaining_at(peerKey, now);
|
||||||
if (found == peers_.end()) {
|
if (!available) {
|
||||||
if (peers_.size() >= config_.maxPeers) {
|
evictIdle(now, true);
|
||||||
evictIdle(now, true);
|
available = peers_.remaining_at(peerKey, now);
|
||||||
}
|
|
||||||
if (peers_.size() >= config_.maxPeers) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
found =
|
|
||||||
peers_
|
|
||||||
.emplace(peerKey, PeerBucket{.bucket = {}, .lastSeen = now})
|
|
||||||
.first;
|
|
||||||
}
|
}
|
||||||
|
if (!available || *available < 1.0) {
|
||||||
found->second.lastSeen = now;
|
|
||||||
refill(found->second.bucket, config_.peerRate, config_.peerBurst, now);
|
|
||||||
if (found->second.bucket.tokens < 1.0) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit both token deductions together. A peer-local rejection never
|
// Commit both token deductions together. A peer-local rejection never
|
||||||
// consumes global capacity and cannot starve unrelated clients.
|
// consumes global capacity and cannot starve unrelated clients.
|
||||||
global_.tokens -= 1.0;
|
const bool peerAllowed = peers_.allow_at(peerKey, now);
|
||||||
found->second.bucket.tokens -= 1.0;
|
const bool globalAllowed = global_.try_acquire_at(now);
|
||||||
|
if (!peerAllowed || !globalAllowed) {
|
||||||
|
throw std::logic_error{
|
||||||
|
"rate limiter transaction became inconsistent"};
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortLinkRateLimiter::reset()
|
void ShortLinkRateLimiter::reset()
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mutex_);
|
std::lock_guard lock(mutex_);
|
||||||
global_ = {};
|
global_.reset();
|
||||||
peers_.clear();
|
peers_.reset();
|
||||||
nextSweep_ = {};
|
nextSweep_ = {};
|
||||||
sweepInitialized_ = false;
|
sweepInitialized_ = false;
|
||||||
}
|
}
|
||||||
@@ -309,24 +304,7 @@ namespace Echoion::Web::Security
|
|||||||
std::size_t ShortLinkRateLimiter::trackedPeerCount() const
|
std::size_t ShortLinkRateLimiter::trackedPeerCount() const
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mutex_);
|
std::lock_guard lock(mutex_);
|
||||||
return peers_.size();
|
return peers_.tracked();
|
||||||
}
|
|
||||||
|
|
||||||
void ShortLinkRateLimiter::refill(TokenBucket& bucket, double rate,
|
|
||||||
double burst, TimePoint now) noexcept
|
|
||||||
{
|
|
||||||
if (!bucket.initialized) {
|
|
||||||
bucket.tokens = burst;
|
|
||||||
bucket.updated = now;
|
|
||||||
bucket.initialized = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto elapsed =
|
|
||||||
now > bucket.updated
|
|
||||||
? std::chrono::duration<double>(now - bucket.updated).count()
|
|
||||||
: 0.0;
|
|
||||||
bucket.tokens = std::min(burst, bucket.tokens + elapsed * rate);
|
|
||||||
bucket.updated = now;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortLinkRateLimiter::evictIdle(TimePoint now, bool force)
|
void ShortLinkRateLimiter::evictIdle(TimePoint now, bool force)
|
||||||
@@ -334,16 +312,7 @@ namespace Echoion::Web::Security
|
|||||||
if (!force && sweepInitialized_ && now < nextSweep_) {
|
if (!force && sweepInitialized_ && now < nextSweep_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (auto peer = peers_.begin(); peer != peers_.end();) {
|
(void)peers_.cleanup_at(now, config_.idleTimeout);
|
||||||
const bool expired =
|
|
||||||
now >= peer->second.lastSeen &&
|
|
||||||
now - peer->second.lastSeen >= config_.idleTimeout;
|
|
||||||
if (expired) {
|
|
||||||
peer = peers_.erase(peer);
|
|
||||||
} else {
|
|
||||||
++peer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nextSweep_ = now + config_.sweepInterval;
|
nextSweep_ = now + config_.sweepInterval;
|
||||||
sweepInitialized_ = true;
|
sweepInitialized_ = true;
|
||||||
}
|
}
|
||||||
|
|||||||
+72
-19
@@ -1,5 +1,6 @@
|
|||||||
#include <echoion/api/module/Module.hpp>
|
#include <echoion/api/module/LegacyModuleAbi.hpp>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
@@ -10,6 +11,7 @@ namespace Echoion::Web
|
|||||||
class WebModule final : public Void::Plugin::IModule
|
class WebModule final : public Void::Plugin::IModule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
[[nodiscard]] std::string_view name() const noexcept override
|
[[nodiscard]] std::string_view name() const noexcept override
|
||||||
{
|
{
|
||||||
return "EchoionWeb";
|
return "EchoionWeb";
|
||||||
@@ -22,41 +24,92 @@ namespace Echoion::Web
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
const Void::Plugin::ModuleDescriptor& webModuleDescriptor()
|
const Void::Plugin::ModuleDescriptor &webModuleDescriptor()
|
||||||
{
|
{
|
||||||
static const Void::Plugin::ModuleDescriptor descriptor{
|
static const Void::Plugin::ModuleDescriptor descriptor{
|
||||||
.module_id = "EchoionWeb",
|
.module_id = "EchoionWeb",
|
||||||
.component_version = {
|
.component_version =
|
||||||
.major = ECHOION_COMPONENT_VERSION_MAJOR,
|
{
|
||||||
.minor = ECHOION_COMPONENT_VERSION_MINOR,
|
.major = ECHOION_COMPONENT_VERSION_MAJOR,
|
||||||
.patch = ECHOION_COMPONENT_VERSION_PATCH,
|
.minor = ECHOION_COMPONENT_VERSION_MINOR,
|
||||||
.pre_release = {},
|
.patch = ECHOION_COMPONENT_VERSION_PATCH,
|
||||||
.build = {},
|
.pre_release = {},
|
||||||
},
|
.build = {},
|
||||||
.abi_hash =
|
},
|
||||||
"sha256:858dfd3a19804e42a63fa8694a70ebe07ee90485a886df1ac07cf91bb5d34316",
|
.abi_hash = "sha256:"
|
||||||
|
"e1f826ddb06caadc394af7a3db27af32789a7e580cde6ee516edd0"
|
||||||
|
"ebda2a5c9f",
|
||||||
.abi_contract = Void::Json::object({
|
.abi_contract = Void::Json::object({
|
||||||
{"schemaVersion", 1},
|
{"schemaVersion", 1},
|
||||||
{"contractId", "echoion.module.web"},
|
{"contractId", "echoion.module.web"},
|
||||||
{"descriptor", "Void::Plugin::ModuleDescriptor"},
|
{"descriptor", "echoion_module_descriptor_v1"},
|
||||||
}),
|
}),
|
||||||
.dependencies = {
|
.dependencies =
|
||||||
{
|
{
|
||||||
.module_id = "EchoionApi",
|
{
|
||||||
.version_range = "^2.0.0",
|
.module_id = "EchoionApi",
|
||||||
.abi_hash = "sha256:336492a52097dd12f222bb6d9acab19e8eb6a502eab45bb78127bce6d733fbd3",
|
.version_range = "^2.0.0",
|
||||||
|
.abi_hash =
|
||||||
|
"sha256:"
|
||||||
|
"d50293d345a97e52f9844088bdd42277f566bc815a21b763"
|
||||||
|
"6d3e053f06c6c113",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
.activation_policy =
|
.activation_policy =
|
||||||
Void::Plugin::ActivationPolicy::RestartRequired,
|
Void::Plugin::ActivationPolicy::RestartRequired,
|
||||||
.create = createWebModule,
|
.create = createWebModule,
|
||||||
};
|
};
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const echoion_module_descriptor_v1 &webModuleAbiDescriptor()
|
||||||
|
{
|
||||||
|
using Bridge = Api::Module::LegacyModuleAbi<createWebModule>;
|
||||||
|
static const echoion_module_dependency_v1 dependencies[]{
|
||||||
|
{
|
||||||
|
.struct_size = sizeof(echoion_module_dependency_v1),
|
||||||
|
.component_id = Api::Module::Detail::stringView("EchoionApi"),
|
||||||
|
.version_range =
|
||||||
|
Api::Module::Detail::stringView(">=2.0.0 <3.0.0"),
|
||||||
|
.abi_hash = Api::Module::Detail::stringView(
|
||||||
|
"sha256:"
|
||||||
|
"d50293d345a97e52f9844088bdd42277f566bc815a21b7636d3e053f06"
|
||||||
|
"c6c11"
|
||||||
|
"3"),
|
||||||
|
.optional = 0,
|
||||||
|
.reserved_bytes = {},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
static const echoion_module_descriptor_v1 descriptor{
|
||||||
|
.struct_size = sizeof(echoion_module_descriptor_v1),
|
||||||
|
.abi_version = ECHOION_MODULE_ABI_VERSION,
|
||||||
|
.component_id = Api::Module::Detail::stringView("EchoionWeb"),
|
||||||
|
.version_major = ECHOION_COMPONENT_VERSION_MAJOR,
|
||||||
|
.version_minor = ECHOION_COMPONENT_VERSION_MINOR,
|
||||||
|
.version_patch = ECHOION_COMPONENT_VERSION_PATCH,
|
||||||
|
.version_prerelease = {},
|
||||||
|
.abi_hash = Api::Module::Detail::stringView(
|
||||||
|
"sha256:"
|
||||||
|
"e1f826ddb06caadc394af7a3db27af32789a7e580cde6ee516edd0ebda2a5c"
|
||||||
|
"9f"),
|
||||||
|
.dependencies = dependencies,
|
||||||
|
.dependency_count = std::size(dependencies),
|
||||||
|
.activation_policy = ECHOION_ACTIVATION_RESTART_REQUIRED_V1,
|
||||||
|
.api = &Bridge::api,
|
||||||
|
.reserved = {},
|
||||||
|
};
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
} // namespace Echoion::Web
|
} // namespace Echoion::Web
|
||||||
|
|
||||||
extern "C" ECHOION_MODULE_EXPORT const Void::Plugin::ModuleDescriptor*
|
extern "C" ECHOION_MODULE_EXPORT const Void::Plugin::ModuleDescriptor *
|
||||||
echoion_module_query()
|
echoion_module_query()
|
||||||
{
|
{
|
||||||
return &Echoion::Web::webModuleDescriptor();
|
return &Echoion::Web::webModuleDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" ECHOION_MODULE_ABI_EXPORT const echoion_module_descriptor_v1 *
|
||||||
|
echoion_module_abi_query()
|
||||||
|
{
|
||||||
|
return &Echoion::Web::webModuleAbiDescriptor();
|
||||||
|
}
|
||||||
Reference in new issue
Block a user