From d7bc923ddd9a8d928fdc9f13fe98781c87b05aa3 Mon Sep 17 00:00:00 2001
From: Benny Baumann <BenBE@geshi.org>
Date: Sun, 19 Feb 2023 21:36:54 +0100
Subject: [PATCH] add: Allow to fall back to runtime conversion for IP address
 conversion

---
 src/net/address.hpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/net/address.hpp b/src/net/address.hpp
index cd7b21a..c271523 100644
--- a/src/net/address.hpp
+++ b/src/net/address.hpp
@@ -479,6 +479,20 @@ static constexpr bool is_valid_ip6addr(const char (&str)[N])
     return details::inet6_aton(str, in6) != -1;
 }
 
+static bool is_valid_ip4addr(const std::string& str)
+{
+    struct in_addr in = {};
+
+    return ::inet_pton(AF_INET, str.c_str(), &in) != -1;
+}
+
+static bool is_valid_ip6addr(const std::string& str)
+{
+    struct in6_addr in = {};
+
+    return ::inet_pton(AF_INET6, str.c_str(), &in) != -1;
+}
+
 }
 
 // Work around use of non-standard feature (not part of ISO-C++)
-- 
GitLab