0z5a opened a new pull request, #3736:
URL: https://github.com/apache/brpc/pull/3736

   ### What problem does this PR solve?
   
   Issue Number: resolve #3734
   
   Problem Summary:
   
   `butil::endpoint2hostname()` of an IPv6 endpoint prints the port in network 
byte order. `[::1]:8080` gives `ip6-localhost:36895` on little-endian machines, 
while `endpoint2str()` and the IPv4 path print 8080.
   
   `ExtendedEndPoint::to_hostname()` formats `_u.in6.sin6_port` without 
`ntohs()`; `ExtendedEndPoint::to(EndPointStr*)` already converts it. Inside 
bRPC the wrong port shows on `/connections` for IPv6 peers when 
`-show_hostname_instead_of_ip` is on.
   
   ### What is changed and the side effects?
   
   Changed:
   
   - `ExtendedEndPoint::to_hostname()` prints `ntohs(_u.in6.sin6_port)`.
   - New test `EndPointTest.ipv6_endpoint2hostname_port`. It fails on master 
(`ip6-localhost:36895`) and passes with this change. It is skipped when `::1` 
has no reverse name on the machine.
   - Tested: `test_butil --gtest_filter='EndPointTest.*'` passes (23 tests) 
with gcc 13.3, CMake build, on Linux x86_64. The rest of `test_butil`, the make 
and bazel builds, clang and macOS were not run locally.
   - AI disclosure: Claude Code, model claude-fable-5-2; AI was used to find 
the bug, write the reproducer, the fix and the test, run the tests listed 
above, and write the first draft of this description; AI-generated code: the 
`ntohs()` call in `src/butil/details/extended_endpoint.hpp` and the new test in 
`test/endpoint_unittest.cpp`. The commit carries `Generated-by:` as the ASF 
generative tooling guidance recommends.
   
   Side effects:
   - Performance effects: none.
   
   - Breaking backward compatibility: none, apart from the port now being the 
real one.
   
   ---
   ### 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](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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