fix proxy auto start issue

This commit is contained in:
Fabian Freund
2026-05-23 19:20:53 +02:00
parent 696ea84412
commit e34acf2777
20 changed files with 236 additions and 164 deletions
@@ -139,23 +139,6 @@ class SingboxProxyRuntimeRepository extends _$SingboxProxyRuntimeRepository {
});
}
Future<void> ensureProxyConnectionAvailable(
SingboxProxyConnectionId connectionId,
) async {
await _lock.synchronized(() async {
final currentState = await _stateSnapshotUnlocked();
final isRunning = currentState.endpoints.any(
(endpoint) => endpoint.profileId == connectionId.encode(),
);
if (isRunning) return;
final activeProfileIds = _activeProfileIds(currentState);
await _startProfilesUnlocked(
{...activeProfileIds, connectionId.profileId}.toList(),
);
});
}
Set<String> _activeProfileIds(SingboxProxyRuntimeState runtimeState) {
return runtimeState.endpoints
.map((endpoint) => ProxyConnectionId.decode(endpoint.profileId))
@@ -87,7 +87,7 @@ final class SingboxProxyRuntimeRepositoryProvider
}
String _$singboxProxyRuntimeRepositoryHash() =>
r'665908eaff34569f7a19dc5328a067711d1937f2';
r'bb84ab57abd3b7261105da85d3e047cef1b31a44';
abstract class _$SingboxProxyRuntimeRepository
extends $AsyncNotifier<SingboxProxyRuntimeState> {