fix: custom client, option to bool (#8303)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2024-06-10 11:01:39 +08:00
committed by GitHub
parent 32ab56f864
commit 9ab5512bfa
8 changed files with 32 additions and 30 deletions

View File

@@ -1430,7 +1430,7 @@ bool option2bool(String option, String value) {
if (option.startsWith("enable-")) {
res = value != "N";
} else if (option.startsWith("allow-") ||
option == "stop-service" ||
option == kOptionStopService ||
option == kOptionDirectServer ||
option == "stop-rendezvous-service" ||
option == kOptionForceAlwaysRelay) {
@@ -1447,7 +1447,7 @@ String bool2option(String option, bool b) {
if (option.startsWith('enable-')) {
res = b ? defaultOptionYes : 'N';
} else if (option.startsWith('allow-') ||
option == "stop-service" ||
option == kOptionStopService ||
option == kOptionDirectServer ||
option == "stop-rendezvous-service" ||
option == kOptionForceAlwaysRelay) {
@@ -1485,9 +1485,9 @@ bool mainGetPeerBoolOptionSync(String id, String key) {
return option2bool(key, bind.mainGetPeerOptionSync(id: id, key: key));
}
mainSetPeerBoolOptionSync(String id, String key, bool v) {
bind.mainSetPeerOptionSync(id: id, key: key, value: bool2option(key, v));
}
// Don't use `option2bool()` and `bool2option()` to convert the session option.
// Use `sessionGetToggleOption()` and `sessionToggleOption()` instead.
// Because all session options use `Y` and `<Empty>` as values.
Future<bool> matchPeer(String searchText, Peer peer) async {
if (searchText.isEmpty) {
@@ -2672,7 +2672,7 @@ Future<void> start_service(bool is_start) async {
!isMacOS ||
await callMainCheckSuperUserPermission();
if (checked) {
bind.mainSetOption(key: "stop-service", value: is_start ? "" : "Y");
mainSetBoolOption(kOptionStopService, !is_start);
}
}