mirror of
https://github.com/CherretGit/zaprett-app.git
synced 2025-12-10 05:29:37 +05:00
Compare commits
2 Commits
59e30206f7
...
ad614b3b4a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad614b3b4a | ||
|
|
5c8425573a |
@@ -266,24 +266,18 @@ class ByeDpiVpnService : VpnService() {
|
||||
.flatMap { arg ->
|
||||
if (getHostListMode(sharedPreferences) == "whitelist") {
|
||||
when {
|
||||
arg == "\$hostlist" && list.isNotEmpty() -> listOf("-H", list)
|
||||
arg == "\$hostlist" && list.isNotEmpty() -> listOf("--hosts", list)
|
||||
arg == "\$hostlist" && list.isEmpty() -> emptyList()
|
||||
arg == "\$ipset" && list.isNotEmpty() -> listOf("-H", list)
|
||||
arg == "\$ipset" && list.isNotEmpty() -> listOf("--ipset", list)
|
||||
arg == "\$ipset" && list.isEmpty() -> emptyList()
|
||||
else -> listOf(arg)
|
||||
}
|
||||
} else {
|
||||
if (list.isNotEmpty()) {
|
||||
listOf("-H", list, "-An", arg).filter { it != "\$hostlist" }
|
||||
} else {
|
||||
listOf("-An", arg).filter { it != "\$hostlist" }
|
||||
}
|
||||
if (ipset.isEmpty()) {
|
||||
listOf("-H", list, "-An", arg).filter { it != "\$ipset" }
|
||||
|
||||
}
|
||||
else {
|
||||
listOf("-An", arg).filter { it != "\$ipset" }
|
||||
when {
|
||||
arg == "\$hostlist" && list.isNotEmpty() -> listOf("--hosts", list, "-An", list)
|
||||
arg == "\$ipset" && ipset.isNotEmpty() -> listOf("--ipset", ipset, "-An", ipset)
|
||||
arg == "\$hostlist" || arg == "\$ipset" -> emptyList()
|
||||
else -> listOf(arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ private val json = Json {
|
||||
prettyPrint = true
|
||||
ignoreUnknownKeys = true
|
||||
coerceInputValues = true
|
||||
encodeDefaults = true
|
||||
}
|
||||
|
||||
private fun readConfig(): ZaprettConfig {
|
||||
@@ -78,13 +79,13 @@ fun restartService(callback: (Boolean) -> Unit) {
|
||||
}
|
||||
|
||||
fun getModuleVersion(callback: (String) -> Unit) {
|
||||
Shell.cmd("zaprett module-ver").submit { result ->
|
||||
Shell.cmd("zaprett module-version").submit { result ->
|
||||
if (result.out.isNotEmpty()) callback(result.out.first()) else "undefined"
|
||||
}
|
||||
}
|
||||
|
||||
fun getBinVersion(callback: (String) -> Unit) {
|
||||
Shell.cmd("zaprett bin-ver").submit { result ->
|
||||
Shell.cmd("zaprett binary-version").submit { result ->
|
||||
if (result.out.isNotEmpty()) callback(result.out.first()) else "undefined"
|
||||
}
|
||||
}
|
||||
@@ -95,7 +96,7 @@ fun getConfigFile(): File {
|
||||
|
||||
fun setStartOnBoot(prefs: SharedPreferences, callback: (Boolean) -> Unit) {
|
||||
if (prefs.getBoolean("use_module", false)) {
|
||||
Shell.cmd("zaprett autostart").submit { result ->
|
||||
Shell.cmd("zaprett set-autostart").submit { result ->
|
||||
if (result.out.isNotEmpty() && result.out.toString().contains("true")) callback(true) else callback(false)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user