summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rw-r--r--response.cpp6
2 files changed, 6 insertions, 1 deletions
diff --git a/TODO b/TODO
index 9e0fa1e..160a118 100644
--- a/TODO
+++ b/TODO
@@ -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; }},
};