endpoint2hostname() prints a byte-swapped port for IPv6 endpoints
Los mantenedores suelen responder en 2 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 86/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- cpp
- Área
- networking
Línea de trabajo
Empieza en src/butil/details/extended_endpoint.hpp, donde el issue identifica ExtendedEndPoint::to_hostname() y lo compara con ExtendedEndPoint::to(EndPointStr*) justo encima. Comprueba la conversión del puerto IPv6 y añade o ejecuta la prueba unitaria mencionada en el informe. Se considera terminado cuando la salida del nombre de host IPv6 conserva el puerto del endpoint, como ip6-localhost:8080 para [::1]:8080, y la ruta IPv4 existente sigue funcionando correctamente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
butil::endpoint2hostname() of an IPv6 endpoint prints the port in network byte order. For [::1]:8080 it returns ip6-localhost:36895 on x86_64 (8080 = 0x1F90, 36895 = 0x901F). endpoint2str() of the same endpoint prints [::1]:8080, and the IPv4 path of endpoint2hostname() prints the right port.
ExtendedEndPoint::to_hostname() (src/butil/details/extended_endpoint.hpp:318 at 05abb1c3) passes _u.in6.sin6_port to snprintf without ntohs(). ExtendedEndPoint::to(EndPointStr*) a few lines above does call ntohs().
In bRPC itself this affects /connections with -show_hostname_instead_of_ip=true for IPv6 peers (src/brpc/builtin/connections_service.cpp:65-66; taken from the code, the page itself was not exercised).
To Reproduce
The machine needs a reverse name for ::1 (here /etc/hosts maps it to ip6-localhost).
#include <stdio.h>
#include <string>
#include "butil/endpoint.h"
int main() {
butil::EndPoint ep;
if (butil::str2endpoint("[::1]:8080", &ep) != 0) {
return 2;
}
std::string host;
if (butil::endpoint2hostname(ep, &host) != 0) {
printf("::1 has no reverse name on this machine\n");
return 2;
}
printf("endpoint2str : %s\n", butil::endpoint2str(ep).c_str());
printf("endpoint2hostname : %s\n", host.c_str());
return 0;
}
Output on master:
endpoint2str : [::1]:8080
endpoint2hostname : ip6-localhost:36895
Expected behavior
endpoint2str : [::1]:8080
endpoint2hostname : ip6-localhost:8080
Versions
OS: Ubuntu 24.04, x86_64
Compiler: gcc 13.3.0
brpc: master @ 05abb1c3
protobuf: 28.3
Additional context/screenshots
- A PR with the fix (add
ntohs()) and a unit test follows. - This report was prepared with an AI coding assistant (Claude Code, model claude-fable-5-2): the bug was found by reading the code and reproduced with the program above on master @ 05abb1c3 on a Linux x86_64 machine; the output shown is from that run.
- Lenguaje dominante
- C++
- Estrellas
- 17.6k
- Forks
- 4.2k
- Merge medio
- 3 d 17 h
- PR fusionados (30 d)
- 72
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/brpc
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 2 días
-
perf(butil): ARM64 (aarch64) performance and modernisation improvements across atomics, CRC32C, spin-wait hints, and fast timersPosiblemente ocupada @jimmystewpot la tomó hace 2 días. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 12/100
Los mantenedores suelen responder en 2 días
-
file:// naming service takes a comment after the address as the tagPosiblemente ocupada @0z5a la tomó hace 8 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
Los mantenedores suelen responder en 2 días
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Los mantenedores suelen responder en 2 días
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
apache/brpc#3707 · 3 comentarios ·
Los mantenedores suelen responder en 2 días
Todos los issues de apache/brpc
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
protocolbuffers/protobuf#31768 ·
Los mantenedores suelen responder en 1 día
-
Needs: Triage :mag: Platform: Android
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
react/react-native#60167 ·
Los mantenedores suelen responder en 2 días
-
Level format documentationAbiertodocumentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
-
tests: ofx_render_test doesn't compile against FFmpeg 4.x (const AVCodec* to av_find_best_stream)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NatronGitHub/openfx-io#221 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
subsurface/subsurface#5145 ·
Los mantenedores suelen responder en 2 días