From 5f004f5b45d46958015797994860d02e1234c98b Mon Sep 17 00:00:00 2001 From: blankie Date: Tue, 4 Apr 2023 21:32:51 +0700 Subject: [PATCH] Add proxy option for proxying images --- config.cpp | 3 ++- config.h | 1 + example_config.json | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/config.cpp b/config.cpp index 9454de4..1346091 100644 --- a/config.cpp +++ b/config.cpp @@ -5,7 +5,7 @@ Config load_config(const char* path) { File config_file(path, "r"); - return nlohmann::json::parse(config_file.get()); + return nlohmann::json::parse(config_file.get(), nullptr, true, true); } void from_json(const nlohmann::json& j, Config& config) { @@ -16,4 +16,5 @@ void from_json(const nlohmann::json& j, Config& config) { if (config.bind_port < 0) { throw std::invalid_argument("Invalid port to bind to: "s + std::to_string(config.bind_port)); } + j.at("image_proxy_url").get_to(config.image_proxy_url); } diff --git a/config.h b/config.h index 98058a5..cd67f4a 100644 --- a/config.h +++ b/config.h @@ -6,6 +6,7 @@ struct Config { std::string bind_host = "127.0.0.1"; int bind_port = 8080; + std::string image_proxy_url = "https://i.pixiv.cat"; }; Config load_config(const char* path); diff --git a/example_config.json b/example_config.json index b06ce88..4c04b33 100644 --- a/example_config.json +++ b/example_config.json @@ -1,4 +1,5 @@ { - "bind_host": "127.0.0.1", - "bind_port": 8080 + "bind_host": "127.0.0.1", // What address to bind to + "bind_port": 8080, // What port to bind to + "image_proxy_url": "https://i.pixiv.cat" // URL to proxy images to (see https://pixiv.cat/reverseproxy.html) }