Add core debug flag
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:hiddify/core/core_providers.dart';
|
||||
import 'package:hiddify/core/prefs/general_prefs.dart';
|
||||
import 'package:hiddify/data/api/clash_api.dart';
|
||||
import 'package:hiddify/data/local/dao/dao.dart';
|
||||
import 'package:hiddify/data/local/database.dart';
|
||||
@@ -61,5 +62,6 @@ CoreFacade coreFacade(CoreFacadeRef ref) => CoreFacadeImpl(
|
||||
ref.watch(singboxServiceProvider),
|
||||
ref.watch(filesEditorServiceProvider),
|
||||
ref.watch(clashApiProvider),
|
||||
ref.read(debugModeNotifierProvider),
|
||||
() => ref.read(configOptionsProvider),
|
||||
);
|
||||
|
||||
@@ -18,12 +18,14 @@ class CoreFacadeImpl with ExceptionHandler, InfraLogger implements CoreFacade {
|
||||
this.singbox,
|
||||
this.filesEditor,
|
||||
this.clash,
|
||||
this.debug,
|
||||
this.configOptions,
|
||||
);
|
||||
|
||||
final SingboxService singbox;
|
||||
final FilesEditorService filesEditor;
|
||||
final ClashApi clash;
|
||||
final bool debug;
|
||||
final ConfigOptions Function() configOptions;
|
||||
|
||||
bool _initialized = false;
|
||||
@@ -39,6 +41,7 @@ class CoreFacadeImpl with ExceptionHandler, InfraLogger implements CoreFacade {
|
||||
filesEditor.dirs.baseDir.path,
|
||||
filesEditor.dirs.workingDir.path,
|
||||
filesEditor.dirs.tempDir.path,
|
||||
debug,
|
||||
)
|
||||
.map((r) {
|
||||
loggy.debug("setup complete");
|
||||
|
||||
@@ -871,27 +871,33 @@ class SingboxNativeLibrary {
|
||||
late final _setupOnce =
|
||||
_setupOncePtr.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
|
||||
|
||||
void setup(
|
||||
ffi.Pointer<ffi.Char> setup(
|
||||
ffi.Pointer<ffi.Char> baseDir,
|
||||
ffi.Pointer<ffi.Char> workingDir,
|
||||
ffi.Pointer<ffi.Char> tempDir,
|
||||
int statusPort,
|
||||
int debug,
|
||||
) {
|
||||
return _setup(
|
||||
baseDir,
|
||||
workingDir,
|
||||
tempDir,
|
||||
statusPort,
|
||||
debug,
|
||||
);
|
||||
}
|
||||
|
||||
late final _setupPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Void Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.Char>, ffi.LongLong)>>('setup');
|
||||
ffi.Pointer<ffi.Char> Function(
|
||||
ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.Char>,
|
||||
ffi.LongLong,
|
||||
GoUint8)>>('setup');
|
||||
late final _setup = _setupPtr.asFunction<
|
||||
void Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.Char>, int)>();
|
||||
ffi.Pointer<ffi.Char> Function(ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int, int)>();
|
||||
|
||||
ffi.Pointer<ffi.Char> parse(
|
||||
ffi.Pointer<ffi.Char> path,
|
||||
|
||||
@@ -66,18 +66,26 @@ class FFISingboxService
|
||||
String baseDir,
|
||||
String workingDir,
|
||||
String tempDir,
|
||||
bool debug,
|
||||
) {
|
||||
final port = _connectionStatusReceiver.sendPort.nativePort;
|
||||
return TaskEither(
|
||||
() => CombineWorker().execute(
|
||||
() {
|
||||
_box.setupOnce(NativeApi.initializeApiDLData);
|
||||
_box.setup(
|
||||
baseDir.toNativeUtf8().cast(),
|
||||
workingDir.toNativeUtf8().cast(),
|
||||
tempDir.toNativeUtf8().cast(),
|
||||
port,
|
||||
);
|
||||
final err = _box
|
||||
.setup(
|
||||
baseDir.toNativeUtf8().cast(),
|
||||
workingDir.toNativeUtf8().cast(),
|
||||
tempDir.toNativeUtf8().cast(),
|
||||
port,
|
||||
debug ? 1 : 0,
|
||||
)
|
||||
.cast<Utf8>()
|
||||
.toDartString();
|
||||
if (err.isNotEmpty) {
|
||||
return left(err);
|
||||
}
|
||||
return right(unit);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -38,6 +38,7 @@ class MobileSingboxService
|
||||
String baseDir,
|
||||
String workingDir,
|
||||
String tempDir,
|
||||
bool debug,
|
||||
) =>
|
||||
TaskEither.of(unit);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ abstract interface class SingboxService {
|
||||
String baseDir,
|
||||
String workingDir,
|
||||
String tempDir,
|
||||
bool debug,
|
||||
);
|
||||
|
||||
TaskEither<String, Unit> parseConfig(
|
||||
|
||||
Reference in New Issue
Block a user