Add export config to clipboard
This commit is contained in:
@@ -5,6 +5,7 @@ import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
|
||||
import 'package:combine/combine.dart';
|
||||
import 'package:dartx/dartx.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:hiddify/domain/connectivity/connectivity.dart';
|
||||
@@ -137,6 +138,28 @@ class FFISingboxService
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
TaskEither<String, String> generateConfig(
|
||||
String path,
|
||||
) {
|
||||
return TaskEither(
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
final response = _box
|
||||
.generateConfig(
|
||||
path.toNativeUtf8().cast(),
|
||||
)
|
||||
.cast<Utf8>()
|
||||
.toDartString();
|
||||
if (response.startsWith("error")) {
|
||||
return left(response.removePrefix("error"));
|
||||
}
|
||||
return right(response);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
TaskEither<String, Unit> start(String configPath, bool disableMemoryLimit) {
|
||||
loggy.debug("starting, memory limit: [${!disableMemoryLimit}]");
|
||||
|
||||
@@ -73,6 +73,24 @@ class MobileSingboxService
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
TaskEither<String, String> generateConfig(
|
||||
String path,
|
||||
) {
|
||||
return TaskEither(
|
||||
() async {
|
||||
final configJson = await _methodChannel.invokeMethod<String>(
|
||||
"generate_config",
|
||||
{"path": path},
|
||||
);
|
||||
if (configJson == null || configJson.isEmpty) {
|
||||
return left("null response");
|
||||
}
|
||||
return right(configJson);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
TaskEither<String, Unit> start(String configPath, bool disableMemoryLimit) {
|
||||
return TaskEither(
|
||||
|
||||
@@ -33,6 +33,10 @@ abstract interface class SingboxService {
|
||||
|
||||
TaskEither<String, Unit> changeConfigOptions(ConfigOptions options);
|
||||
|
||||
TaskEither<String, String> generateConfig(
|
||||
String path,
|
||||
);
|
||||
|
||||
TaskEither<String, Unit> start(String configPath, bool disableMemoryLimit);
|
||||
|
||||
TaskEither<String, Unit> stop();
|
||||
|
||||
Reference in New Issue
Block a user