diff irccdctl/cli.cpp @ 788:3c090c1ff4f0

irccd: support IPv4, IPv6 in IRC servers, closes #945 @2h
author David Demelier <markand@malikania.fr>
date Thu, 08 Nov 2018 20:48:19 +0100
parents 7145a3df4cb7
children f26bb089232d
line wrap: on
line diff
--- a/irccdctl/cli.cpp	Thu Nov 08 07:03:37 2018 +0100
+++ b/irccdctl/cli.cpp	Thu Nov 08 20:48:19 2018 +0100
@@ -210,6 +210,8 @@
 auto parse(std::vector<std::string> &args) -> option::result
 {
 	option::options options{
+		{ "-4",                 false   },
+                { "-6",                 false   },
 		{ "-c",                 true    },
 		{ "--command",          true    },
 		{ "-n",                 true    },
@@ -775,7 +777,7 @@
 	auto object = nlohmann::json::object({
 		{ "command",    "server-connect"        },
 		{ "name",       copy[0]                 },
-		{ "hostname",   copy[1]                 }
+		{ "hostname",   copy[1]                 },
 	});
 
 	if (copy.size() == 3) {
@@ -798,6 +800,12 @@
 	if ((it = result.find("-u")) != result.end() || (it = result.find("--username")) != result.end())
 		object["username"] = it->second;
 
+        // Mutually exclusive.
+        if ((it = result.find("-4")) != result.end())
+                object["family"] = nlohmann::json::array({ "ipv4" });
+        if ((it = result.find("-6")) != result.end())
+                object["family"] = nlohmann::json::array({ "ipv6" });
+
 	request(ctl, object);
 }