fix: log the real address when a remote http camera on ipv6 fails to connect

This commit is contained in:
singhharsh1708 committed 2026-11-17 03:56:41 +05:30
1 parent fe013898c3
commit d4c5d128dd
1 file changed
+6 -4
+6 -4
View File
@@ -165,10 +165,12 @@ int RemoteCameraHttp::Connect() {
if ( connect( sd, p->ai_addr, p->ai_addrlen ) < 0 ) {
close(sd);
sd = -1;
char buf[INET6_ADDRSTRLEN];
struct sockaddr_in *addr;
addr = (struct sockaddr_in *)p->ai_addr;
inet_ntop(AF_INET, &(addr->sin_addr), buf, sizeof(buf));
char buf[INET6_ADDRSTRLEN] = "n/a";
if (p->ai_family == AF_INET) {
inet_ntop(AF_INET, &((struct sockaddr_in *)p->ai_addr)->sin_addr, buf, sizeof(buf));
} else if (p->ai_family == AF_INET6) {
inet_ntop(AF_INET6, &((struct sockaddr_in6 *)p->ai_addr)->sin6_addr, buf, sizeof(buf));
}
Warning("Can't connect to remote camera mid: %d at %s: %s", monitor->Id(), buf, strerror(errno));
continue;