Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Process self package at VpnService using addDisallowedApplication
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust authored and AnGgIt86 committed Sep 26, 2024
1 parent e24dd3b commit 87c05c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,11 @@ object V2RayServiceManager {
}

override fun onEmitStatus(l: Long, s: String?): Long {
//Logger.d(s)
return 0
}

override fun setup(s: String): Long {
val serviceControl = serviceControl?.get() ?: return -1
//Logger.d(s)
return try {
serviceControl.startService()
lastQueryTime = System.currentTimeMillis()
Expand Down Expand Up @@ -197,7 +195,6 @@ object V2RayServiceManager {
val serviceControl = serviceControl?.get() ?: return
when (intent?.getIntExtra("key", 0)) {
AppConfig.MSG_REGISTER_CLIENT -> {
//Logger.e("ReceiveMessageHandler", intent?.getIntExtra("key", 0).toString())
if (v2rayPoint.isRunning) {
MessageUtil.sendMsg2UI(serviceControl.getService(), AppConfig.MSG_STATE_RUNNING, "")
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import android.os.StrictMode
import android.util.Log
import androidx.annotation.RequiresApi
import com.neko.v2ray.AppConfig
import com.neko.v2ray.BuildConfig
import com.neko.v2ray.R
import com.neko.v2ray.util.MmkvManager.settingsStorage
import com.neko.v2ray.util.MyContextWrapper
Expand Down Expand Up @@ -150,19 +151,23 @@ class V2RayVpnService : VpnService(), ServiceControl {

builder.setSession(V2RayServiceManager.currentConfig?.remarks.orEmpty())

val selfPackageName = BuildConfig.APPLICATION_ID
if (settingsStorage?.decodeBool(AppConfig.PREF_PER_APP_PROXY) == true) {
val apps = settingsStorage?.decodeStringSet(AppConfig.PREF_PER_APP_PROXY_SET)
val bypassApps = settingsStorage?.decodeBool(AppConfig.PREF_BYPASS_APPS) ?: false
//process self package
if (bypassApps) apps?.add(selfPackageName) else apps?.remove(selfPackageName)
apps?.forEach {
try {
if (bypassApps)
builder.addDisallowedApplication(it)
else
builder.addAllowedApplication(it)
} catch (e: PackageManager.NameNotFoundException) {
//Logger.d(e)
}
}
} else {
builder.addDisallowedApplication(selfPackageName)
}

// Close the old interface since the parameters have been changed.
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/raw/licenses.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
<copyright>Copyright 2010-2016 JetBrains s.r.o.</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>Logger</name>
<url>https://github.com/orhanobut/logger</url>
<copyright>Copyright 2015 Orhan Obut</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>LeakCanary</name>
<url>https://github.com/square/leakcanary</url>
Expand Down

0 comments on commit 87c05c0

Please sign in to comment.