Add proxy routing and sing-box support
This commit is contained in:
@@ -41,14 +41,13 @@ import 'package:weblibre/features/geckoview/features/tabs/domain/providers.dart'
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/repositories/gecko_inference.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/repositories/tab.dart';
|
||||
import 'package:weblibre/features/geckoview/utils/image_helper.dart';
|
||||
import 'package:weblibre/features/user/data/models/tor_settings.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/tor_settings.dart';
|
||||
import 'package:weblibre/features/user/data/models/proxy_routing_settings.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/proxy_routing_settings.dart';
|
||||
|
||||
part 'tab_state.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class TabStates extends _$TabStates {
|
||||
|
||||
Future<void> _onTabContentStateChange(TabContentState contentState) async {
|
||||
final current = await patchedState(contentState.id);
|
||||
|
||||
@@ -377,25 +376,27 @@ Future<TabState> tabStateWithFallback(Ref ref, String tabId) async {
|
||||
@Riverpod()
|
||||
Future<bool> isTabTunneled(Ref ref, String? tabId) async {
|
||||
final tabState = ref.watch(tabStateProvider(tabId));
|
||||
final torSettings = ref.watch(torSettingsWithDefaultsProvider);
|
||||
final proxyRoutingSettings = ref.watch(
|
||||
proxyRoutingSettingsWithDefaultsProvider,
|
||||
);
|
||||
|
||||
if (tabState != null) {
|
||||
// Isolated tabs follow the same proxy rules as regular tabs
|
||||
// (container-based routing via proxy aliasing)
|
||||
if (tabState.tabMode is PrivateTabMode) {
|
||||
return torSettings.proxyPrivateTabsTor;
|
||||
return proxyRoutingSettings.privateTabsProxyConnectionId != null;
|
||||
} else {
|
||||
switch (torSettings.proxyRegularTabsMode) {
|
||||
case TorRegularTabProxyMode.container:
|
||||
switch (proxyRoutingSettings.regularTabsMode) {
|
||||
case ProxyRegularTabRoutingMode.container:
|
||||
final containerData = await ref
|
||||
.read(tabDataRepositoryProvider.notifier)
|
||||
.getTabContainerData(tabState.id);
|
||||
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
return containerData?.metadata.useProxy ?? false;
|
||||
case TorRegularTabProxyMode.all:
|
||||
return true;
|
||||
return containerData?.metadata.proxyConnectionId != null;
|
||||
case ProxyRegularTabRoutingMode.all:
|
||||
return proxyRoutingSettings.regularTabsProxyConnectionId != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ final class IsTabTunneledProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$isTabTunneledHash() => r'b11134b33ad0c98ffddd14afc2c790fb65735e93';
|
||||
String _$isTabTunneledHash() => r'cb3a3afe5b94f7e9c77d6a32266afbb8a225c259';
|
||||
|
||||
final class IsTabTunneledFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<bool>, String?> {
|
||||
|
||||
@@ -43,7 +43,7 @@ import 'package:weblibre/features/geckoview/features/tabs/data/providers.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/providers/selected_container.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/repositories/container.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/repositories/tab.dart';
|
||||
import 'package:weblibre/features/tor/domain/repositories/tor_proxy.dart';
|
||||
import 'package:weblibre/features/proxy/domain/repositories/container_proxy.dart';
|
||||
import 'package:weblibre/features/user/data/models/general_settings.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/general_settings.dart';
|
||||
import 'package:weblibre/utils/debouncer.dart';
|
||||
@@ -417,7 +417,7 @@ class TabRepository extends _$TabRepository {
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
if (containerData != null) {
|
||||
if (containerData.metadata.useProxy) {
|
||||
if (containerData.metadata.proxyConnectionId != null) {
|
||||
final proxyPluginHealthy = await GeckoContainerProxyService()
|
||||
.healthcheck();
|
||||
|
||||
@@ -711,8 +711,8 @@ class TabRepository extends _$TabRepository {
|
||||
// Best-effort: remove proxy alias (no-op if never set)
|
||||
try {
|
||||
await ref
|
||||
.read(torProxyRepositoryProvider.notifier)
|
||||
.removeContainerProxy(contextId);
|
||||
.read(containerProxyRepositoryProvider.notifier)
|
||||
.clearContainerProxy(contextId);
|
||||
} catch (e, st) {
|
||||
logger.e(
|
||||
'Failed to remove proxy for isolation context $contextId',
|
||||
|
||||
@@ -41,7 +41,7 @@ final class TabRepositoryProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$tabRepositoryHash() => r'ea5caa3c9c4b19898db9de1f77d5476794b8b66f';
|
||||
String _$tabRepositoryHash() => r'2cd5b6bf5bb9a62c05b038b28acef59cecbeae4e';
|
||||
|
||||
abstract class _$TabRepository extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
Reference in New Issue
Block a user