Skip to content

Commit

Permalink
Additional fix for PR #8678
Browse files Browse the repository at this point in the history
  • Loading branch information
cardigliano committed Aug 28, 2024
1 parent 2258c89 commit da4a5f0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3609,19 +3609,22 @@ void Flow::formatECSHost(json_object *my_object, bool is_client,

/* Adding IP */
if (addr) {
if (is_client && (getPreNATSrcIp() != getPostNATSrcIp()))
use_nat = true;
if (getPreNATSrcIp()) {
tmp_ip.set(getPreNATSrcIp());
if (is_client && (getPreNATSrcIp() != getPostNATSrcIp()))
use_nat = true;
} else {
tmp_ip.set(addr);
}

/* With NAT they are IPv4 */
json_object_object_add(
host_object,
Utils::jsonLabel(
is_client ? (addr->isIPv4() ? IPV4_SRC_ADDR : IPV6_SRC_ADDR)
: (addr->isIPv4() ? IPV4_DST_ADDR : IPV6_DST_ADDR),
is_client ? (tmp_ip.isIPv4() ? IPV4_SRC_ADDR : IPV6_SRC_ADDR)
: (tmp_ip.isIPv4() ? IPV4_DST_ADDR : IPV6_DST_ADDR),
"ip", jsonbuf, sizeof(jsonbuf)),
json_object_new_string(use_nat ? tmp_ip.print(buf, sizeof(buf)) :
addr->print(buf, sizeof(buf))));
json_object_new_string(tmp_ip.print(buf, sizeof(buf))));

/* Custom information elements, Local, Blacklisted, Has Services and
* domain name */
Expand Down

0 comments on commit da4a5f0

Please sign in to comment.