๐Ÿ A very simple static Gemini server, now with Titan support!
cpp gemini titan gemini-protocol titan-protocol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

build: switch from ninja to tup

Fuwn 970099af be5e7393

+40 -42
+8 -8
.gitignore
··· 1 1 # Development 2 2 *.pem 3 - out/ 4 3 5 - # CMake 6 - cmake-build-*/ 7 - CMakeLists.txt 4 + # IDE 5 + .idea 6 + .vscode 8 7 9 - # Ninja 10 - .ninja_* 8 + # Tup 9 + .tup 11 10 12 - # IDE 13 - .idea/ 11 + # Build Artifacts 12 + build 13 +
+4 -3
README.md
··· 3 3 A very simple static Gemini server, now with Titan support! 4 4 5 5 ### Lines-of-code 6 + 6 7 This codebase is now 351 lines of lines-of-code! 7 8 8 9 The statement "... written within a single file and liberally ··· 32 33 33 34 ### Executable 34 35 35 - 1. Build: `ninja` (requires [Ninja](https://ninja-build.org/)) 36 - 2. Run: `out/maple`, or 37 - `TITAN=1 TITAN_TOKEN=secret TITAN_MAX_SIZE=2048 out/maple` 36 + 1. Build: `tup` (requires [Tup](https://gittup.org/tup/index.html)) 37 + 2. Run: `build/maple`, or 38 + `TITAN=1 TITAN_TOKEN=secret TITAN_MAX_SIZE=2048 build/maple` 38 39 39 40 ### Certificates 40 41
+22
Tupfile
··· 1 + NAME = maple 2 + 3 + # Input & Output Directories 4 + SOURCE_DIRECTORY = $(NAME) 5 + INCLUDE_DIRECTORY = $(NAME) 6 + BUILD_DIRECTORY = build 7 + 8 + # Compiler Configuration 9 + CXX = clang++ 10 + CXX_EXTENSION = cc 11 + CXX_FLAGS = -std=c++23 -I $(INCLUDE_DIRECTORY) -Weverything -Wno-padded -Wno-c++98-compat -MMD -fno-diagnostics-show-note-include-stack -Wno-c++98-compat-pedantic 12 + LD_FLAGS = -lssl -lcrypto 13 + 14 + # Clang-Tidy Configuration 15 + CLANG_TIDY_CHECKS = '-*,bugprone-*,clang-analyzer-*,concurrency-*,cppcoreguildelines-*,llvm-*,misc-*,modernize-*,performance-*,portability-*,readability-*,-readability-magic-numbers,-llvm-header-guard,-bugprone-suspicious-include,-readability-function-cognitive-complexity,-bugprone-exception-escape' 16 + CLANG_TIDY_FLAGS = -checks=$(CLANG_TIDY_CHECKS) -warnings-as-errors=* -quiet 17 + 18 + # : foreach $(SOURCE_DIRECTORY)/*.$(CXX_EXTENSION) $(INCLUDE_DIRECTORY)/*.hh |> clang-format -i -style=LLVM %f |> 19 + # : foreach $(SOURCE_DIRECTORY)/*.$(CXX_EXTENSION) |> clang-tidy $(CLANG_TIDY_FLAGS) %f -- $(CXX_FLAGS) |> 20 + : foreach $(SOURCE_DIRECTORY)/*.$(CXX_EXTENSION) |> ^j^ $(CXX) $(CXX_FLAGS) -MF $(BUILD_DIRECTORY)/%B.d -c %f -o %o |> $(BUILD_DIRECTORY)/%B.o | $(BUILD_DIRECTORY)/%B.d 21 + : $(BUILD_DIRECTORY)/*.o |> $(CXX) $(LD_FLAGS) %f -o %o |> $(BUILD_DIRECTORY)/$(NAME) 22 +
-26
build.ninja
··· 1 - cc = clang++ 2 - cxxflags = -Weverything -Wno-c++98-compat -std=c++20 3 - ldflags = -lssl -lcrypto 4 - out_dir = out 5 - name = maple 6 - src_dir = $name 7 - 8 - rule compile 9 - command = $cc $cxxflags -c $in -o $out 10 - 11 - rule link 12 - command = $cc $ldflags $in -o $out 13 - 14 - rule clang_format 15 - command = clang-format -i -style=LLVM $src_dir/*$cc_ext $src_dir/*.hh 16 - 17 - build $out_dir/$name.o: compile $src_dir/$name.cc 18 - build $out_dir/gemini.o: compile $src_dir/gemini.cc 19 - build $out_dir/titan.o: compile $src_dir/titan.cc 20 - 21 - build $out_dir/$name: link $out_dir/$name.o $out_dir/gemini.o $out_dir/titan.o 22 - 23 - build _format: clang_format 24 - build format: phony _format 25 - 26 - default $out_dir/$name
+6 -5
maple/titan.cc
··· 39 39 parameter.erase(0, parameter_delimiter_position + 1); 40 40 41 41 // Add the key and value to `parameters_map` 42 - parameters_map[key] = parameter; 42 + parameters_map.at(key) = parameter; 43 43 } 44 44 45 45 return parameters_map; 46 46 } 47 47 48 48 auto handle_client(std::stringstream &response, std::string path, 49 - const std::string &titan_token, size_t titan_max_size) 50 - -> void { 49 + const std::string &titan_token, 50 + size_t titan_max_size) -> void { 51 51 std::vector<std::string> parameters; 52 52 // Find path in `path` 53 53 size_t delimiter_position = path.find(';'); ··· 121 121 } 122 122 123 123 try { 124 - size_t body_size = static_cast<size_t>(std::stoi(parameters_map["size"])); 124 + size_t body_size = 125 + static_cast<size_t>(std::stoi(parameters_map.at("size"))); 125 126 126 127 if (body_size > titan_max_size) { 127 128 response << "20 text/gemini\r\nThe server (Maple) received a body " ··· 141 142 update_path = "/index.gmi"; 142 143 } 143 144 144 - if (parameters_map["token"] == titan_token) { 145 + if (parameters_map.at("token") == titan_token) { 145 146 std::ofstream file(".maple/gmi" + update_path); 146 147 147 148 file << body;