|
Haio 0.2.X
Homebrew Asset IO/CDN
|
Classes | |
| struct | Failure |
| struct | ZipEntry |
| struct | ZipIndex |
| struct | ZipPath |
| class | ZipArchives |
Typedefs | |
| using | Headers = std::map<std::string, std::string> |
Functions | |
| Blob | fetchFile (const BucketConfig &bucket, std::string path) |
| boost::asio::awaitable< Blob > | fetchHttp (const BucketConfig &bucket, std::string path) |
| boost::asio::awaitable< Blob > | fetchUrlWith (std::string url, std::string pathForFormat, Headers headers) |
| boost::asio::awaitable< Blob > | fetchS3 (const BucketConfig &bucket, std::string path) |
| std::string | awsSignatureV4 (std::string_view secret, std::string_view date, std::string_view region, std::string_view service, std::string_view stringToSign) |
| Result< ZipIndex > | readZipIndex (Bytes data) |
| Result< std::vector< uint8_t > > | readZipEntry (Bytes data, const ZipEntry &entry, size_t maxSize) |
| std::optional< ZipPath > | splitZipPath (std::string_view path) |
| boost::asio::awaitable< Blob > | fetchInsideZip (const BucketConfig &bucket, const ZipPath &path, const SecurityConfig &security, ZipArchives &archives) |
one directory per way of reaching bytes, the way the codecs do it. the dispatcher in buckets.cpp picks by the scheme the config parsed, and each fetcher only knows its own protocol.
| struct Haio::Cdn::Bucket::ZipEntry |
where one file sits inside an archive, as the zip's own directory records it
Definition at line 63 of file bucket.hpp.
| Class Members | ||
|---|---|---|
| uint32_t | at = 0 | |
| uint32_t | compressed = 0 | |
| uint16_t | method = 0 | |
| uint32_t | uncompressed = 0 | |
| struct Haio::Cdn::Bucket::ZipIndex |
Definition at line 70 of file bucket.hpp.
| Class Members | ||
|---|---|---|
| map< string, ZipEntry > | entries | |
| struct Haio::Cdn::Bucket::ZipPath |
"pack.zip/logo.png" split into the archive and the name inside it, or nothing when the path names no archive. the split is on the first ".zip/", so an archive inside an archive is read as a file inside the outer one rather than opened again.
Definition at line 82 of file bucket.hpp.
| Class Members | ||
|---|---|---|
| string | archive | |
| string | inside | |
| using Haio::Cdn::Bucket::Headers = std::map<std::string, std::string> |
headers a caller adds to the request, which is how s3 carries its signature
Definition at line 37 of file bucket.hpp.
| std::string Haio::Cdn::Bucket::awsSignatureV4 | ( | std::string_view | secret, |
| std::string_view | date, | ||
| std::string_view | region, | ||
| std::string_view | service, | ||
| std::string_view | stringToSign ) |
the signature part of sigv4, on its own so it can be checked against the vectors aws publishes. the key is derived over date, region and service and then used over the string to sign; getting the last step wrong yields something that looks like a signature and is refused exactly like a wrong secret.
Definition at line 113 of file s3.cpp.

| Blob Haio::Cdn::Bucket::fetchFile | ( | const BucketConfig & | bucket, |
| std::string | path ) |
| asio::awaitable< Blob > Haio::Cdn::Bucket::fetchHttp | ( | const BucketConfig & | bucket, |
| std::string | path ) |
| asio::awaitable< Blob > Haio::Cdn::Bucket::fetchInsideZip | ( | const BucketConfig & | bucket, |
| const ZipPath & | path, | ||
| const SecurityConfig & | security, | ||
| ZipArchives & | archives ) |
reads one file out of an archive the bucket holds.
the archive is fetched the ordinary way and then kept, so a second picture out of the same zip costs an inflate and no fetch. the same picture twice never arrives here at all: the response cache answered before the bucket was asked.
Definition at line 16 of file fetch.cpp.

| asio::awaitable< Blob > Haio::Cdn::Bucket::fetchS3 | ( | const BucketConfig & | bucket, |
| std::string | path ) |
s3 buckets, which are https with a signature.
the credentials come from the environment, the way every other aws tool reads them, so nothing secret is ever written in the config file.
signature version 4, which is what turns an https request into an s3 one.
the credentials are read from the environment on every request rather than kept, so rotating them does not need a restart, and nothing secret is ever written in the config file. without them the request goes out unsigned, which is exactly right for a public bucket and gives a plain 403 from aws for a private one.
Definition at line 130 of file s3.cpp.

| Result< std::vector< uint8_t > > Haio::Cdn::Bucket::readZipEntry | ( | Bytes | data, |
| const ZipEntry & | entry, | ||
| size_t | maxSize ) |
inflates one entry, refusing anything that expands further than it should
Definition at line 106 of file reader.cpp.

enough of the zip format to read one file out of an archive already in memory.
the central directory is the index the format itself keeps, so nothing has to be guessed by scanning for local headers; a file that disagrees with its own directory is refused rather than read around.
Definition at line 57 of file reader.cpp.

| std::optional< ZipPath > Haio::Cdn::Bucket::splitZipPath | ( | std::string_view | path | ) |
the split is on the first ".zip/", so the outer archive is the one that opens
Definition at line 6 of file archives.cpp.
