}
uint16_t Resolver::sendResolve(const ComboAddress& remote, const ComboAddress& local,
- const DNSName &domain, int type, bool dnssecOK,
+ const DNSName &domain, int type, int *localsock, bool dnssecOK,
const DNSName& tsigkeyname, const DNSName& tsigalgorithm,
const string& tsigsecret)
{
}
}
+ if (localsock != nullptr) {
+ *localsock = sock;
+ }
if(sendto(sock, &packet[0], packet.size(), 0, (struct sockaddr*)(&remote), remote.getSocklen()) < 0) {
throw ResolverException("Unable to ask query of "+remote.toStringWithPort()+": "+stringerror());
}
try {
ComboAddress to(ipport, 53);
- int id = sendResolve(to, local, domain, type);
- int sock;
-
- // choose socket based on local
- if (local.sin4.sin_family == 0) {
- // up to us.
- sock = to.sin4.sin_family == AF_INET ? locals["default4"] : locals["default6"];
- } else {
- std::string lstr = local.toString();
- std::map<std::string, int>::iterator lptr;
- // see if there is a local
-
- if ((lptr = locals.find(lstr)) != locals.end()) sock = lptr->second;
- else throw ResolverException("sendResolve did not create socket for " + lstr);
- }
-
+ int sock = -1;
+ int id = sendResolve(to, local, domain, type, &sock);
int err=waitForData(sock, 0, 3000000);
if(!err) {
int resolve(const string &ip, const DNSName &domain, int type, res_t* result);
//! only send out a resolution request
- uint16_t sendResolve(const ComboAddress& remote, const ComboAddress& local, const DNSName &domain, int type, bool dnssecOk=false,
+ uint16_t sendResolve(const ComboAddress& remote, const ComboAddress& local, const DNSName &domain, int type, int *localsock, bool dnssecOk=false,
const DNSName& tsigkeyname=DNSName(), const DNSName& tsigalgorithm=DNSName(), const string& tsigsecret="");
//! see if we got a SOA response from our sendResolve