Add memory limit option

This commit is contained in:
problematicconsumer
2023-10-26 15:16:25 +03:30
parent f85163476d
commit ab4e6f8b77
14 changed files with 90 additions and 27 deletions

View File

@@ -130,12 +130,16 @@ class FFISingboxService
}
@override
TaskEither<String, Unit> start(String configPath) {
TaskEither<String, Unit> start(String configPath, bool disableMemoryLimit) {
loggy.debug("starting, memory limit: [${!disableMemoryLimit}]");
return TaskEither(
() => CombineWorker().execute(
() {
final err = _box
.start(configPath.toNativeUtf8().cast())
.start(
configPath.toNativeUtf8().cast(),
disableMemoryLimit ? 1 : 0,
)
.cast<Utf8>()
.toDartString();
if (err.isNotEmpty) {
@@ -163,12 +167,16 @@ class FFISingboxService
}
@override
TaskEither<String, Unit> restart(String configPath) {
TaskEither<String, Unit> restart(String configPath, bool disableMemoryLimit) {
loggy.debug("restarting, memory limit: [${!disableMemoryLimit}]");
return TaskEither(
() => CombineWorker().execute(
() {
final err = _box
.restart(configPath.toNativeUtf8().cast())
.restart(
configPath.toNativeUtf8().cast(),
disableMemoryLimit ? 1 : 0,
)
.cast<Utf8>()
.toDartString();
if (err.isNotEmpty) {