From 8c204a4c10d8b76cbb4688f7ee88ee17139ac003 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 18 Jul 2025 22:39:21 -0400 Subject: [PATCH] use std::string_view for I2P HTTP headers. constexpr for ecxluded headers list --- libi2pd_client/I2PTunnel.cpp | 4 ++-- libi2pd_client/I2PTunnel.h | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libi2pd_client/I2PTunnel.cpp b/libi2pd_client/I2PTunnel.cpp index fe83d47f..c1cf247a 100644 --- a/libi2pd_client/I2PTunnel.cpp +++ b/libi2pd_client/I2PTunnel.cpp @@ -428,7 +428,7 @@ namespace client else { // strip up some headers - static const std::array excluded // list of excluded headers + static constexpr std::array excluded // list of excluded headers { "Keep-Alive:", "X-I2P" }; @@ -511,7 +511,7 @@ namespace client if (line == "\r") endOfHeader = true; else { - static const std::array excluded // list of excluded headers + static constexpr std::array excluded // list of excluded headers { "Server:", "Date:", "X-Runtime:", "X-Powered-By:", "Proxy" }; diff --git a/libi2pd_client/I2PTunnel.h b/libi2pd_client/I2PTunnel.h index 9abae09a..3fb98c5c 100644 --- a/libi2pd_client/I2PTunnel.h +++ b/libi2pd_client/I2PTunnel.h @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -30,13 +31,13 @@ namespace client constexpr size_t I2P_TUNNEL_CONNECTION_BUFFER_SIZE = 8192; constexpr size_t I2P_TUNNEL_CONNECTION_STREAM_MAX_SEND_BUFFER_SIZE = 8*I2P_TUNNEL_CONNECTION_BUFFER_SIZE; constexpr size_t I2P_TUNNEL_CONNECTION_STREAM_BUFFER_SIZE = 16384; - const int I2P_TUNNEL_CONNECTION_MAX_IDLE = 3600; // in seconds - const int I2P_TUNNEL_DESTINATION_REQUEST_TIMEOUT = 10; // in seconds + constexpr int I2P_TUNNEL_CONNECTION_MAX_IDLE = 3600; // in seconds + constexpr int I2P_TUNNEL_DESTINATION_REQUEST_TIMEOUT = 10; // in seconds // for HTTP tunnels - constexpr char X_I2P_DEST_HASH[] = "X-I2P-DestHash"; // hash in base64 - constexpr char X_I2P_DEST_B64[] = "X-I2P-DestB64"; // full address in base64 - constexpr char X_I2P_DEST_B32[] = "X-I2P-DestB32"; // .b32.i2p address - const int I2P_TUNNEL_HTTP_MAX_HEADER_SIZE = 8192; + constexpr std::string_view X_I2P_DEST_HASH { "X-I2P-DestHash" }; // hash in base64 + constexpr std::string_view X_I2P_DEST_B64 { "X-I2P-DestB64" }; // full address in base64 + constexpr std::string_view X_I2P_DEST_B32 { "X-I2P-DestB32" }; // .b32.i2p address + constexpr int I2P_TUNNEL_HTTP_MAX_HEADER_SIZE = 8192; class I2PTunnelConnection: public I2PServiceHandler, public std::enable_shared_from_this {