fix(plex): validate a failover candidate before switching the live endpoint

A transient GET failure on a healthy endpoint could park the client on an
unreachable fallback (e.g. the server host's Docker bridge gateway, which
plex.tv advertises as a local connection) for a full connect timeout, failing
every request in flight during that window (log bbr90).

The cascade now probes each candidate with an unauthenticated /identity
request under the discovery-race budget and only switches when it answers as
the expected server, mirroring the Jellyfin trust gate. Unreachable-looking
private IPv4 candidates stay in the list — a client on the server host can
legitimately reach them, so reachability is probed, not inferred.
This commit is contained in:
edde746
2026-08-08 12:18:32 +02:00
parent e6be5f9fef
commit 7437b43207
5 changed files with 181 additions and 2 deletions
@@ -149,6 +149,8 @@ PlexClient testPlexClient({
http.Client? httpClient,
Future<http.Response> Function(http.Request request)? handler,
List<String>? prioritizedEndpoints,
http.Client Function()? endpointProbeHttpClientFactory,
void Function()? onAllEndpointsExhausted,
List<({String identifier, String gridEndpoint})> epgProviders = const [],
String? homeHubKey,
String? promotedHubKey,
@@ -163,6 +165,8 @@ PlexClient testPlexClient({
serverName: serverName,
httpClient: httpClient ?? MockClient(handler ?? _defaultResponse),
prioritizedEndpoints: prioritizedEndpoints,
endpointProbeHttpClientFactory: endpointProbeHttpClientFactory,
onAllEndpointsExhausted: onAllEndpointsExhausted,
epgProviders: epgProviders,
homeHubKey: homeHubKey,
promotedHubKey: promotedHubKey,