dev custom rule config

This commit is contained in:
armv9 2025-09-03 17:14:08 +09:00
parent 0127c60906
commit 7c46729c83
9 changed files with 520 additions and 81 deletions

View File

@ -0,0 +1,373 @@
{
"formatVersion": 1,
"database": {
"version": 6,
"identityHash": "3d3db9106a89d6f20ef3fde6e81dbaa9",
"entities": [
{
"tableName": "proxy_groups",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `userOrder` INTEGER NOT NULL, `ungrouped` INTEGER NOT NULL, `name` TEXT, `type` INTEGER NOT NULL, `subscription` BLOB, `order` INTEGER NOT NULL, `isSelector` INTEGER NOT NULL, `frontProxy` INTEGER NOT NULL, `landingProxy` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "userOrder",
"columnName": "userOrder",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "ungrouped",
"columnName": "ungrouped",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "subscription",
"columnName": "subscription",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "order",
"columnName": "order",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "isSelector",
"columnName": "isSelector",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "frontProxy",
"columnName": "frontProxy",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "landingProxy",
"columnName": "landingProxy",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "proxy_entities",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `groupId` INTEGER NOT NULL, `type` INTEGER NOT NULL, `userOrder` INTEGER NOT NULL, `tx` INTEGER NOT NULL, `rx` INTEGER NOT NULL, `status` INTEGER NOT NULL, `ping` INTEGER NOT NULL, `uuid` TEXT NOT NULL, `error` TEXT, `socksBean` BLOB, `httpBean` BLOB, `ssBean` BLOB, `vmessBean` BLOB, `trojanBean` BLOB, `trojanGoBean` BLOB, `mieruBean` BLOB, `naiveBean` BLOB, `hysteriaBean` BLOB, `tuicBean` BLOB, `sshBean` BLOB, `wgBean` BLOB, `shadowTLSBean` BLOB, `anyTLSBean` BLOB, `chainBean` BLOB, `nekoBean` BLOB, `configBean` BLOB)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "groupId",
"columnName": "groupId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "userOrder",
"columnName": "userOrder",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "tx",
"columnName": "tx",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "rx",
"columnName": "rx",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "status",
"columnName": "status",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "ping",
"columnName": "ping",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "uuid",
"columnName": "uuid",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "error",
"columnName": "error",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "socksBean",
"columnName": "socksBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "httpBean",
"columnName": "httpBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "ssBean",
"columnName": "ssBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "vmessBean",
"columnName": "vmessBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "trojanBean",
"columnName": "trojanBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "trojanGoBean",
"columnName": "trojanGoBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "mieruBean",
"columnName": "mieruBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "naiveBean",
"columnName": "naiveBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "hysteriaBean",
"columnName": "hysteriaBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "tuicBean",
"columnName": "tuicBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "sshBean",
"columnName": "sshBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "wgBean",
"columnName": "wgBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "shadowTLSBean",
"columnName": "shadowTLSBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "anyTLSBean",
"columnName": "anyTLSBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "chainBean",
"columnName": "chainBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "nekoBean",
"columnName": "nekoBean",
"affinity": "BLOB",
"notNull": false
},
{
"fieldPath": "configBean",
"columnName": "configBean",
"affinity": "BLOB",
"notNull": false
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [
{
"name": "groupId",
"unique": false,
"columnNames": [
"groupId"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `groupId` ON `${TABLE_NAME}` (`groupId`)"
}
],
"foreignKeys": []
},
{
"tableName": "rules",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `config` TEXT NOT NULL DEFAULT '', `userOrder` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, `domains` TEXT NOT NULL, `ip` TEXT NOT NULL, `port` TEXT NOT NULL, `sourcePort` TEXT NOT NULL, `network` TEXT NOT NULL, `source` TEXT NOT NULL, `protocol` TEXT NOT NULL, `outbound` INTEGER NOT NULL, `packages` TEXT NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "config",
"columnName": "config",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "''"
},
{
"fieldPath": "userOrder",
"columnName": "userOrder",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "enabled",
"columnName": "enabled",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "domains",
"columnName": "domains",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "ip",
"columnName": "ip",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "port",
"columnName": "port",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "sourcePort",
"columnName": "sourcePort",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "network",
"columnName": "network",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "source",
"columnName": "source",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "protocol",
"columnName": "protocol",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "outbound",
"columnName": "outbound",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "packages",
"columnName": "packages",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '3d3db9106a89d6f20ef3fde6e81dbaa9')"
]
}
}

View File

@ -12,6 +12,8 @@ import kotlinx.parcelize.Parcelize
data class RuleEntity(
@PrimaryKey(autoGenerate = true) var id: Long = 0L,
var name: String = "",
@ColumnInfo(defaultValue = "")
var config: String = "",
var userOrder: Long = 0L,
var enabled: Boolean = false,
var domains: String = "",
@ -31,11 +33,12 @@ data class RuleEntity(
fun mkSummary(): String {
var summary = ""
if (config.isNotBlank()) summary += "[config]\n"
if (domains.isNotBlank()) summary += "$domains\n"
if (ip.isNotBlank()) summary += "$ip\n"
if (source.isNotBlank()) summary += "source: $source\n"
if (sourcePort.isNotBlank()) summary += "sourcePort: $sourcePort\n"
if (port.isNotBlank()) summary += "port: $port\n"
if (source.isNotBlank()) summary += "src ip: $source\n"
if (sourcePort.isNotBlank()) summary += "src port: $sourcePort\n"
if (port.isNotBlank()) summary += "dst port: $port\n"
if (network.isNotBlank()) summary += "network: $network\n"
if (protocol.isNotBlank()) summary += "protocol: $protocol\n"
if (packages.isNotEmpty()) summary += app.getString(

View File

@ -16,7 +16,7 @@ import kotlinx.coroutines.launch
@Database(
entities = [ProxyGroup::class, ProxyEntity::class, RuleEntity::class],
version = 5,
version = 6,
autoMigrations = [
AutoMigration(from = 3, to = 4),
AutoMigration(from = 4, to = 5)

View File

@ -35,7 +35,6 @@ import moe.matsuri.nb4a.proxy.config.ConfigBean
import moe.matsuri.nb4a.proxy.shadowtls.ShadowTLSBean
import moe.matsuri.nb4a.proxy.shadowtls.buildSingBoxOutboundShadowTLSBean
import moe.matsuri.nb4a.utils.JavaUtil.gson
import moe.matsuri.nb4a.utils.Util
import moe.matsuri.nb4a.utils.listByLineOrComma
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
@ -82,7 +81,6 @@ fun buildConfig(
val globalOutbounds = HashMap<Long, String>()
val selectorNames = ArrayList<String>()
val group = SagerDatabase.groupDao.getById(proxy.groupId)
val optionsToMerge = proxy.requireBean().customConfigJson ?: ""
fun ProxyEntity.resolveChainInternal(): MutableList<ProxyEntity> {
val bean = requireBean()
@ -255,13 +253,13 @@ fun buildConfig(
add(entity)
}
var currentOutbound = mutableMapOf<String, Any>()
lateinit var pastOutbound: MutableMap<String, Any>
var currentOutbound: SingBoxOption
lateinit var pastOutbound: SingBoxOption
lateinit var pastInboundTag: String
var pastEntity: ProxyEntity? = null
val externalChainMap = LinkedHashMap<Int, ProxyEntity>()
externalIndexMap.add(IndexEntity(externalChainMap))
val chainOutbounds = ArrayList<MutableMap<String, Any>>()
val chainOutbounds = ArrayList<SingBoxOption>()
// chainTagOut: v2ray outbound tag for this chain
var chainTagOut = ""
@ -309,7 +307,7 @@ fun buildConfig(
outbound = tagOut
})
} else {
pastOutbound["detour"] = tagOut
pastOutbound._hack_config_map["detour"] = tagOut
}
} else {
// index == 0 means last profile in chain / not chain
@ -332,53 +330,51 @@ fun buildConfig(
type = "socks"
server = LOCALHOST
server_port = localPort
}.asMap()
} else { // internal outbound
}
} else {
// internal outbound
currentOutbound = when (bean) {
is ConfigBean ->
gson.fromJson(bean.config, currentOutbound.javaClass)
is ConfigBean -> SingBoxOption().apply {
_hack_custom_config = bean.config
}
is ShadowTLSBean -> // before StandardV2RayBean
buildSingBoxOutboundShadowTLSBean(bean).asMap()
buildSingBoxOutboundShadowTLSBean(bean)
is StandardV2RayBean -> // http/trojan/vmess/vless
buildSingBoxOutboundStandardV2RayBean(bean).asMap()
buildSingBoxOutboundStandardV2RayBean(bean)
is HysteriaBean ->
buildSingBoxOutboundHysteriaBean(bean)
is TuicBean ->
buildSingBoxOutboundTuicBean(bean).asMap()
buildSingBoxOutboundTuicBean(bean)
is SOCKSBean ->
buildSingBoxOutboundSocksBean(bean).asMap()
buildSingBoxOutboundSocksBean(bean)
is ShadowsocksBean ->
buildSingBoxOutboundShadowsocksBean(bean).asMap()
buildSingBoxOutboundShadowsocksBean(bean)
is WireGuardBean ->
buildSingBoxOutboundWireguardBean(bean).asMap()
buildSingBoxOutboundWireguardBean(bean)
is SSHBean ->
buildSingBoxOutboundSSHBean(bean).asMap()
buildSingBoxOutboundSSHBean(bean)
is AnyTLSBean ->
buildSingBoxOutboundAnyTLSBean(bean).asMap()
buildSingBoxOutboundAnyTLSBean(bean)
else -> throw IllegalStateException("can't reach")
}
currentOutbound.apply {
// TODO nb4a keepAliveInterval?
// val keepAliveInterval = DataStore.tcpKeepAliveInterval
// val needKeepAliveInterval = keepAliveInterval !in intArrayOf(0, 15)
} as SingBoxOption
// internal mux
if (!muxApplied) {
val muxObj = proxyEntity.singMux()
if (muxObj != null && muxObj.enabled) {
muxApplied = true
currentOutbound["multiplex"] = muxObj.asMap()
}
currentOutbound._hack_config_map["multiplex"] = muxObj.asMap()
}
}
}
@ -388,8 +384,8 @@ fun buildConfig(
// udp over tcp
try {
val sUoT = bean.javaClass.getField("sUoT").get(bean)
if (sUoT is Boolean && sUoT == true) {
currentOutbound["udp_over_tcp"] = true
if (sUoT is Boolean && sUoT) {
_hack_config_map["udp_over_tcp"] = true
}
} catch (_: Exception) {
}
@ -401,19 +397,13 @@ fun buildConfig(
domainListDNSDirectForce.add("full:$serverAddress")
}
}
currentOutbound["domain_strategy"] =
_hack_config_map["domain_strategy"] =
if (forTest) "" else defaultServerDomainStrategy
// custom JSON merge
if (bean.customOutboundJson.isNotBlank()) {
Util.mergeJSON(
bean.customOutboundJson,
currentOutbound as MutableMap<String, Any?>
)
}
}
_hack_config_map["tag"] = tagOut
currentOutbound["tag"] = tagOut
_hack_custom_config = bean.customOutboundJson
}
// External proxy need a dokodemo-door inbound to forward the traffic
// For external proxy software, their traffic must goes to v2ray-core to use protected fd.
@ -472,8 +462,8 @@ fun buildConfig(
// build outbounds
if (buildSelector) {
val list = group?.id?.let { SagerDatabase.proxyDao.getByGroup(it) }
list?.forEach {
val list = group.id.let { SagerDatabase.proxyDao.getByGroup(it) }
list.forEach {
tagMap[it.id] = buildChain(it.id, it)
}
outbounds.add(0, Outbound_SelectorOptions().apply {
@ -481,7 +471,7 @@ fun buildConfig(
tag = TAG_PROXY
default_ = tagMap[proxy.id]
outbounds = tagMap.values.toList()
}.asMap())
})
} else {
buildChain(0, proxy)
}
@ -591,6 +581,8 @@ fun buildConfig(
-2L -> TAG_BLOCK
else -> if (outId == proxy.id) TAG_PROXY else tagMap[outId] ?: ""
}
_hack_custom_config = rule.config
}
if (!ruleObj.checkEmpty()) {
@ -620,7 +612,7 @@ fun buildConfig(
for (freedom in arrayOf(TAG_DIRECT, TAG_BYPASS)) outbounds.add(Outbound().apply {
tag = freedom
type = "direct"
}.asMap())
})
// Bypass Lookup for the first profile
bypassDNSBeans.forEach {
@ -746,16 +738,16 @@ fun buildConfig(
})
}
}
_hack_custom_config = proxy.requireBean().customConfigJson
}.let {
ConfigBuildResult(
gson.toJson(it.asMap().apply {
Util.mergeJSON(optionsToMerge, this)
}),
gson.toJson(it.asMap()),
externalIndexMap,
proxy.id,
trafficMap,
tagMap,
if (buildSelector) group!!.id else -1L
if (buildSelector) group.id else -1L
)
}

View File

@ -272,7 +272,7 @@ fun HysteriaBean.canUseSingBox(): Boolean {
return true
}
fun buildSingBoxOutboundHysteriaBean(bean: HysteriaBean): MutableMap<String, Any> {
fun buildSingBoxOutboundHysteriaBean(bean: HysteriaBean): SingBoxOptions.SingBoxOption {
return when (bean.protocolVersion) {
1 -> SingBoxOptions.Outbound_HysteriaOptions().apply {
type = "hysteria"
@ -311,7 +311,7 @@ fun buildSingBoxOutboundHysteriaBean(bean: HysteriaBean): MutableMap<String, Any
insecure = bean.allowInsecure || DataStore.globalAllowInsecure
enabled = true
}
}.asMap()
}
2 -> SingBoxOptions.Outbound_Hysteria2Options().apply {
type = "hysteria2"
@ -350,9 +350,9 @@ fun buildSingBoxOutboundHysteriaBean(bean: HysteriaBean): MutableMap<String, Any
insecure = bean.allowInsecure || DataStore.globalAllowInsecure
enabled = true
}
}.asMap()
}
else -> mutableMapOf("error_version" to bean.protocolVersion)
else -> error("error_version $bean.protocolVersion")
}
}

View File

@ -39,6 +39,7 @@ import io.nekohasekai.sagernet.widget.AppListPreference
import io.nekohasekai.sagernet.widget.ListListener
import io.nekohasekai.sagernet.widget.OutboundPreference
import kotlinx.parcelize.Parcelize
import moe.matsuri.nb4a.ui.EditConfigPreference
@Suppress("UNCHECKED_CAST")
class RouteSettingsActivity(
@ -57,6 +58,7 @@ class RouteSettingsActivity(
fun RuleEntity.init() {
DataStore.routeName = name
DataStore.serverConfig = config
DataStore.routeDomain = domains
DataStore.routeIP = ip
DataStore.routePort = port
@ -76,6 +78,7 @@ class RouteSettingsActivity(
fun RuleEntity.serialize() {
name = DataStore.routeName
config = DataStore.serverConfig
domains = DataStore.routeDomain
ip = DataStore.routeIP
port = DataStore.routePort
@ -96,12 +99,10 @@ class RouteSettingsActivity(
}
}
private lateinit var editConfigPreference: EditConfigPreference
fun needSave(): Boolean {
if (!DataStore.dirty) return false
if (DataStore.routePackages.isBlank() && DataStore.routeDomain.isBlank() && DataStore.routeIP.isBlank() && DataStore.routePort.isBlank() && DataStore.routeSourcePort.isBlank() && DataStore.routeNetwork.isBlank() && DataStore.routeSource.isBlank() && DataStore.routeProtocol.isBlank()) {
return false
}
return true
return DataStore.dirty
}
fun PreferenceFragmentCompat.createPreferences(
@ -109,6 +110,16 @@ class RouteSettingsActivity(
rootKey: String?,
) {
addPreferencesFromResource(R.xml.route_preferences)
editConfigPreference = findPreference(Key.SERVER_CONFIG)!!
}
override fun onResume() {
super.onResume()
if (::editConfigPreference.isInitialized) {
editConfigPreference.notifyChanged()
}
}
val selectProfileForAdd = registerForActivityResult(
@ -163,7 +174,7 @@ class RouteSettingsActivity(
}
}
fun PreferenceFragmentCompat.displayPreferenceDialog(preference: Preference): Boolean {
fun displayPreferenceDialog(preference: Preference): Boolean {
return false
}

View File

@ -1,19 +1,74 @@
package moe.matsuri.nb4a;
import static moe.matsuri.nb4a.utils.JavaUtil.gson;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.ToNumberPolicy;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import moe.matsuri.nb4a.utils.Util;
public class SingBoxOptions {
// base
private static final Gson gsonSingbox = new GsonBuilder()
.registerTypeHierarchyAdapter(SingBoxOption.class, new SingBoxOptionSerializer())
.setPrettyPrinting()
.setNumberToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE)
.setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE)
.setLenient()
.disableHtmlEscaping()
.create();
public static class SingBoxOption {
public transient Map<String, Object> _hack_config_map; // 仍然用普通json方式合并所以Object内不要使用 _hack
public transient String _hack_custom_config;
public SingBoxOption() {
_hack_config_map = new HashMap<>();
}
public Map<String, Object> asMap() {
return gson.fromJson(gson.toJson(this), Map.class);
return gsonSingbox.fromJson(gsonSingbox.toJson(this), Map.class);
}
}
// 自定义序列化器
public static class SingBoxOptionSerializer implements JsonSerializer<SingBoxOption> {
@Override
public JsonElement serialize(SingBoxOption src, Type typeOfSrc, JsonSerializationContext context) {
// 拿到原始的 delegate默认序列化器
TypeAdapter<?> delegate = gsonSingbox.getDelegateAdapter(
new TypeAdapterFactory() {
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
return null; // 返回 null表示只作为跳过当前自定义 marker
}
},
TypeToken.get(src.getClass())
);
Map<String, Object> map = gsonSingbox.fromJson(((TypeAdapter<SingBoxOption>) delegate).toJson(src), Map.class);
if (src._hack_config_map != null && !src._hack_config_map.isEmpty()) {
Util.INSTANCE.mergeMap(map, src._hack_config_map);
}
if (src._hack_custom_config != null && !src._hack_custom_config.isBlank()) {
Util.INSTANCE.mergeJSON(map, src._hack_custom_config);
}
return gsonSingbox.toJsonTree(map);
}
}
@ -33,7 +88,7 @@ public class SingBoxOptions {
public List<Inbound> inbounds;
public List<Map<String, Object>> outbounds;
public List<SingBoxOption> outbounds;
public RouteOptions route;

View File

@ -152,7 +152,7 @@ object Util {
return dst
}
fun mergeJSON(j: String, dst: MutableMap<String, Any?>) {
fun mergeJSON(dst: MutableMap<String, Any?>, j: String) {
if (j.isBlank()) return
val src = JavaUtil.gson.fromJson(j, dst.javaClass)
mergeMap(dst, src)

View File

@ -6,11 +6,16 @@
app:key="routeName"
app:title="@string/route_name"
app:useSimpleSummaryProvider="true" />
<moe.matsuri.nb4a.ui.EditConfigPreference
app:icon="@drawable/ic_baseline_layers_24"
app:key="serverConfig"
app:title="@string/custom_config"
app:useSimpleSummaryProvider="true" />
<PreferenceCategory app:title="@string/cag_route">
<io.nekohasekai.sagernet.widget.AppListPreference
app:icon="@drawable/ic_baseline_legend_toggle_24"
app:key="routePackages"
app:title="@string/apps" />
<PreferenceCategory app:title="@string/cag_route">
<EditTextPreference
app:icon="@drawable/ic_baseline_domain_24"
app:key="routeDomain"
@ -19,19 +24,24 @@
<EditTextPreference
app:icon="@drawable/ic_baseline_add_road_24"
app:key="routeIP"
app:title="ip"
app:title="dst ip"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
android:layout_width="match_parent"
android:layout_height="match_parent"
app:icon="@drawable/ic_maps_directions_boat"
app:key="routePort"
app:title="port"
app:title="dst port"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
app:icon="@drawable/ic_baseline_local_bar_24"
app:key="routeSource"
app:title="src ip"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
app:icon="@drawable/ic_baseline_home_24"
app:key="routeSourcePort"
app:title="sourcePort"
app:title="src port"
app:useSimpleSummaryProvider="true" />
<moe.matsuri.nb4a.ui.SimpleMenuPreference
app:entries="@array/route_protocol_entry"
@ -40,11 +50,6 @@
app:key="routeNetwork"
app:title="network"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
app:icon="@drawable/ic_baseline_local_bar_24"
app:key="routeSource"
app:title="source"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
app:icon="@drawable/ic_baseline_layers_24"
app:key="routeProtocol"