diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-04-24 17:40:52 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-04-24 17:40:52 +0200 |
commit | e04f16439db7e1befadf987a7795e68a10697af4 (patch) | |
tree | 3c96352ab2c8279b492ee2d3ebc665b8278a4564 | |
parent | 58da9654563d89039a58e4bf14a3b0e383fe93c8 (diff) |
Add Ipv6 property to server
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | response.cpp | 6 |
2 files changed, 6 insertions, 1 deletions
@@ -4,7 +4,6 @@ weblog: style: zitate Integrate into Debian Ubuntu version -Request properties: Remote Address, e.g. [::1]:8081 -> ipv6 / ipv4 Speed up config.GetPath read: The socket was closed due to a timeout statistics diff --git a/response.cpp b/response.cpp index 7bbcebf..e1b6c05 100644 --- a/response.cpp +++ b/response.cpp @@ -72,10 +72,16 @@ std::string extend_index_html(std::string path) return path; } +bool is_ipv6_address(const std::string& addr) +{ + return addr.find(":") != addr.npos; +} + std::unordered_map<std::string, std::function<std::string(Server&)>> GetServerParamFunctions{ // following are the supported fields: {"version", [](Server& server) { return Server::VersionString; }}, {"address", [](Server& server) { return server.GetSocket().address; }}, + {"ipv6", [](Server& server) { return is_ipv6_address(server.GetSocket().address) ? "yes" : "no"; }}, {"port", [](Server& server) { return server.GetSocket().port; }}, }; |