You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by "jsl422 (via GitHub)" <gi...@apache.org> on 2023/02/28 03:47:16 UTC

[PR] feat: dns resolve support ipv6 (brpc)

jsl422 opened a new pull request, #2139:
URL: https://github.com/apache/brpc/pull/2139

   ### What problem does this PR solve?
   
   Issue Number:
   
   Problem Summary:
   
   ### What is changed and the side effects?
   
   Changed:
   
   Side effects:
   - Performance effects(性能影响):
   
   - Breaking backward compatibility(向后兼容性): 
   
   ---
   ### Check List:
   - Please make sure your changes are compilable(请确保你的更改可以通过编译).
   - When providing us with a new feature, it is best to add related tests(如果你向我们增加一个新的功能, 请添加相关测试).
   - Please follow [Contributor Covenant Code of Conduct](../../master/CODE_OF_CONDUCT.md).(请遵循贡献者准则).
   


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [PR] feat: dns resolve support ipv6 (brpc)

Posted by "jamesge (via GitHub)" <gi...@apache.org>.
jamesge merged PR #2139:
URL: https://github.com/apache/brpc/pull/2139


-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [PR] feat: dns resolve support ipv6 (brpc)

Posted by "jamesge (via GitHub)" <gi...@apache.org>.
jamesge commented on code in PR #2139:
URL: https://github.com/apache/brpc/pull/2139#discussion_r1119597368


##########
src/brpc/policy/domain_naming_service.cpp:
##########
@@ -96,7 +96,10 @@ int DomainNamingService::GetServers(const char* dns_name,
         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);
+            auto ret = inet_ntop(AF_INET6, &a->sin6_addr, straddr + 1, INET6_ADDRSTRLEN);
+            if(ret == nullptr) {
+                continue;

Review Comment:
   需要报错



-- 
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [PR] feat: dns resolve support ipv6 (brpc)

Posted by "wwbmmm (via GitHub)" <gi...@apache.org>.
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: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org