079924d19a
- Removing the primary machine hands pipelines/runs to the next saved machine on native hosts; removing the last machine returns to the connect screen instead of stranding the app on "Server endpoint not configured". - Add server probes the new machine and asks for its own password in the same page; Settings rows show Connected / Sign in required / Unreachable with the reason and offer Sign in; no other machine's credential is ever reused. - Unreachable addresses explain why: a TLS failure against an IP points at the Tailscale name, a non-Pipelines answer points at the port. - Discovered machines list every advertised route (LAN, Tailscale IP, Tailscale name) as a checklist; chosen routes are saved as one machine. - tool/connection_probe.dart replays the native login and websocket against real addresses for diagnosis.
42 lines
1.5 KiB
Dart
42 lines
1.5 KiB
Dart
import '../session/server_session.dart';
|
|
|
|
/// Probes one address and reports its session state with a reason.
|
|
typedef ServerProbe = Future<ServerProbeResult> Function(Uri endpoint);
|
|
|
|
/// Adapts a plain state check to a [ServerProbe] without reasons.
|
|
ServerProbe probeFromCheck(Future<SessionState> Function(Uri) check) =>
|
|
(uri) async => ServerProbeResult(await check(uri));
|
|
|
|
/// Probe only the selected profile's explicit aliases, with a bounded wait.
|
|
/// Never send a mutation or discover/switch logical servers. When every
|
|
/// address is unreachable the first address and its reason are returned.
|
|
Future<({Uri endpoint, SessionState state, String? reason})>
|
|
probeServerAddresses(
|
|
List<Uri> addresses, {
|
|
required ServerProbe probe,
|
|
required bool Function() isCurrent,
|
|
}) async {
|
|
if (addresses.isEmpty) throw ArgumentError('No server addresses to probe.');
|
|
String? reason;
|
|
for (final endpoint in addresses) {
|
|
if (!isCurrent()) break;
|
|
final result = await probe(endpoint).timeout(
|
|
const Duration(seconds: 12),
|
|
onTimeout: () => ServerProbeResult(
|
|
SessionState.unreachable,
|
|
reason: 'Could not reach ${endpoint.host}: no answer in time.',
|
|
),
|
|
);
|
|
if (!isCurrent()) break;
|
|
if (result.state != SessionState.unreachable) {
|
|
return (endpoint: endpoint, state: result.state, reason: null);
|
|
}
|
|
reason ??= result.reason;
|
|
}
|
|
return (
|
|
endpoint: addresses.first,
|
|
state: SessionState.unreachable,
|
|
reason: reason,
|
|
);
|
|
}
|