wwbmmm commented on code in PR #2139:
URL: https://github.com/apache/brpc/pull/2139#discussion_r1119549715


##########
src/brpc/policy/domain_naming_service.cpp:
##########
@@ -78,6 +80,35 @@ int DomainNamingService::GetServers(const char* dns_name,
         return -1;
     }
 
+    if (FLAGS_dnsIPV6) {
+        struct addrinfo hints;
+        struct addrinfo* addrResult;
+        memset(&hints, 0, sizeof(hints));
+        hints.ai_family = AF_INET6;
+        hints.ai_socktype = SOCK_DGRAM;
+        auto ok = getaddrinfo(buf, nullptr, &hints, &addrResult);
+        if (ok != 0) {
+            LOG(WARNING) << "Can't resolve `" << buf << "for ipv6";
+            return -1;
+        }
+
+        butil::EndPoint point;
+        for(auto rp = addrResult; rp != NULL; rp = rp->ai_next) {
+            struct sockaddr_in6* a= (struct sockaddr_in6*)rp->ai_addr;
+            char straddr[INET6_ADDRSTRLEN + 2];
+            inet_ntop(AF_INET6, &a->sin6_addr, straddr + 1, INET6_ADDRSTRLEN);
+            straddr[0] = '[';
+            auto len = strlen(straddr + 1);
+            straddr[len + 1] = ']';
+            straddr[len + 2] = '\0';
+            butil::details::ExtendedEndPoint::create(straddr, port, &point);

Review Comment:
   use butil::sockaddr2endpoint, don't use internal 
butil::details::ExtendedEndPoint



##########
src/brpc/policy/domain_naming_service.cpp:
##########
@@ -78,6 +80,35 @@ int DomainNamingService::GetServers(const char* dns_name,
         return -1;
     }
 
+    if (FLAGS_dnsIPV6) {
+        struct addrinfo hints;
+        struct addrinfo* addrResult;
+        memset(&hints, 0, sizeof(hints));
+        hints.ai_family = AF_INET6;
+        hints.ai_socktype = SOCK_DGRAM;
+        auto ok = getaddrinfo(buf, nullptr, &hints, &addrResult);
+        if (ok != 0) {
+            LOG(WARNING) << "Can't resolve `" << buf << "for ipv6";
+            return -1;

Review Comment:
   Maybe need some fallback
   If ipv6 resolve failed, try ipv4 resolve



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to