From e04f16439db7e1befadf987a7795e68a10697af4 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 24 Apr 2020 17:40:52 +0200 Subject: Add Ipv6 property to server --- response.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'response.cpp') 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> 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; }}, }; -- cgit v1.2.3