From 794ab41663ffcdeefc50f5e39a8b2e4b505f4a38 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:17:05 +0800 Subject: [PATCH] Bug fix --- .../kotlin/com/neko/v2ray/service/V2RayServiceManager.kt | 2 +- .../kotlin/com/neko/v2ray/service/V2RayTestService.kt | 2 +- .../main/kotlin/com/neko/v2ray/service/V2RayVpnService.kt | 4 ++++ .../main/kotlin/com/neko/v2ray/ui/RoutingEditActivity.kt | 8 +++----- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/neko/v2ray/service/V2RayServiceManager.kt b/app/src/main/kotlin/com/neko/v2ray/service/V2RayServiceManager.kt index a569b485..bc3ab8e7 100644 --- a/app/src/main/kotlin/com/neko/v2ray/service/V2RayServiceManager.kt +++ b/app/src/main/kotlin/com/neko/v2ray/service/V2RayServiceManager.kt @@ -51,7 +51,7 @@ object V2RayServiceManager { set(value) { field = value Seq.setContext(value?.get()?.getService()?.applicationContext) - Libv2ray.initV2Env(Utils.userAssetPath(value?.get()?.getService()))//, Utils.getDeviceIdForXUDPBaseKey()) + Libv2ray.initV2Env(Utils.userAssetPath(value?.get()?.getService()), Utils.getDeviceIdForXUDPBaseKey()) } var currentConfig: ServerConfig? = null diff --git a/app/src/main/kotlin/com/neko/v2ray/service/V2RayTestService.kt b/app/src/main/kotlin/com/neko/v2ray/service/V2RayTestService.kt index fd9b46f7..e54ef055 100644 --- a/app/src/main/kotlin/com/neko/v2ray/service/V2RayTestService.kt +++ b/app/src/main/kotlin/com/neko/v2ray/service/V2RayTestService.kt @@ -24,7 +24,7 @@ class V2RayTestService : Service() { override fun onCreate() { super.onCreate() Seq.setContext(this) - Libv2ray.initV2Env(Utils.userAssetPath(this)) //Utils.getDeviceIdForXUDPBaseKey()) + Libv2ray.initV2Env(Utils.userAssetPath(this), Utils.getDeviceIdForXUDPBaseKey()) } override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { diff --git a/app/src/main/kotlin/com/neko/v2ray/service/V2RayVpnService.kt b/app/src/main/kotlin/com/neko/v2ray/service/V2RayVpnService.kt index 65b0f458..6f7be8af 100644 --- a/app/src/main/kotlin/com/neko/v2ray/service/V2RayVpnService.kt +++ b/app/src/main/kotlin/com/neko/v2ray/service/V2RayVpnService.kt @@ -138,12 +138,16 @@ class V2RayVpnService : VpnService(), ServiceControl { } } +// if (settingsStorage?.decodeBool(AppConfig.PREF_LOCAL_DNS_ENABLED) == true) { +// builder.addDnsServer(PRIVATE_VLAN4_ROUTER) +// } else { Utils.getVpnDnsServers() .forEach { if (Utils.isPureIpAddress(it)) { builder.addDnsServer(it) } } +// } builder.setSession(V2RayServiceManager.currentConfig?.remarks.orEmpty()) diff --git a/app/src/main/kotlin/com/neko/v2ray/ui/RoutingEditActivity.kt b/app/src/main/kotlin/com/neko/v2ray/ui/RoutingEditActivity.kt index 875c74c7..2e3d857c 100644 --- a/app/src/main/kotlin/com/neko/v2ray/ui/RoutingEditActivity.kt +++ b/app/src/main/kotlin/com/neko/v2ray/ui/RoutingEditActivity.kt @@ -2,14 +2,12 @@ package com.neko.v2ray.ui import android.os.Bundle import android.text.TextUtils -import android.util.Log import android.view.Menu import android.view.MenuItem import androidx.appcompat.app.AlertDialog import androidx.lifecycle.lifecycleScope import com.google.android.material.appbar.MaterialToolbar import com.google.android.material.appbar.CollapsingToolbarLayout -import com.google.gson.Gson import com.neko.v2ray.R import com.neko.v2ray.databinding.ActivityRoutingEditBinding import com.neko.v2ray.dto.RulesetItem @@ -114,9 +112,9 @@ class RoutingEditActivity : BaseActivity() { val rulesetItem = SettingsManager.getRoutingRuleset(position) ?: RulesetItem() rulesetItem.remarks = binding.etRemarks.text.toString() - binding.etDomain.text.toString().let { rulesetItem.domain = if (it.isEmpty()) null else it.split(',') } - binding.etIp.text.toString().let { rulesetItem.ip = if (it.isEmpty()) null else it.split(',') } - binding.etProtocol.text.toString().let { rulesetItem.protocol = if (it.isEmpty()) null else it.split(',') } + binding.etDomain.text.toString().let { rulesetItem.domain = if (it.isEmpty()) null else it.split(",").map { itt -> itt.trim() }.filter { itt -> itt.isNotEmpty() } } + binding.etIp.text.toString().let { rulesetItem.ip = if (it.isEmpty()) null else it.split(",").map { itt -> itt.trim() }.filter { itt -> itt.isNotEmpty() } } + binding.etProtocol.text.toString().let { rulesetItem.protocol = if (it.isEmpty()) null else it.split(",").map { itt -> itt.trim() }.filter { itt -> itt.isNotEmpty() } } binding.etPort.text.toString().let { rulesetItem.port = it.ifEmpty { null } } binding.etNetwork.text.toString().let { rulesetItem.network = it.ifEmpty { null } } rulesetItem.outboundTag = outbound_tag[binding.spOutboundTag.selectedItemPosition]