Skip to content

Commit c20c22b

Browse files
committed
fix(aggregator): feed fr24 from the probed decoder address
fr24feed.ini hardcoded host=127.0.0.1:30005 while the reachability probe checks AGG_DECODER_ADDR (which the piaware path already honors). Pass the probed address into the ini writer so fr24 feeds from exactly the decoder that was verified.
1 parent a513cd6 commit c20c22b

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

files/usr/local/bin/apl-aggregator

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,15 +1052,17 @@ _fr24_acquire_binary() {
10521052
rm -rf "$tmp"
10531053
}
10541054

1055-
# _fr24_write_ini <ini> <key>: configure fr24feed as a BEAST-TCP consumer of
1056-
# the local decoder with the operator's sharing key (MLAT off, per the
1057-
# adapter's FR24-MLAT-default-off contract).
1055+
# _fr24_write_ini <ini> <key> <decoder-addr>: configure fr24feed as a BEAST-TCP
1056+
# consumer of the local decoder at <decoder-addr> with the operator's sharing
1057+
# key (MLAT off, per the adapter's FR24-MLAT-default-off contract). The address
1058+
# is the same AGG_DECODER_ADDR the reachability probe checks, so fr24feed feeds
1059+
# from exactly what was verified rather than a separately hardcoded endpoint.
10581060
_fr24_write_ini() {
1059-
local ini="$1" key="$2" tmp
1061+
local ini="$1" key="$2" addr="$3" tmp
10601062
tmp="$(mktemp "${ini}.XXXXXX")" || return 1
10611063
if ! cat >"$tmp" <<EOF
10621064
receiver="beast-tcp"
1063-
host="127.0.0.1:30005"
1065+
host="$addr"
10641066
fr24key="$key"
10651067
bs="no"
10661068
raw="no"
@@ -1175,7 +1177,7 @@ _enable_fr24() {
11751177
_worker_progress configuring
11761178
install -d -m 0750 "$(dirname "$ini")" 2>/dev/null || true
11771179
if [[ -n "$key" ]]; then
1178-
_fr24_write_ini "$ini" "$key" || { _emit_error state_error "failed to write fr24feed.ini"; exit 3; }
1180+
_fr24_write_ini "$ini" "$key" "$AGG_DECODER_ADDR" || { _emit_error state_error "failed to write fr24feed.ini"; exit 3; }
11791181
else
11801182
if ! _fr24_signup "$bin" "$ini" "$email" "$lat" "$lon" "$alt"; then
11811183
_emit_error signup_failed "fr24 signup did not return a sharing key"; exit 2
@@ -1185,7 +1187,7 @@ _enable_fr24() {
11851187
# The wizard writes its own receiver config (dvbt/auto); overwrite it so the
11861188
# signup and keyed paths produce identical BEAST-TCP-to-local config. Only
11871189
# the minted key is kept from the wizard's run.
1188-
_fr24_write_ini "$ini" "$key" || { _emit_error state_error "failed to write fr24feed.ini"; exit 3; }
1190+
_fr24_write_ini "$ini" "$key" "$AGG_DECODER_ADDR" || { _emit_error state_error "failed to write fr24feed.ini"; exit 3; }
11891191
fi
11901192
_fr24_finalize_perms "$ini"
11911193

test/bats/test_aggregator_enable.bats

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,17 @@ EOF
294294
grep -q 'fr24key="KEYONLY1234"' "$AGG_FR24_INI"
295295
}
296296

297+
@test "fr24 ini feeds from the configured decoder address" {
298+
# AGG_DECODER_STATE=up (setup) bypasses the live probe; a non-default
299+
# AGG_DECODER_ADDR must still flow into fr24feed.ini so fr24 feeds from
300+
# exactly the decoder the reachability probe checks.
301+
export AGG_DECODER_ADDR="10.9.8.7:31005"
302+
agg enable '{"id":"fr24","lat":47.0,"lon":8.0,"alt":400,"fields":{"email":"a@b.c","sharing_key":"PROVIDEDKEY1"}}'
303+
[ "$status" -eq 0 ]
304+
grep -q 'host="10.9.8.7:31005"' "$AGG_FR24_INI"
305+
! grep -q 'host="127.0.0.1:30005"' "$AGG_FR24_INI"
306+
}
307+
297308
@test "enable fails cleanly when the local decoder is unreachable" {
298309
export AGG_DECODER_STATE=down
299310
agg enable '{"id":"fr24","lat":47.0,"lon":8.0,"alt":400,"fields":{"email":"a@b.c","sharing_key":"VALIDKEY12"}}'

0 commit comments

Comments
 (0)