summaryrefslogtreecommitdiffhomepage
path: root/response.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-04-24 17:40:52 +0200
committerRoland Reichwein <mail@reichwein.it>2020-04-24 17:40:52 +0200
commite04f16439db7e1befadf987a7795e68a10697af4 (patch)
tree3c96352ab2c8279b492ee2d3ebc665b8278a4564 /response.cpp
parent58da9654563d89039a58e4bf14a3b0e383fe93c8 (diff)
Add Ipv6 property to server
Diffstat (limited to 'response.cpp')
-rw-r--r--response.cpp6
1 files changed, 6 insertions, 0 deletions
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; }},
};