mirror of
https://github.com/dyhkwong/Exclave.git
synced 2026-07-01 02:15:00 +08:00
Import and export process rules
This commit is contained in:
@@ -187,6 +187,7 @@ class RouteFragment : ToolbarFragment(R.layout.layout_route), Toolbar.OnMenuItem
|
||||
domains = Gson().fromJson(it, Array<String>::class.java).mapNotNull { it.trim().ifBlank { null } }.joinToString("\n")
|
||||
}
|
||||
rawRule.get("ip")?.takeIf { !it.isJsonNull }?.let {
|
||||
// Fuck https://github.com/XTLS/Xray-core/pull/5951, I don't care about it.
|
||||
ip = Gson().fromJson(it, Array<String>::class.java).mapNotNull { it.trim().ifBlank { null } }.joinToString("\n")
|
||||
}
|
||||
port = rawRule.get("port")?.takeIf { !it.isJsonNull }?.asString?.trim() ?: ""
|
||||
@@ -199,6 +200,9 @@ class RouteFragment : ToolbarFragment(R.layout.layout_route), Toolbar.OnMenuItem
|
||||
rawRule.get("protocol")?.takeIf { !it.isJsonNull }?.let {
|
||||
protocol = Gson().fromJson(it, Array<String>::class.java).mapNotNull { it.trim().ifBlank { null } }.joinToString("\n")
|
||||
}
|
||||
rawRule.get("process")?.takeIf { !it.isJsonNull }?.let {
|
||||
packages = Gson().fromJson(it, Array<String>::class.java).mapNotNull { it.trim().ifBlank { null } }
|
||||
}
|
||||
})
|
||||
}
|
||||
if (rules.isNotEmpty()) {
|
||||
@@ -242,7 +246,14 @@ class RouteFragment : ToolbarFragment(R.layout.layout_route), Toolbar.OnMenuItem
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rule.domains.isEmpty() && rule.ip.isEmpty() && rule.port.isEmpty() && protocols.isEmpty) {
|
||||
val processes = JsonArray().apply {
|
||||
if (rule.customPackageNames.isNotEmpty()) {
|
||||
rule.customPackageNames.forEach { if (it.toIntOrNull() != null) add(it) }
|
||||
} else if (rule.packages.isNotEmpty()) {
|
||||
rule.packages.forEach { add(it) }
|
||||
}
|
||||
}
|
||||
if (rule.domains.isEmpty() && rule.ip.isEmpty() && rule.port.isEmpty() && protocols.isEmpty && processes.isEmpty) {
|
||||
continue
|
||||
}
|
||||
jsonArray.add(JsonObject().apply {
|
||||
@@ -279,6 +290,9 @@ class RouteFragment : ToolbarFragment(R.layout.layout_route), Toolbar.OnMenuItem
|
||||
if (!protocols.isEmpty) {
|
||||
add("protocol", protocols)
|
||||
}
|
||||
if (!processes.isEmpty) {
|
||||
add("process", processes)
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!jsonArray.isEmpty) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="license_gpl_v3_only" translatable="false">Copyright (C) 2023 dyhkwong\nCopyright (C) 2021 by nekohasekai <contact-sagernet@sekai.icu>\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.</string>
|
||||
<string name="license_gpl_v3_or_later" translatable="false">Copyright (C) 2023 dyhkwong\nCopyright (C) 2021 by nekohasekai <contact-sagernet@sekai.icu>\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.</string>
|
||||
<string name="license_gpl_v3_only" translatable="false">Copyright (C) 2023\u0020 dyhkwong\nCopyright (C) 2021 by nekohasekai <contact-sagernet@sekai.icu>\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.</string>
|
||||
<string name="license_gpl_v3_or_later" translatable="false">Copyright (C) 2023\u0020 dyhkwong\nCopyright (C) 2021 by nekohasekai <contact-sagernet@sekai.icu>\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user