Haio 0.2.X
Homebrew Asset IO/CDN
Loading...
Searching...
No Matches
haio_cdn.hpp File Reference
#include "haio.hpp"
#include "haio_cache.hpp"
#include <boost/asio/awaitable.hpp>
#include <chrono>
#include <filesystem>
#include <map>
#include <set>
#include <string_view>
Include dependency graph for haio_cdn.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Haio::Cdn::BucketConfig
struct  Haio::Cdn::SecurityConfig
struct  Haio::Cdn::Config

Namespaces

namespace  Haio
namespace  Haio::Cdn
namespace  Haio::Cdn::Bucket

Functions

Config Haio::Cdn::parseConfig (std::string_view text)
Config Haio::Cdn::loadConfig (const std::filesystem::path &path)
boost::asio::awaitable< Result< Blob > > Haio::Cdn::fetchBucket (const Config &config, Bucket::ZipArchives &archives, std::string bucket, std::string path)
boost::asio::awaitable< void > Haio::Cdn::runServer (Config config)

Class Documentation

◆ Haio::Cdn::BucketConfig

struct Haio::Cdn::BucketConfig

a bucket is described entirely by the scheme of its url:

file://relative/dir file:///absolute/dir http://host/prefix https://host/prefix s3://host/bucket https://* open, the request names the host //* open, the request names the scheme and the host

Definition at line 201 of file haio_cdn.hpp.

Class Members
string accessKey

s3 only, and the reason a config file deserves careful permissions. empty leaves the request unsigned, which is what a public bucket wants.

string name
bool open = false
string region

s3 only: from ?region=, then the host, then AWS_DEFAULT_REGION

path root
string scheme
string secretKey
string sessionToken
string url

◆ Haio::Cdn::SecurityConfig

struct Haio::Cdn::SecurityConfig

every limit the server has, in one table, so that reviewing what protects this deployment is reading one page of the config rather than hunting for it.

each one is safe when left out, and the server says at startup which ones it chose for itself; see Security.

Definition at line 229 of file haio_cdn.hpp.

Class Members
bool allowUnzip = false

whether a path may reach inside a zip; off unless asked for

size_t maxCacheEntriesByIp = 0

entries one address may create per cache window; zero is no limit

size_t maxRequestsByIp = 0

requests one address may make per second; zero is no limit

int maxSizePercent = 500

the largest share a resize may ask for, as a percentage.

it is a separate number because it bounds a different thing: a picture scaled by a share is bounded by what it was, so five hundred percent of a thumbnail is still small, while five hundred percent of something large is not.

int maxSizePixel = 4096

the largest width or height a resize may ask for outright

size_t maxUnzip = 64u << 20

bytes one file out of a zip may take, and what the archives kept in memory may take altogether. megabytes in the config.

seconds timeout {10}

seconds one conversion may run before it is given up on

◆ Haio::Cdn::Config

struct Haio::Cdn::Config

Definition at line 261 of file haio_cdn.hpp.

Collaboration diagram for Haio::Cdn::Config:
Class Members
map< string, BucketConfig > buckets
CacheConfig cache
set< string > declared

the keys the file actually spelled out, as "max_size" or "cache.max_ip".

the safety limits all have a default, so leaving one out is safe rather than open; this is what lets the server say which ones it chose for itself instead of letting an operator believe they had configured something.

string host = "0.0.0.0"
unsigned short port = 8080
SecurityConfig security