diff --git a/lib/core/utils/proxy_command_executor.dart b/lib/core/utils/proxy_command_executor.dart index 5f4d291b..739d6a0b 100644 --- a/lib/core/utils/proxy_command_executor.dart +++ b/lib/core/utils/proxy_command_executor.dart @@ -33,6 +33,10 @@ abstract final class ProxyCommandExecutor { required int port, required String user, }) async { + if (Platform.isIOS) { + throw ProxyCommandException(message: 'ProxyCommand is not supported on iOS'); + } + final finalCommand = config.getFinalCommand(hostname: hostname, port: port, user: user); Loggers.app.info('Executing proxy command: $finalCommand'); @@ -99,6 +103,10 @@ abstract final class ProxyCommandExecutor { /// Validate proxy command configuration static Future validateConfig(ProxyCommandConfig config) async { + if (Platform.isIOS) { + return 'ProxyCommand is not supported on iOS'; + } + final testCommand = config.getFinalCommand(hostname: 'test.example.com', port: 22, user: 'testuser'); // Check if required placeholders are present diff --git a/lib/core/utils/server.dart b/lib/core/utils/server.dart index 86b9b42d..c44abefa 100644 --- a/lib/core/utils/server.dart +++ b/lib/core/utils/server.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:convert'; +import 'dart:io'; import 'package:dartssh2/dartssh2.dart'; import 'package:fl_lib/fl_lib.dart'; @@ -122,24 +123,27 @@ Future genClient( // For ProxyCommand and direct connections, get SSHSocket SSHSocket? socket; try { + final proxyCommand = spi.proxyCommand; // ProxyCommand support - Check for ProxyCommand configuration first - if (spi.proxyCommand != null) { + if (proxyCommand != null && !Platform.isIOS) { try { - Loggers.app.info('Connecting via ProxyCommand: ${spi.proxyCommand!.command}'); + Loggers.app.info('Connecting via ProxyCommand: ${proxyCommand.command}'); socket = await ProxyCommandExecutor.executeProxyCommand( - spi.proxyCommand!, + proxyCommand, hostname: spi.ip, port: spi.port, user: spi.user, ); } catch (e) { Loggers.app.warning('ProxyCommand failed', e); - if (!spi.proxyCommand!.retryOnFailure) { + if (!proxyCommand.retryOnFailure) { rethrow; } // If retry is enabled, fall through to direct connection Loggers.app.info('ProxyCommand failed, falling back to direct connection'); } + } else if (proxyCommand != null && Platform.isIOS) { + Loggers.app.info('ProxyCommand configuration is ignored on iOS'); } // Direct connection (or fallback) diff --git a/lib/view/page/server/edit/actions.dart b/lib/view/page/server/edit/actions.dart index aed02823..e1c4e0d0 100644 --- a/lib/view/page/server/edit/actions.dart +++ b/lib/view/page/server/edit/actions.dart @@ -267,7 +267,7 @@ extension _Actions on _ServerEditPageState { // ProxyCommand configuration ProxyCommandConfig? proxyCommand; - if (_proxyCommandEnabled.value) { + if (!Platform.isIOS && _proxyCommandEnabled.value) { final command = _proxyCommandController.text.trim(); if (command.isEmpty) { context.showSnackBar('ProxyCommand is enabled but command is empty'); @@ -292,6 +292,9 @@ extension _Actions on _ServerEditPageState { requiresExecutable: requiresExecutable, executableName: requiresExecutable ? executable : null, ); + } else if (Platform.isIOS && _proxyCommandEnabled.value) { + context.showSnackBar('ProxyCommand is not supported on iOS'); + return; } final spi = Spi( @@ -483,7 +486,7 @@ extension _Utils on _ServerEditPageState { // Load ProxyCommand configuration final proxyCommand = spi.proxyCommand; - if (proxyCommand != null) { + if (proxyCommand != null && !Platform.isIOS) { _proxyCommandEnabled.value = true; _proxyCommandController.text = proxyCommand.command; _proxyCommandTimeout.value = proxyCommand.timeout.inSeconds; @@ -502,5 +505,12 @@ extension _Utils on _ServerEditPageState { _proxyCommandTimeout.value = 30; _proxyCommandPreset.value = null; } + + if (Platform.isIOS) { + _proxyCommandEnabled.value = false; + _proxyCommandController.text = ''; + _proxyCommandTimeout.value = 30; + _proxyCommandPreset.value = null; + } } } diff --git a/lib/view/page/server/edit/widget.dart b/lib/view/page/server/edit/widget.dart index 0c5c4d2b..b7be3ab1 100644 --- a/lib/view/page/server/edit/widget.dart +++ b/lib/view/page/server/edit/widget.dart @@ -450,6 +450,14 @@ extension _Widgets on _ServerEditPageState { } Widget _buildProxyCommand() { + if (Platform.isIOS) { + return ListTile( + title: const Text('ProxyCommand'), + subtitle: const Text('ProxyCommand is not available on iOS'), + trailing: const Icon(Icons.block, color: Colors.grey), + ); + } + return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [