X-Git-Url: https://git.llucax.com/z.facultad/75.74/practicos.git/blobdiff_plain/c5c7f9d1eedf0faf5ab7581c56ef1ca700d58fb5..f17a708ff0e870baf2709bb0d63f32f166e082d3:/practicas/pipi/src/nameserver.cpp?ds=inline diff --git a/practicas/pipi/src/nameserver.cpp b/practicas/pipi/src/nameserver.cpp index 822f6f6..cf7dac3 100644 --- a/practicas/pipi/src/nameserver.cpp +++ b/practicas/pipi/src/nameserver.cpp @@ -248,17 +248,29 @@ ResolvProtoResponse NameServer::resolv_direct(const Name& n) } if (zones.size()) { + // Busco una zona con padre para ver si puedo "trepar" + for (zones_t::const_iterator i = zones.begin(); i != zones.end(); ++i) + { #ifdef DEBUG_RESOLV - std::cerr << "resolv_direct found (al padre): " << zones.front().parent + std::cerr << "resolv_direct -> evaluando padre " << i->parent << "\n"; - ResolvProtoResponse rpr(ResolvProtoResponse::R_NS, zones.front().ttl); - rpr.ips.push_back(zones.front().parent); - return rpr; #endif + if (i->parent != IPAddr(0)) + { +#ifdef DEBUG_RESOLV + std::cerr << "resolv_direct found (al padre): " + << i->parent << "\n"; +#endif + ResolvProtoResponse rpr(ResolvProtoResponse::R_NS, i->ttl); + rpr.ips.push_back(i->parent); + return rpr; + } + } } #ifdef DEBUG_RESOLV std::cerr << "resolv_direct NOT FOUND (no hay padre)\n"; #endif + // No hay padre, no puedo hacer nada más return ResolvProtoResponse(ResolvProtoResponse::R_NOTFOUND); }