diff --git a/TargetGroup.cc b/TargetGroup.cc index 317ecd8ae..175025f31 100644 --- a/TargetGroup.cc +++ b/TargetGroup.cc @@ -260,6 +260,10 @@ static NetBlock *parse_expr_without_netmask(const char *hostexp, int af) { sslen = sizeof(ss); if (resolve_numeric(hostexp, 0, &ss, &sslen, AF_INET6) == 0) { + if (af != AF_INET6) { + error("%s looks like an IPv6 target specification -- you have to use the -6 option.", hostexp); + return NULL; + } NetBlockIPv6Netmask *netblock_ipv6; netblock_ipv6 = new NetBlockIPv6Netmask(); diff --git a/targets.cc b/targets.cc index 654ea779b..4a3926d44 100644 --- a/targets.cc +++ b/targets.cc @@ -395,20 +395,6 @@ int TargetGroup::get_next_host(struct sockaddr_storage *ss, size_t *sslen) { delete netblock_hostname; } - /* Check for proper address family. Give a specific error message for IPv6 - specifications appearing in IPv4 mode. */ - if (o.af() == AF_INET && dynamic_cast(this->netblock) != NULL) { - error("%s looks like an IPv6 target specification -- you have to use the -6 option.", - this->netblock->str().c_str()); - return -1; - } - if ((o.af() == AF_INET && dynamic_cast(this->netblock) == NULL) || - (o.af() == AF_INET6 && dynamic_cast(this->netblock) == NULL)) { - error("Address family mismatch in target specification \"%s\".", - this->netblock->str().c_str()); - return -1; - } - if (this->netblock->next(ss, sslen)) return 0; else