diff --git a/files/usr/local/bin/apl-aggregator b/files/usr/local/bin/apl-aggregator index 2e42331..4838f5c 100755 --- a/files/usr/local/bin/apl-aggregator +++ b/files/usr/local/bin/apl-aggregator @@ -1052,15 +1052,17 @@ _fr24_acquire_binary() { rm -rf "$tmp" } -# _fr24_write_ini : configure fr24feed as a BEAST-TCP consumer of -# the local decoder with the operator's sharing key (MLAT off, per the -# adapter's FR24-MLAT-default-off contract). +# _fr24_write_ini : configure fr24feed as a BEAST-TCP +# consumer of the local decoder at with the operator's sharing +# key (MLAT off, per the adapter's FR24-MLAT-default-off contract). The address +# is the same AGG_DECODER_ADDR the reachability probe checks, so fr24feed feeds +# from exactly what was verified rather than a separately hardcoded endpoint. _fr24_write_ini() { - local ini="$1" key="$2" tmp + local ini="$1" key="$2" addr="$3" tmp tmp="$(mktemp "${ini}.XXXXXX")" || return 1 if ! cat >"$tmp" </dev/null || true if [[ -n "$key" ]]; then - _fr24_write_ini "$ini" "$key" || { _emit_error state_error "failed to write fr24feed.ini"; exit 3; } + _fr24_write_ini "$ini" "$key" "$AGG_DECODER_ADDR" || { _emit_error state_error "failed to write fr24feed.ini"; exit 3; } else if ! _fr24_signup "$bin" "$ini" "$email" "$lat" "$lon" "$alt"; then _emit_error signup_failed "fr24 signup did not return a sharing key"; exit 2 @@ -1185,7 +1187,7 @@ _enable_fr24() { # The wizard writes its own receiver config (dvbt/auto); overwrite it so the # signup and keyed paths produce identical BEAST-TCP-to-local config. Only # the minted key is kept from the wizard's run. - _fr24_write_ini "$ini" "$key" || { _emit_error state_error "failed to write fr24feed.ini"; exit 3; } + _fr24_write_ini "$ini" "$key" "$AGG_DECODER_ADDR" || { _emit_error state_error "failed to write fr24feed.ini"; exit 3; } fi _fr24_finalize_perms "$ini" diff --git a/test/bats/test_aggregator_enable.bats b/test/bats/test_aggregator_enable.bats index 47bffba..c46d194 100644 --- a/test/bats/test_aggregator_enable.bats +++ b/test/bats/test_aggregator_enable.bats @@ -294,6 +294,17 @@ EOF grep -q 'fr24key="KEYONLY1234"' "$AGG_FR24_INI" } +@test "fr24 ini feeds from the configured decoder address" { + # AGG_DECODER_STATE=up (setup) bypasses the live probe; a non-default + # AGG_DECODER_ADDR must still flow into fr24feed.ini so fr24 feeds from + # exactly the decoder the reachability probe checks. + export AGG_DECODER_ADDR="10.9.8.7:31005" + agg enable '{"id":"fr24","lat":47.0,"lon":8.0,"alt":400,"fields":{"email":"a@b.c","sharing_key":"PROVIDEDKEY1"}}' + [ "$status" -eq 0 ] + grep -q 'host="10.9.8.7:31005"' "$AGG_FR24_INI" + ! grep -q 'host="127.0.0.1:30005"' "$AGG_FR24_INI" +} + @test "enable fails cleanly when the local decoder is unreachable" { export AGG_DECODER_STATE=down agg enable '{"id":"fr24","lat":47.0,"lon":8.0,"alt":400,"fields":{"email":"a@b.c","sharing_key":"VALIDKEY12"}}'