Add core debug flag

This commit is contained in:
problematicconsumer
2023-10-27 17:45:38 +03:30
parent 7a87084b78
commit bf1be7159c
6 changed files with 32 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:hiddify/core/core_providers.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/api/clash_api.dart';
import 'package:hiddify/data/local/dao/dao.dart'; import 'package:hiddify/data/local/dao/dao.dart';
import 'package:hiddify/data/local/database.dart'; import 'package:hiddify/data/local/database.dart';
@@ -61,5 +62,6 @@ CoreFacade coreFacade(CoreFacadeRef ref) => CoreFacadeImpl(
ref.watch(singboxServiceProvider), ref.watch(singboxServiceProvider),
ref.watch(filesEditorServiceProvider), ref.watch(filesEditorServiceProvider),
ref.watch(clashApiProvider), ref.watch(clashApiProvider),
ref.read(debugModeNotifierProvider),
() => ref.read(configOptionsProvider), () => ref.read(configOptionsProvider),
); );

View File

@@ -18,12 +18,14 @@ class CoreFacadeImpl with ExceptionHandler, InfraLogger implements CoreFacade {
this.singbox, this.singbox,
this.filesEditor, this.filesEditor,
this.clash, this.clash,
this.debug,
this.configOptions, this.configOptions,
); );
final SingboxService singbox; final SingboxService singbox;
final FilesEditorService filesEditor; final FilesEditorService filesEditor;
final ClashApi clash; final ClashApi clash;
final bool debug;
final ConfigOptions Function() configOptions; final ConfigOptions Function() configOptions;
bool _initialized = false; bool _initialized = false;
@@ -39,6 +41,7 @@ class CoreFacadeImpl with ExceptionHandler, InfraLogger implements CoreFacade {
filesEditor.dirs.baseDir.path, filesEditor.dirs.baseDir.path,
filesEditor.dirs.workingDir.path, filesEditor.dirs.workingDir.path,
filesEditor.dirs.tempDir.path, filesEditor.dirs.tempDir.path,
debug,
) )
.map((r) { .map((r) {
loggy.debug("setup complete"); loggy.debug("setup complete");

View File

@@ -871,27 +871,33 @@ class SingboxNativeLibrary {
late final _setupOnce = late final _setupOnce =
_setupOncePtr.asFunction<void Function(ffi.Pointer<ffi.Void>)>(); _setupOncePtr.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
void setup( ffi.Pointer<ffi.Char> setup(
ffi.Pointer<ffi.Char> baseDir, ffi.Pointer<ffi.Char> baseDir,
ffi.Pointer<ffi.Char> workingDir, ffi.Pointer<ffi.Char> workingDir,
ffi.Pointer<ffi.Char> tempDir, ffi.Pointer<ffi.Char> tempDir,
int statusPort, int statusPort,
int debug,
) { ) {
return _setup( return _setup(
baseDir, baseDir,
workingDir, workingDir,
tempDir, tempDir,
statusPort, statusPort,
debug,
); );
} }
late final _setupPtr = _lookup< late final _setupPtr = _lookup<
ffi.NativeFunction< ffi.NativeFunction<
ffi.Void Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char> Function(
ffi.Pointer<ffi.Char>, ffi.LongLong)>>('setup'); ffi.Pointer<ffi.Char>,
ffi.Pointer<ffi.Char>,
ffi.Pointer<ffi.Char>,
ffi.LongLong,
GoUint8)>>('setup');
late final _setup = _setupPtr.asFunction< late final _setup = _setupPtr.asFunction<
void Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char> Function(ffi.Pointer<ffi.Char>,
ffi.Pointer<ffi.Char>, int)>(); ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int, int)>();
ffi.Pointer<ffi.Char> parse( ffi.Pointer<ffi.Char> parse(
ffi.Pointer<ffi.Char> path, ffi.Pointer<ffi.Char> path,

View File

@@ -66,18 +66,26 @@ class FFISingboxService
String baseDir, String baseDir,
String workingDir, String workingDir,
String tempDir, String tempDir,
bool debug,
) { ) {
final port = _connectionStatusReceiver.sendPort.nativePort; final port = _connectionStatusReceiver.sendPort.nativePort;
return TaskEither( return TaskEither(
() => CombineWorker().execute( () => CombineWorker().execute(
() { () {
_box.setupOnce(NativeApi.initializeApiDLData); _box.setupOnce(NativeApi.initializeApiDLData);
_box.setup( final err = _box
baseDir.toNativeUtf8().cast(), .setup(
workingDir.toNativeUtf8().cast(), baseDir.toNativeUtf8().cast(),
tempDir.toNativeUtf8().cast(), workingDir.toNativeUtf8().cast(),
port, tempDir.toNativeUtf8().cast(),
); port,
debug ? 1 : 0,
)
.cast<Utf8>()
.toDartString();
if (err.isNotEmpty) {
return left(err);
}
return right(unit); return right(unit);
}, },
), ),

View File

@@ -38,6 +38,7 @@ class MobileSingboxService
String baseDir, String baseDir,
String workingDir, String workingDir,
String tempDir, String tempDir,
bool debug,
) => ) =>
TaskEither.of(unit); TaskEither.of(unit);

View File

@@ -22,6 +22,7 @@ abstract interface class SingboxService {
String baseDir, String baseDir,
String workingDir, String workingDir,
String tempDir, String tempDir,
bool debug,
); );
TaskEither<String, Unit> parseConfig( TaskEither<String, Unit> parseConfig(