mirror of
https://github.com/uroni/urbackup_backend.git
synced 2025-10-26 11:36:50 +00:00
Return ipv6 zone in lookup
This commit is contained in:
parent
bdd995a62c
commit
b158bfa4ef
@ -26,6 +26,7 @@
|
||||
|
||||
bool LookupBlocking(std::string pServer, SLookupBlockingResult& dest)
|
||||
{
|
||||
dest.zone = 0;
|
||||
const char* host = pServer.c_str();
|
||||
unsigned int addr = inet_addr(host);
|
||||
if (addr != INADDR_NONE)
|
||||
@ -34,12 +35,6 @@ bool LookupBlocking(std::string pServer, SLookupBlockingResult& dest)
|
||||
dest.addr_v4 = addr;
|
||||
return true;
|
||||
}
|
||||
int rc = inet_pton(AF_INET6, host, dest.addr_v6);
|
||||
if (rc == 1)
|
||||
{
|
||||
dest.is_ipv6 = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
addrinfo hints;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
@ -66,6 +61,7 @@ bool LookupBlocking(std::string pServer, SLookupBlockingResult& dest)
|
||||
{
|
||||
dest.is_ipv6 = true;
|
||||
memcpy(dest.addr_v6, &reinterpret_cast<sockaddr_in6*>(h->ai_addr)->sin6_addr, 16);
|
||||
dest.zone = reinterpret_cast<sockaddr_in6*>(h->ai_addr)->sin6_scope_id;
|
||||
freeaddrinfo(orig_h);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ struct SLookupBlockingResult
|
||||
unsigned int addr_v4;
|
||||
char addr_v6[16];
|
||||
};
|
||||
unsigned int zone;
|
||||
};
|
||||
|
||||
bool LookupBlocking(std::string pServer, SLookupBlockingResult& dest);
|
||||
|
||||
@ -1036,6 +1036,7 @@ IPipe* CServer::ConnectStream(std::string pServer, unsigned short pPort, unsigne
|
||||
memcpy(&addr.addr_v6.sin6_addr, lookup_result.addr_v6, sizeof(addr.addr_v6.sin6_addr));
|
||||
addr.addr_v6.sin6_port = htons(pPort);
|
||||
addr.addr_v6.sin6_family = AF_INET6;
|
||||
addr.addr_v6.sin6_scope_id = lookup_result.zone;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user