mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-23 16:45:27 +01:00
@@ -280,17 +280,33 @@ extension _Actions on _ServerEditPageState {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> tokens;
|
||||
try {
|
||||
tokens = ProxyCommandExecutor.tokenizeCommand(command);
|
||||
} on ProxyCommandException catch (e) {
|
||||
context.showSnackBar(e.message);
|
||||
return;
|
||||
}
|
||||
if (tokens.isEmpty) {
|
||||
context.showSnackBar('ProxyCommand must not be empty');
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine if this requires an executable
|
||||
final parts = command.split(' ');
|
||||
final executable = parts.first;
|
||||
final requiresExecutable = !['ssh', 'nc', 'socat'].contains(executable);
|
||||
final executableToken = tokens.first;
|
||||
var normalized = p.basename(executableToken).toLowerCase();
|
||||
if (normalized.endsWith('.exe')) {
|
||||
normalized = normalized.substring(0, normalized.length - 4);
|
||||
}
|
||||
const builtinExecutables = {'ssh', 'nc', 'socat'};
|
||||
final requiresExecutable = !builtinExecutables.contains(normalized);
|
||||
|
||||
proxyCommand = ProxyCommandConfig(
|
||||
command: command,
|
||||
timeout: Duration(seconds: _proxyCommandTimeout.value),
|
||||
retryOnFailure: true,
|
||||
requiresExecutable: requiresExecutable,
|
||||
executableName: requiresExecutable ? executable : null,
|
||||
executableName: requiresExecutable ? executableToken : null,
|
||||
);
|
||||
} else if (Platform.isIOS && _proxyCommandEnabled.value) {
|
||||
context.showSnackBar('ProxyCommand is not supported on iOS');
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:icons_plus/icons_plus.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:server_box/core/extension/context/locale.dart';
|
||||
import 'package:server_box/core/route.dart';
|
||||
import 'package:server_box/core/utils/proxy_command_executor.dart';
|
||||
|
||||
Reference in New Issue
Block a user