Skip to content

Commit

Permalink
Merge pull request #272 from MrAnno/otel-ipv6-switch
Browse files Browse the repository at this point in the history
otel/ipv6: respect ipv6 compile switch
  • Loading branch information
alltilla authored Sep 5, 2024
2 parents 365f443 + 038d843 commit 5c9f1a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions modules/grpc/otel/otel-protobuf-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,16 @@ _extract_saddr(const grpc::string &peer)
else
host = peer.substr(first + 1, last - first - 1);

if (ip_version.compare("ipv6") == 0)
if (ip_version.compare("ipv4") == 0)
{
return g_sockaddr_inet6_new(host.c_str(), port);
return g_sockaddr_inet_new(host.c_str(), port);
}
else if (ip_version.compare("ipv4") == 0)
#if SYSLOG_NG_ENABLE_IPV6
else if (ip_version.compare("ipv6") == 0)
{
return g_sockaddr_inet_new(host.c_str(), port);
return g_sockaddr_inet6_new(host.c_str(), port);
}
#endif
}

return NULL;
Expand Down Expand Up @@ -1311,6 +1313,7 @@ syslogng::grpc::otel::ProtobufParser::set_syslog_ng_address(LogMessage *msg, GSo
sin.sin_port = htons(port);
*sa = g_sockaddr_inet_new2(&sin);
}
#if SYSLOG_NG_ENABLE_IPV6
else if (addr_bytes->length() == 16)
{
/* ipv6 */
Expand All @@ -1320,6 +1323,7 @@ syslogng::grpc::otel::ProtobufParser::set_syslog_ng_address(LogMessage *msg, GSo
sin6.sin6_port = htons(port);
*sa = g_sockaddr_inet6_new2(&sin6);
}
#endif
}

void
Expand Down
2 changes: 2 additions & 0 deletions modules/grpc/otel/otel-protobuf-parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#ifndef OTEL_PROTOBUF_PARSER_HPP
#define OTEL_PROTOBUF_PARSER_HPP

#include "syslog-ng.h"

#include "otel-protobuf-parser.h"

#include "compat/cpp-start.h"
Expand Down

0 comments on commit 5c9f1a7

Please sign in to comment.