Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal resolver tweaks #710

Merged
merged 3 commits into from
Mar 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ static char *resolveHostname(const char *addr)
return hostname;
}

// Back up first ns record in _res and ...
struct in_addr nsbck;
nsbck = _res.nsaddr_list[0].sin_addr;
// Force last available (MAXNS-1) server used for lookups to 127.0.0.1 (FTL itself)
struct in_addr nsbck = { 0 };
// Back up corresponding ns record in _res and ...
nsbck = _res.nsaddr_list[MAXNS-1].sin_addr;
// ... force FTL resolver to 127.0.0.1
inet_pton(AF_INET, "127.0.0.1", &_res.nsaddr_list[0].sin_addr);
inet_pton(AF_INET, "127.0.0.1", &_res.nsaddr_list[MAXNS-1].sin_addr);

// Test if we want to resolve an IPv6 address
if(strstr(addr,":") != NULL)
Expand Down Expand Up @@ -80,8 +81,8 @@ static char *resolveHostname(const char *addr)
strtolower(hostname);
}

// Restore first ns record in _res
_res.nsaddr_list[0].sin_addr = nsbck;
// Restore ns record in _res
_res.nsaddr_list[MAXNS-1].sin_addr = nsbck;

// Return result
return hostname;
Expand Down