浏览代码

working on TV, split tunneling optimized on wireguard

Khubaib 10 月之前
父节点
当前提交
b4e68be2e5

+ 2 - 2
.idea/deploymentTargetSelector.xml

@@ -4,10 +4,10 @@
     <selectionStates>
       <SelectionState runConfigName="app">
         <option name="selectionMode" value="DROPDOWN" />
-        <DropdownSelection timestamp="2024-06-07T09:37:15.274201056Z">
+        <DropdownSelection timestamp="2024-06-11T13:21:48.190010045Z">
           <Target type="DEFAULT_BOOT">
             <handle>
-              <DeviceId pluginId="PhysicalDevice" identifier="serial=1C051FDF60048Z" />
+              <DeviceId pluginId="LocalEmulator" identifier="path=/home/ubuntu/.android/avd/Television_1080p_API_31.avd" />
             </handle>
           </Target>
         </DropdownSelection>

+ 1 - 1
app/build.gradle.kts

@@ -16,7 +16,7 @@ android {
         minSdk = 21
         targetSdk = 34
         versionCode = 327
-        versionName = "3.2.7"
+        versionName = "3.2.7.1"
 
         testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
         ndk {

二进制
app/release/app-release.apk


+ 1 - 1
app/release/output-metadata.json

@@ -12,7 +12,7 @@
       "filters": [],
       "attributes": [],
       "versionCode": 327,
-      "versionName": "3.2.7",
+      "versionName": "3.2.7.1",
       "outputFile": "app-release.apk"
     }
   ],

+ 1 - 0
app/src/main/java/com/vpn/fastestvpnservice/activities/HomeActivityTV.kt

@@ -211,6 +211,7 @@ class HomeActivityTV : AppCompatActivity(), VPNConnectionCallBacks, CallBacks {
                 prefHelper.getServerData().get(0).servers!!
             )
         }
+        serverobj = filterServerByConnectionCount
         prefHelper.setServerObject(filterServerByConnectionCount)
 
 //        callBacks?.onServerSelected(filterServerByConnectionCount)

+ 0 - 33
app/src/main/java/com/vpn/fastestvpnservice/beans/Server.kt

@@ -35,39 +35,6 @@ class Server(
     var ping: Int = 0
 )
 
-class Server2(
-    var id: Int? = null,
-    @SerializedName("continent") val continent: String? = null,
-    @SerializedName("country") val country: String? = null,
-    @SerializedName("state") val state: String? = null,
-    @SerializedName("city") val city: Any? = null,
-    @SerializedName("name") val name: String? = null,
-    @SerializedName("dns") val dns: String? = null,
-    @SerializedName("iso") val iso: String? = null,
-    @SerializedName("lt") val lt: Double? = null,
-    @SerializedName("lg") var lg: Double? = null,
-    @SerializedName("ip") val ip: Any? = null,
-    @SerializedName("port") val port: Int? = null,
-    @SerializedName("protocol") val protocol: String? = null,
-    @SerializedName("ipsec") val ipsec: Any? = null,
-    @SerializedName("remote_id") val remoteId: Any? = null,
-    @SerializedName("is_trial") val isTrial: Boolean? = null,
-    @SerializedName("active") val active: Boolean? = null,
-    @SerializedName("flag") val flag: String? = null,
-    @SerializedName("server_name") val server_name: String? = null,
-    @SerializedName("is_favourited") var isFavourited: Boolean? = null,
-    val country_sort: Int = 0,
-    @SerializedName("connection_count") val connection_count: Int = 0,
-    @SerializedName("wg_key") val wg_key: String? = null,
-    @SerializedName("enable") var enable: Int = 1,
-    var countryServers: List<Server>? = null,
-    var totalServers: Int = 1,
-    var enableServers: Int = 1,
-    var distance: Float = 0.0f,
-    var ping: Int = 0
-)
-
-
 class ServerProtocol(
     val server: Server,
     val isFound: Boolean

+ 0 - 1
app/src/main/java/com/vpn/fastestvpnservice/screens/bottomNavBarScreens/HomeScreen.kt

@@ -8,7 +8,6 @@ import android.os.Handler
 import android.util.Log
 import androidx.activity.ComponentActivity
 import androidx.compose.foundation.BorderStroke
-import androidx.compose.foundation.ExperimentalFoundationApi
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
 import androidx.compose.foundation.border

+ 46 - 2
app/src/main/java/com/vpn/fastestvpnservice/utils/VPNConnectionUtilsTV.kt

@@ -449,16 +449,36 @@ class VPNConnectionUtilsTV: VpnStatus.StateListener {
                         App.backend = App.getBackend()
                     }
                     val listEnable = basePreferenceHelper.getEnableTvAppsSplit()
+                    val listDisable = basePreferenceHelper.getDisableTvAppsSplit()
+
+                    Log.d("listEnable", "server = ${basePreferenceHelper.getServerObject()?.dns}")
+
+                    listEnable?.forEachIndexed { index, tvEnableApps ->
+                        Log.d("listEnable", "tvEnableApps = ${tvEnableApps.appNames}")
+                    }
+
+                    listDisable?.forEachIndexed { index, tvDisableApps ->
+                        Log.d("listEnable", "tvDisableApps = ${tvDisableApps.appNames}")
+                    }
 
 //                    Log.d("testing_wg_on_tv WG s", "${App.backend.toString()} , ${App.getTunnel()} + ${App.tunnelStatus} + ${App.peerBuilder}")
 
-                    if (listEnable?.size == 0)
+                    if (listEnable?.size == 0 && listDisable?.size != 0)
                     {
+                        Log.d("listEnable", "on -> listEnable?.size == 0 && listDisable?.size != 0")
+
+                        val tempDisabledList = ArrayList<String>()
+
+                        listDisable?.forEachIndexed { index, tvSplitTunneling ->
+                            tempDisabledList.add(index, tvSplitTunneling.appPackageName)
+                        }
+
                         App.backend?.setState(
                             App.getTunnel(), App.tunnelStatus, Config.Builder().setInterface(
                                 interfaceBuilder!!.addAddress(InetNetwork.parse(basePreferenceHelper.getWireGuard()?.ip + "/32"))
                                     .parsePrivateKey(basePreferenceHelper.getWireGuard()?.key)
                                     .parseDnsServers(dnswg)
+                                    .excludeApplications(tempDisabledList)
                                     .build()
                             ).addPeer(
                                 App.peerBuilder.addAllowedIp(InetNetwork.parse("0.0.0.0/0"))
@@ -469,11 +489,17 @@ class VPNConnectionUtilsTV: VpnStatus.StateListener {
 
 
                     }
-                    else{
+                    else if (listEnable?.let {
+                            it.size > 0
+                        } == true)
+                    {
+                        Log.d("listEnable", "on -> listEnable?.size > 0")
+
                         val tempEnabledList = ArrayList<String>()
 
                         listEnable?.forEachIndexed { index, tvSplitTunneling ->
                             tempEnabledList.add(index, tvSplitTunneling.appPackageName)
+                            Log.d("listEnable", "on -> ${tempEnabledList[index]}")
                         }
 
                         App.backend?.setState(
@@ -489,6 +515,24 @@ class VPNConnectionUtilsTV: VpnStatus.StateListener {
                                     .parsePublicKey(basePreferenceHelper.getServerObject()?.wg_key).build()
                             ).build()
                         )
+
+
+                    }
+                    else{
+                        Log.d("listEnable", "on -> else - ${listEnable?.size} ${listDisable?.size}")
+
+                        App.backend?.setState(
+                            App.getTunnel(), App.tunnelStatus, Config.Builder().setInterface(
+                                interfaceBuilder!!.addAddress(InetNetwork.parse(basePreferenceHelper.getWireGuard()?.ip + "/32"))
+                                    .parsePrivateKey(basePreferenceHelper.getWireGuard()?.key)
+                                    .parseDnsServers(dnswg)
+                                    .build()
+                            ).addPeer(
+                                App.peerBuilder.addAllowedIp(InetNetwork.parse("0.0.0.0/0"))
+                                    .setEndpoint(InetEndpoint.parse(basePreferenceHelper.getServerObject()?.dns + ":51820"))
+                                    .parsePublicKey(basePreferenceHelper.getServerObject()?.wg_key).build()
+                            ).build()
+                        )
                     }
                 }
                 else