@@ -823,14 +823,11 @@ bool LookupSubNet(const std::string& strSubnet, CSubNet& ret, DNSLookupFn dns_lo
823
823
return false ;
824
824
}
825
825
size_t slash = strSubnet.find_last_of (' /' );
826
- std::vector< CNetAddr> vIP ;
826
+ CNetAddr network ;
827
827
828
828
std::string strAddress = strSubnet.substr (0 , slash);
829
- // TODO: Use LookupHost(const std::string&, CNetAddr&, bool) instead to just get
830
- // one CNetAddr.
831
- if (LookupHost (strAddress, vIP, 1 , false , dns_lookup_function))
829
+ if (LookupHost (strAddress, network, false , dns_lookup_function))
832
830
{
833
- CNetAddr network = vIP[0 ];
834
831
if (slash != strSubnet.npos )
835
832
{
836
833
std::string strNetmask = strSubnet.substr (slash + 1 );
@@ -842,14 +839,15 @@ bool LookupSubNet(const std::string& strSubnet, CSubNet& ret, DNSLookupFn dns_lo
842
839
}
843
840
else // If not a valid number, try full netmask syntax
844
841
{
842
+ CNetAddr netmask;
845
843
// Never allow lookup for netmask
846
- if (LookupHost (strNetmask, vIP, 1 , false , dns_lookup_function)) {
847
- ret = CSubNet (network, vIP[ 0 ] );
844
+ if (LookupHost (strNetmask, netmask , false , dns_lookup_function)) {
845
+ ret = CSubNet (network, netmask );
848
846
return ret.IsValid ();
849
847
}
850
848
}
851
849
}
852
- else
850
+ else // Single IP subnet (<ipv4>/32 or <ipv6>/128)
853
851
{
854
852
ret = CSubNet (network);
855
853
return ret.IsValid ();
0 commit comments