commit bce8f2740bc3c255439257893c9c6f724feb4689 from: Aleksey Ryndin date: Wed Aug 16 12:44:50 2023 UTC Cross platform build: alpine linux tested (`libressl-dev` required) commit - b20335632804754482ef930b97f325c08c4ac8fc commit + bce8f2740bc3c255439257893c9c6f724feb4689 blob - 8931ba4f492fc02e35c0967addd746637eaa662b blob + acdaaf481179d4a060644166f0198c5d07b1e9d2 --- Makefile +++ Makefile @@ -9,4 +9,4 @@ server: ${MAKE} -C vostokd run_server: server - ./vostokd/vostokd -c cert/server.crt -k cert/server.key -f static/ + ./vostokd/vostokd -c cert/server.crt -k cert/server.key -f ./ blob - e124e72c5414367ddacc70318254ba0945a59634 blob + 2b7e140a4af8327c021ece421a7e4c429784072e --- shared/cut_null +++ shared/cut_null @@ -1,5 +1,6 @@ /** Remove null terminating character */ +#include "span" #pragma once @@ -9,7 +10,7 @@ namespace vostok /** Remove null terminating character and return as span */ -template +template constexpr span cut_null(const char (&arr)[N]) { static_assert(N > 0, "!(N > 0)"); blob - 611e231ad28b76cc73de58ba46028d9a0be60ff0 blob + 5ce2750cbb1b144ccd61629648a261139e086a47 --- shared/span +++ shared/span @@ -18,29 +18,29 @@ class span (public) constexpr span() : m_p{nullptr}, m_count{0} {} - constexpr span(element_type *p, size_t count) : m_p{count ? p : nullptr}, m_count{count} {} - template + constexpr span(element_type *p, std::size_t count) : m_p{count ? p : nullptr}, m_count{count} {} + template constexpr span(element_type (&arr)[N]) : m_p{arr}, m_count{N} {} - template + template constexpr span(std::array &arr) : m_p{arr.data()}, m_count{N} {} - constexpr size_t size() const {return m_count;} + constexpr std::size_t size() const {return m_count;} constexpr iterator begin() const noexcept { return m_p; } constexpr iterator end() const noexcept { return m_p + size(); } - span first(size_t count) const + span first(std::size_t count) const { assert(count <= m_count); return span{m_p, count}; } - span subspan(size_t offset) const + span subspan(std::size_t offset) const { assert(offset <= m_count); return (offset < m_count) ? span{m_p + offset, m_count - offset} : span{}; } - element_type &operator[](size_t idx) const + element_type &operator[](std::size_t idx) const { assert(idx < m_count); return m_p[idx]; @@ -48,7 +48,7 @@ class span (public) private: element_type *m_p; - size_t m_count; + std::size_t m_count; }; } // namespace vostok blob - c842f06d2f8051e40b5b6eafeeb763195a489e99 blob + f235e457c38976fd348742488c27f7759fb7dc42 --- shared/transport.h +++ shared/transport.h @@ -7,6 +7,7 @@ #include "span" #include "gemini.h" +#include #include #pragma once blob - /dev/null blob + cdb10cb45e220ca09bf2a04fb0a76a8425c2333b (mode 644) --- /dev/null +++ reports/0.0.1.gmi @@ -0,0 +1,9 @@ +# vostokd: gemini-сервер статического контента + +...work-in-progress... + + +``` +$ mkdir cert && cd cert +cert$ openssl req -newkey rsa:4096 -nodes -keyout server.key -x509 -days 36500 -out server.crt +``` blob - 7f0db3126308ca3ba1c2e678fd46892699271d92 (mode 644) blob + /dev/null --- static/reports/0.0.1.gmi +++ /dev/null @@ -1,3 +0,0 @@ -# vostokd: gemini-сервер статического контента - -...work-in-progress... blob - 673540d1db66509e57e5ec76656eeadd308f3a3f blob + 057a3719306c47d8e9a791269e7d309159e70709 --- vostokd/Makefile +++ vostokd/Makefile @@ -1,25 +1,24 @@ -CXXFLAGS = -Wall -Wextra -std=c++11 -CXXFLAGS += -I${.CURDIR}/../shared -CXXFLAGS += -ltls +CXXFLAGS = -Wall -Wextra -std=c++11 -I../shared +LIBS = -ltls CXXFILES = vostokd.cc -HXXFILES = ${.PATH}../shared/not_null -HXXFILES += ${.PATH}../shared/zstring -HXXFILES += ${.PATH}../shared/unique_fd -HXXFILES += ${.PATH}../shared/non_copiable -HXXFILES += ${.PATH}../shared/unique_fd -HXXFILES += ${.PATH}../shared/span -HXXFILES += ${.PATH}../shared/cut_null -CXXFILES += ${.PATH}../shared/transport.cc -HXXFILES += ${.PATH}../shared/transport.h -CXXFILES += ${.PATH}../shared/error.cc -HXXFILES += ${.PATH}../shared/error.h -CXXFILES += ${.PATH}../shared/gemini.cc -HXXFILES += ${.PATH}../shared/gemini.h +HXXFILES = ../shared/not_null +HXXFILES += ../shared/zstring +HXXFILES += ../shared/unique_fd +HXXFILES += ../shared/non_copiable +HXXFILES += ../shared/unique_fd +HXXFILES += ../shared/span +HXXFILES += ../shared/cut_null +CXXFILES += ../shared/transport.cc +HXXFILES += ../shared/transport.h +CXXFILES += ../shared/error.cc +HXXFILES += ../shared/error.h +CXXFILES += ../shared/gemini.cc +HXXFILES += ../shared/gemini.h CXXFILES += command_line_arguments.cc HXXFILES += command_line_arguments.h CXXFILES += url_normalization.cc HXXFILES += url_normalization.h vostokd: ${CXXFILES} ${HXXFILES} - ${CXX} ${CXXFLAGS} ${CXXFILES} -o vostokd + ${CXX} ${CXXFLAGS} ${CXXFILES} ${LIBS} -o vostokd