# HG changeset patch # User David Demelier # Date 1487405331 -3600 # Node ID ce1903f4bdb77af0e8b9a03d359c92903fb2480c # Parent e1373abccacb85416dad0b15e101ee32af6ad610 Fix #637: check for domain and family options The decision was not clear between the two option names, the documentation stated to use family but the code checked for family. Accept both for compatibility purposes and unify the documentation using the family name. Task: #637 Errata: 20170218 diff -r e1373abccacb -r ce1903f4bdb7 irccdctl/main.cpp --- a/irccdctl/main.cpp Thu Feb 16 18:53:30 2017 +0100 +++ b/irccdctl/main.cpp Sat Feb 18 09:08:51 2017 +0100 @@ -132,13 +132,13 @@ int domain = AF_INET; - if ((it = sc.find("domain")) != sc.end()) { + if ((it = sc.find("domain")) != sc.end() || (it = sc.find("family")) != sc.end()) { if (it->value() == "ipv6") { domain = AF_INET6; } else if (it->value() == "ipv4") { domain = AF_INET; } else { - throw std::invalid_argument("invalid domain: " + it->value()); + throw std::invalid_argument("invalid family: " + it->value()); } } diff -r e1373abccacb -r ce1903f4bdb7 libirccd/irccd/config.cpp --- a/libirccd/irccd/config.cpp Thu Feb 16 18:53:30 2017 +0100 +++ b/libirccd/irccd/config.cpp Sat Feb 18 09:08:51 2017 +0100 @@ -157,10 +157,16 @@ if ((it = sc.find("address")) != sc.end()) address = it->value(); - // Domain std::uint8_t mode = TransportServerIp::v4; - if ((it = sc.find("domain")) != sc.end()) { + /* + * Documentation stated family but code checked for 'domain' option. + * + * As irccdctl uses domain, accept both and unify the option name to 'family'. + * + * See #637 + */ + if ((it = sc.find("domain")) != sc.end() || (it = sc.find("family")) != sc.end()) { mode = 0; for (const auto &v : *it) { @@ -188,7 +194,7 @@ } if (mode == 0) - throw std::invalid_argument("transport: domain must at least have ipv4 or ipv6"); + throw std::invalid_argument("transport: family must at least have ipv4 or ipv6"); if (pkey.empty()) return std::make_shared(address, port, mode); diff -r e1373abccacb -r ce1903f4bdb7 libirccd/irccd/transport.cpp --- a/libirccd/irccd/transport.cpp Thu Feb 16 18:53:30 2017 +0100 +++ b/libirccd/irccd/transport.cpp Sat Feb 18 09:08:51 2017 +0100 @@ -376,14 +376,14 @@ m_socket.set(net::option::SockReuseAddress(true)); if (mode & v6) { + // Disable or enable IPv4 when using IPv6. + if (!(mode & v4)) + m_socket.set(net::option::Ipv6Only(true)); + if (address == "*") m_socket.bind(net::ipv6::any(port)); else m_socket.bind(net::ipv6::pton(address, port)); - - // Disable or enable IPv4 when using IPv6. - if (!(mode & v4)) - m_socket.set(net::option::Ipv6Only(true)); } else { if (address == "*") m_socket.bind(net::ipv4::any(port));