X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=client.cpp;h=04518c8c2f58a97e9afcd877b77c91863d319bcc;hp=5871da1ed70fb111a85db1bcf278735f64a6b62e;hb=ef7f588a9b7a63ba2153cd06ce5322db4453fa16;hpb=6942bd4c7da1379565817ae82e6ace259abf4492 diff --git a/client.cpp b/client.cpp index 5871da1..04518c8 100644 --- a/client.cpp +++ b/client.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include "client.h" @@ -32,8 +32,19 @@ Client::Client(int sock) if (getpeername(sock, reinterpret_cast(&addr), &addr_len) == -1) { log_perror("getpeername"); remote_addr = ""; + return; + } + + char buf[INET6_ADDRSTRLEN]; + if (IN6_IS_ADDR_V4MAPPED(&addr.sin6_addr)) { + // IPv4 address, really. + if (inet_ntop(AF_INET, &addr.sin6_addr.s6_addr32[3], buf, sizeof(buf)) == NULL) { + log_perror("inet_ntop"); + remote_addr = ""; + } else { + remote_addr = buf; + } } else { - char buf[INET6_ADDRSTRLEN]; if (inet_ntop(addr.sin6_family, &addr.sin6_addr, buf, sizeof(buf)) == NULL) { log_perror("inet_ntop"); remote_addr = ""; @@ -92,7 +103,11 @@ ClientProto Client::serialize() const ClientStats Client::get_stats() const { ClientStats stats; - stats.stream_id = stream_id; + if (stream_id.empty()) { + stats.stream_id = "-"; + } else { + stats.stream_id = stream_id; + } stats.sock = sock; stats.fwmark = fwmark; stats.remote_addr = remote_addr;