Skip to content

Commit

Permalink
for idaholab#560 (see also idaholab#559), slight tweak to handle when…
Browse files Browse the repository at this point in the history
… OS_HOST is not an IP address already
  • Loading branch information
mmguero committed Sep 11, 2024
1 parent ba4a7e9 commit c6f66a8
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,16 @@ if [[ -n $SUPERVISOR_PATH ]] && [[ -r "$SUPERVISOR_PATH"/arkime/config.ini ]]; t
fi

# identify node in session metadata for PCAP reachback
if [[ -n $OS_HOST ]]; then
PRIMARY_IP=$(ip route get $OS_HOST | grep -Po '(?<=src )(\d{1,3}.){4}' | sed "s/ //g")
else
PRIMARY_IP=$(ip route get 255.255.255.255 | grep -Po '(?<=src )(\d{1,3}.){4}' | sed "s/ //g")
ROUTE_DEST_IP=
if [[ -n "$OS_HOST" ]]; then
if [[ "$OS_HOST" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
ROUTE_DEST_IP="$OS_HOST"
else
ROUTE_DEST_IP=$(dig +short "$OS_HOST" 2>/dev/null | head -n 1)
fi
fi
[[ -n "$ROUTE_DEST_IP" ]] || ROUTE_DEST_IP=255.255.255.255
PRIMARY_IP=$(ip route get "$ROUTE_DEST_IP" | grep -Po '(?<=src )(\d{1,3}.){4}' | sed "s/ //g")
export ARKIME_NODE_NAME="$(hostname --long)"
export ARKIME_NODE_HOST="$PRIMARY_IP"

Expand Down

0 comments on commit c6f66a8

Please sign in to comment.