Optimize app logic
Support windows administrator auto launch Support android close vpn
This commit is contained in:
@@ -2,11 +2,11 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.touchscreen"
|
android:name="android.hardware.touchscreen"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.camera"
|
android:name="android.hardware.camera"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
@@ -14,18 +14,20 @@
|
|||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"
|
<uses-permission
|
||||||
|
android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"
|
||||||
tools:ignore="SystemPermissionTypo" />
|
tools:ignore="SystemPermissionTypo" />
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
<uses-permission
|
||||||
|
android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||||
tools:ignore="QueryAllPackagesPermission" />
|
tools:ignore="QueryAllPackagesPermission" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher"
|
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
|
||||||
android:extractNativeLibs="true"
|
|
||||||
android:enableOnBackInvokedCallback="true"
|
android:enableOnBackInvokedCallback="true"
|
||||||
|
android:extractNativeLibs="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="FlClash"
|
android:label="FlClash"
|
||||||
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
tools:targetApi="tiramisu">
|
tools:targetApi="tiramisu">
|
||||||
<activity
|
<activity
|
||||||
android:name="com.follow.clash.MainActivity"
|
android:name="com.follow.clash.MainActivity"
|
||||||
@@ -56,17 +58,17 @@
|
|||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
<data android:scheme="clash"/>
|
<data android:scheme="clash" />
|
||||||
<data android:scheme="clashmeta"/>
|
<data android:scheme="clashmeta" />
|
||||||
<data android:scheme="flclash"/>
|
<data android:scheme="flclash" />
|
||||||
|
|
||||||
<data android:host="install-config"/>
|
<data android:host="install-config" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- <meta-data-->
|
<!-- <meta-data-->
|
||||||
<!-- android:name="io.flutter.embedding.android.EnableImpeller"-->
|
<!-- android:name="io.flutter.embedding.android.EnableImpeller"-->
|
||||||
<!-- android:value="true" />-->
|
<!-- android:value="true" />-->
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".TempActivity"
|
android:name=".TempActivity"
|
||||||
@@ -75,11 +77,10 @@
|
|||||||
<service
|
<service
|
||||||
android:name=".services.FlClashTileService"
|
android:name=".services.FlClashTileService"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:icon="@drawable/ic_stat_name"
|
|
||||||
android:foregroundServiceType="specialUse"
|
android:foregroundServiceType="specialUse"
|
||||||
|
android:icon="@drawable/ic_stat_name"
|
||||||
android:label="FlClash"
|
android:label="FlClash"
|
||||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||||
>
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
@@ -114,13 +115,17 @@
|
|||||||
android:name=".services.FlClashVpnService"
|
android:name=".services.FlClashVpnService"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:foregroundServiceType="specialUse"
|
android:foregroundServiceType="specialUse"
|
||||||
android:permission="android.permission.BIND_VPN_SERVICE"
|
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||||
>
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.net.VpnService" />
|
<action android:name="android.net.VpnService" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name=".services.FlClashService"
|
||||||
|
android:exported="false"
|
||||||
|
android:foregroundServiceType="specialUse" />
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="flutterEmbedding"
|
android:name="flutterEmbedding"
|
||||||
android:value="2" />
|
android:value="2" />
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.follow.clash
|
||||||
|
|
||||||
|
import com.follow.clash.models.Props
|
||||||
|
|
||||||
|
interface BaseServiceInterface {
|
||||||
|
fun start(port: Int, props: Props?): Int?
|
||||||
|
fun stop()
|
||||||
|
fun startForeground(title: String, content: String)
|
||||||
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.follow.clash
|
package com.follow.clash
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.follow.clash.plugins.AppPlugin
|
import com.follow.clash.plugins.AppPlugin
|
||||||
import com.follow.clash.plugins.ProxyPlugin
|
import com.follow.clash.plugins.ServicePlugin
|
||||||
|
import com.follow.clash.plugins.VpnPlugin
|
||||||
import com.follow.clash.plugins.TilePlugin
|
import com.follow.clash.plugins.TilePlugin
|
||||||
import io.flutter.FlutterInjector
|
import io.flutter.FlutterInjector
|
||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
@@ -22,6 +22,7 @@ enum class RunState {
|
|||||||
object GlobalState {
|
object GlobalState {
|
||||||
|
|
||||||
private val lock = ReentrantLock()
|
private val lock = ReentrantLock()
|
||||||
|
val runLock = ReentrantLock()
|
||||||
|
|
||||||
val runState: MutableLiveData<RunState> = MutableLiveData<RunState>(RunState.STOP)
|
val runState: MutableLiveData<RunState> = MutableLiveData<RunState>(RunState.STOP)
|
||||||
var flutterEngine: FlutterEngine? = null
|
var flutterEngine: FlutterEngine? = null
|
||||||
@@ -37,6 +38,11 @@ object GlobalState {
|
|||||||
return currentEngine?.plugins?.get(TilePlugin::class.java) as TilePlugin?
|
return currentEngine?.plugins?.get(TilePlugin::class.java) as TilePlugin?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getCurrentVPNPlugin(): VpnPlugin? {
|
||||||
|
val currentEngine = if (serviceEngine != null) serviceEngine else flutterEngine
|
||||||
|
return currentEngine?.plugins?.get(VpnPlugin::class.java) as VpnPlugin?
|
||||||
|
}
|
||||||
|
|
||||||
fun destroyServiceEngine() {
|
fun destroyServiceEngine() {
|
||||||
serviceEngine?.destroy()
|
serviceEngine?.destroy()
|
||||||
serviceEngine = null
|
serviceEngine = null
|
||||||
@@ -47,9 +53,10 @@ object GlobalState {
|
|||||||
lock.withLock {
|
lock.withLock {
|
||||||
destroyServiceEngine()
|
destroyServiceEngine()
|
||||||
serviceEngine = FlutterEngine(context)
|
serviceEngine = FlutterEngine(context)
|
||||||
serviceEngine?.plugins?.add(ProxyPlugin())
|
serviceEngine?.plugins?.add(VpnPlugin())
|
||||||
serviceEngine?.plugins?.add(AppPlugin())
|
serviceEngine?.plugins?.add(AppPlugin())
|
||||||
serviceEngine?.plugins?.add(TilePlugin())
|
serviceEngine?.plugins?.add(TilePlugin())
|
||||||
|
serviceEngine?.plugins?.add(ServicePlugin())
|
||||||
val vpnService = DartExecutor.DartEntrypoint(
|
val vpnService = DartExecutor.DartEntrypoint(
|
||||||
FlutterInjector.instance().flutterLoader().findAppBundlePath(),
|
FlutterInjector.instance().flutterLoader().findAppBundlePath(),
|
||||||
"vpnService"
|
"vpnService"
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ package com.follow.clash
|
|||||||
|
|
||||||
|
|
||||||
import com.follow.clash.plugins.AppPlugin
|
import com.follow.clash.plugins.AppPlugin
|
||||||
import com.follow.clash.plugins.ProxyPlugin
|
import com.follow.clash.plugins.ServicePlugin
|
||||||
|
import com.follow.clash.plugins.VpnPlugin
|
||||||
import com.follow.clash.plugins.TilePlugin
|
import com.follow.clash.plugins.TilePlugin
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
@@ -12,7 +13,8 @@ class MainActivity : FlutterActivity() {
|
|||||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||||
super.configureFlutterEngine(flutterEngine)
|
super.configureFlutterEngine(flutterEngine)
|
||||||
flutterEngine.plugins.add(AppPlugin())
|
flutterEngine.plugins.add(AppPlugin())
|
||||||
flutterEngine.plugins.add(ProxyPlugin())
|
flutterEngine.plugins.add(VpnPlugin())
|
||||||
|
flutterEngine.plugins.add(ServicePlugin())
|
||||||
flutterEngine.plugins.add(TilePlugin())
|
flutterEngine.plugins.add(TilePlugin())
|
||||||
GlobalState.flutterEngine = flutterEngine
|
GlobalState.flutterEngine = flutterEngine
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,28 @@
|
|||||||
package com.follow.clash.extensions
|
package com.follow.clash.extensions
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
|
||||||
|
import android.app.NotificationChannel
|
||||||
|
import android.app.NotificationManager
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.app.Service
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.os.Build
|
||||||
import android.system.OsConstants.IPPROTO_TCP
|
import android.system.OsConstants.IPPROTO_TCP
|
||||||
import android.system.OsConstants.IPPROTO_UDP
|
import android.system.OsConstants.IPPROTO_UDP
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import java.net.URL
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
|
import com.follow.clash.MainActivity
|
||||||
|
import com.follow.clash.R
|
||||||
import com.follow.clash.models.Metadata
|
import com.follow.clash.models.Metadata
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.net.InetAddress
|
|
||||||
import java.net.InetSocketAddress
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun Drawable.getBase64(): String {
|
suspend fun Drawable.getBase64(): String {
|
||||||
@@ -31,7 +41,6 @@ fun Metadata.getProtocol(): Int? {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.getInetSocketAddress(): InetSocketAddress {
|
private val CHANNEL = "FlClash"
|
||||||
val url = URL("https://$this")
|
|
||||||
return InetSocketAddress(InetAddress.getByName(url.host), url.port)
|
private val notificationId: Int = 1
|
||||||
}
|
|
||||||
@@ -12,6 +12,7 @@ data class AccessControl(
|
|||||||
)
|
)
|
||||||
|
|
||||||
data class Props(
|
data class Props(
|
||||||
|
val enable: Boolean?,
|
||||||
val accessControl: AccessControl?,
|
val accessControl: AccessControl?,
|
||||||
val allowBypass: Boolean?,
|
val allowBypass: Boolean?,
|
||||||
val systemProxy: Boolean?,
|
val systemProxy: Boolean?,
|
||||||
|
|||||||
@@ -9,8 +9,11 @@ import android.content.pm.ApplicationInfo
|
|||||||
import android.content.pm.ComponentInfo
|
import android.content.pm.ComponentInfo
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.VpnService
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.app.ActivityCompat
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.ContextCompat.getSystemService
|
import androidx.core.content.ContextCompat.getSystemService
|
||||||
import com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile
|
import com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
@@ -21,6 +24,7 @@ import com.follow.clash.extensions.getProtocol
|
|||||||
import com.follow.clash.models.Package
|
import com.follow.clash.models.Package
|
||||||
import com.follow.clash.models.Process
|
import com.follow.clash.models.Process
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
||||||
@@ -36,14 +40,13 @@ import java.io.File
|
|||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
|
|
||||||
|
|
||||||
class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
|
class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
|
||||||
|
|
||||||
private var activity: Activity? = null
|
private var activity: Activity? = null
|
||||||
|
|
||||||
private var toast: Toast? = null
|
private var toast: Toast? = null
|
||||||
|
|
||||||
private var context: Context? = null
|
private lateinit var context: Context
|
||||||
|
|
||||||
private lateinit var channel: MethodChannel
|
private lateinit var channel: MethodChannel
|
||||||
|
|
||||||
@@ -51,6 +54,8 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
|
|
||||||
private var connectivity: ConnectivityManager? = null
|
private var connectivity: ConnectivityManager? = null
|
||||||
|
|
||||||
|
private var vpnCallBack: (() -> Unit)? = null
|
||||||
|
|
||||||
private val iconMap = mutableMapOf<String, String?>()
|
private val iconMap = mutableMapOf<String, String?>()
|
||||||
private val packages = mutableListOf<Package>()
|
private val packages = mutableListOf<Package>()
|
||||||
|
|
||||||
@@ -109,12 +114,18 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
("(" + chinaAppPrefixList.joinToString("|").replace(".", "\\.") + ").*").toRegex()
|
("(" + chinaAppPrefixList.joinToString("|").replace(".", "\\.") + ").*").toRegex()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val VPN_PERMISSION_REQUEST_CODE = 1001
|
||||||
|
|
||||||
|
val NOTIFICATION_PERMISSION_REQUEST_CODE = 1002
|
||||||
|
|
||||||
|
private var isBlockNotification: Boolean = false
|
||||||
|
|
||||||
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
scope = CoroutineScope(Dispatchers.Default)
|
scope = CoroutineScope(Dispatchers.Default)
|
||||||
context = flutterPluginBinding.applicationContext;
|
context = flutterPluginBinding.applicationContext;
|
||||||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "app")
|
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "app")
|
||||||
channel.setMethodCallHandler(this)
|
channel.setMethodCallHandler(this)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
@@ -172,7 +183,7 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
}
|
}
|
||||||
if (iconMap["default"] == null) {
|
if (iconMap["default"] == null) {
|
||||||
iconMap["default"] =
|
iconMap["default"] =
|
||||||
context?.packageManager?.defaultActivityIcon?.getBase64()
|
context.packageManager?.defaultActivityIcon?.getBase64()
|
||||||
}
|
}
|
||||||
result.success(iconMap["default"])
|
result.success(iconMap["default"])
|
||||||
return@launch
|
return@launch
|
||||||
@@ -199,12 +210,8 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
result.success(null)
|
result.success(null)
|
||||||
return@withContext
|
return@withContext
|
||||||
}
|
}
|
||||||
if (context == null) {
|
|
||||||
result.success(null)
|
|
||||||
return@withContext
|
|
||||||
}
|
|
||||||
if (connectivity == null) {
|
if (connectivity == null) {
|
||||||
connectivity = context!!.getSystemService<ConnectivityManager>()
|
connectivity = context.getSystemService<ConnectivityManager>()
|
||||||
}
|
}
|
||||||
val src = InetSocketAddress(metadata.sourceIP, metadata.sourcePort)
|
val src = InetSocketAddress(metadata.sourceIP, metadata.sourcePort)
|
||||||
val dst = InetSocketAddress(
|
val dst = InetSocketAddress(
|
||||||
@@ -220,7 +227,7 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
result.success(null)
|
result.success(null)
|
||||||
return@withContext
|
return@withContext
|
||||||
}
|
}
|
||||||
val packages = context?.packageManager?.getPackagesForUid(uid)
|
val packages = context.packageManager?.getPackagesForUid(uid)
|
||||||
result.success(packages?.first())
|
result.success(packages?.first())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,46 +252,43 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun openFile(path: String) {
|
private fun openFile(path: String) {
|
||||||
context?.let {
|
val file = File(path)
|
||||||
val file = File(path)
|
val uri = FileProvider.getUriForFile(
|
||||||
val uri = FileProvider.getUriForFile(
|
context,
|
||||||
it,
|
"${context.packageName}.fileProvider",
|
||||||
"${it.packageName}.fileProvider",
|
file
|
||||||
file
|
)
|
||||||
)
|
|
||||||
|
|
||||||
val intent = Intent(Intent.ACTION_VIEW).setDataAndType(
|
val intent = Intent(Intent.ACTION_VIEW).setDataAndType(
|
||||||
|
uri,
|
||||||
|
"text/plain"
|
||||||
|
)
|
||||||
|
|
||||||
|
val flags =
|
||||||
|
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||||
|
|
||||||
|
val resInfoList = context.packageManager.queryIntentActivities(
|
||||||
|
intent, PackageManager.MATCH_DEFAULT_ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
for (resolveInfo in resInfoList) {
|
||||||
|
val packageName = resolveInfo.activityInfo.packageName
|
||||||
|
context.grantUriPermission(
|
||||||
|
packageName,
|
||||||
uri,
|
uri,
|
||||||
"text/plain"
|
flags
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val flags =
|
try {
|
||||||
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION
|
activity?.startActivity(intent)
|
||||||
|
} catch (e: Exception) {
|
||||||
val resInfoList = it.packageManager.queryIntentActivities(
|
println(e)
|
||||||
intent, PackageManager.MATCH_DEFAULT_ONLY
|
|
||||||
)
|
|
||||||
|
|
||||||
for (resolveInfo in resInfoList) {
|
|
||||||
val packageName = resolveInfo.activityInfo.packageName
|
|
||||||
it.grantUriPermission(
|
|
||||||
packageName,
|
|
||||||
uri,
|
|
||||||
flags
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
activity?.startActivity(intent)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
println(e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateExcludeFromRecents(value: Boolean?) {
|
private fun updateExcludeFromRecents(value: Boolean?) {
|
||||||
if (context == null) return
|
val am = getSystemService(context, ActivityManager::class.java)
|
||||||
val am = getSystemService(context!!, ActivityManager::class.java)
|
|
||||||
val task = am?.appTasks?.firstOrNull {
|
val task = am?.appTasks?.firstOrNull {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
it.taskInfo.taskId == activity?.taskId
|
it.taskInfo.taskId == activity?.taskId
|
||||||
@@ -301,7 +305,7 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getPackageIcon(packageName: String): String? {
|
private suspend fun getPackageIcon(packageName: String): String? {
|
||||||
val packageManager = context?.packageManager
|
val packageManager = context.packageManager
|
||||||
if (iconMap[packageName] == null) {
|
if (iconMap[packageName] == null) {
|
||||||
iconMap[packageName] = try {
|
iconMap[packageName] = try {
|
||||||
packageManager?.getApplicationIcon(packageName)?.getBase64()
|
packageManager?.getApplicationIcon(packageName)?.getBase64()
|
||||||
@@ -314,10 +318,10 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getPackages(): List<Package> {
|
private fun getPackages(): List<Package> {
|
||||||
val packageManager = context?.packageManager
|
val packageManager = context.packageManager
|
||||||
if (packages.isNotEmpty()) return packages;
|
if (packages.isNotEmpty()) return packages;
|
||||||
packageManager?.getInstalledPackages(PackageManager.GET_META_DATA)?.filter {
|
packageManager?.getInstalledPackages(PackageManager.GET_META_DATA)?.filter {
|
||||||
it.packageName != context?.packageName
|
it.packageName != context.packageName
|
||||||
|| it.requestedPermissions?.contains(Manifest.permission.INTERNET) == true
|
|| it.requestedPermissions?.contains(Manifest.permission.INTERNET) == true
|
||||||
|| it.packageName == "android"
|
|| it.packageName == "android"
|
||||||
|
|
||||||
@@ -346,8 +350,38 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun requestVpnPermission(context: Context, callBack: () -> Unit) {
|
||||||
|
vpnCallBack = callBack
|
||||||
|
val intent = VpnService.prepare(context)
|
||||||
|
if (intent != null) {
|
||||||
|
activity?.startActivityForResult(intent, VPN_PERMISSION_REQUEST_CODE)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vpnCallBack?.invoke()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun requestNotificationsPermission(context: Context) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
val permission = ContextCompat.checkSelfPermission(
|
||||||
|
context,
|
||||||
|
Manifest.permission.POST_NOTIFICATIONS
|
||||||
|
)
|
||||||
|
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
if (isBlockNotification) return
|
||||||
|
if (activity == null) return
|
||||||
|
ActivityCompat.requestPermissions(
|
||||||
|
activity!!,
|
||||||
|
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
||||||
|
NOTIFICATION_PERMISSION_REQUEST_CODE
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun isChinaPackage(packageName: String): Boolean {
|
private fun isChinaPackage(packageName: String): Boolean {
|
||||||
val packageManager = context?.packageManager ?: return false
|
val packageManager = context.packageManager ?: return false
|
||||||
skipPrefixList.forEach {
|
skipPrefixList.forEach {
|
||||||
if (packageName == it || packageName.startsWith("$it.")) return false
|
if (packageName == it || packageName.startsWith("$it.")) return false
|
||||||
}
|
}
|
||||||
@@ -419,6 +453,8 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
|
|
||||||
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
||||||
activity = binding.activity;
|
activity = binding.activity;
|
||||||
|
binding.addActivityResultListener(::onActivityResult)
|
||||||
|
binding.addRequestPermissionsResultListener(::onRequestPermissionsResultListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetachedFromActivityForConfigChanges() {
|
override fun onDetachedFromActivityForConfigChanges() {
|
||||||
@@ -433,4 +469,25 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
channel.invokeMethod("exit", null)
|
channel.invokeMethod("exit", null)
|
||||||
activity = null
|
activity = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean {
|
||||||
|
if (requestCode == VPN_PERMISSION_REQUEST_CODE) {
|
||||||
|
if (resultCode == FlutterActivity.RESULT_OK) {
|
||||||
|
GlobalState.initServiceEngine(context)
|
||||||
|
vpnCallBack?.invoke()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onRequestPermissionsResultListener(
|
||||||
|
requestCode: Int,
|
||||||
|
permissions: Array<String>,
|
||||||
|
grantResults: IntArray
|
||||||
|
): Boolean {
|
||||||
|
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) {
|
||||||
|
isBlockNotification = true
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,220 +0,0 @@
|
|||||||
package com.follow.clash.plugins
|
|
||||||
|
|
||||||
import android.Manifest
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.ServiceConnection
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.net.VpnService
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.IBinder
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.core.app.ActivityCompat
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import com.follow.clash.GlobalState
|
|
||||||
import com.follow.clash.RunState
|
|
||||||
import com.follow.clash.models.Props
|
|
||||||
import com.follow.clash.services.FlClashVpnService
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
|
||||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
|
||||||
import io.flutter.plugin.common.MethodCall
|
|
||||||
import io.flutter.plugin.common.MethodChannel
|
|
||||||
|
|
||||||
|
|
||||||
class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
|
|
||||||
|
|
||||||
private lateinit var flutterMethodChannel: MethodChannel
|
|
||||||
|
|
||||||
val VPN_PERMISSION_REQUEST_CODE = 1001
|
|
||||||
val NOTIFICATION_PERMISSION_REQUEST_CODE = 1002
|
|
||||||
|
|
||||||
private var activity: Activity? = null
|
|
||||||
private var context: Context? = null
|
|
||||||
private var flClashVpnService: FlClashVpnService? = null
|
|
||||||
private var port: Int = 7890
|
|
||||||
private var props: Props? = null
|
|
||||||
private var isBlockNotification: Boolean = false
|
|
||||||
private var isStart: Boolean = false
|
|
||||||
|
|
||||||
private val connection = object : ServiceConnection {
|
|
||||||
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
|
||||||
val binder = service as FlClashVpnService.LocalBinder
|
|
||||||
flClashVpnService = binder.getService()
|
|
||||||
if (isStart) {
|
|
||||||
startVpn()
|
|
||||||
} else {
|
|
||||||
flClashVpnService?.initServiceEngine()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onServiceDisconnected(arg: ComponentName) {
|
|
||||||
flClashVpnService = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
|
||||||
context = flutterPluginBinding.applicationContext
|
|
||||||
flutterMethodChannel = MethodChannel(flutterPluginBinding.binaryMessenger, "proxy")
|
|
||||||
flutterMethodChannel.setMethodCallHandler(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDetachedFromEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
|
||||||
flutterMethodChannel.setMethodCallHandler(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) = when (call.method) {
|
|
||||||
"initService" -> {
|
|
||||||
isStart = false
|
|
||||||
initService()
|
|
||||||
requestNotificationsPermission()
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
"startProxy" -> {
|
|
||||||
isStart = true
|
|
||||||
port = call.argument<Int>("port")!!
|
|
||||||
val args = call.argument<String>("args")
|
|
||||||
props =
|
|
||||||
if (args != null) Gson().fromJson(args, Props::class.java) else null
|
|
||||||
startVpn()
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
"stopProxy" -> {
|
|
||||||
stopVpn()
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
"setProtect" -> {
|
|
||||||
val fd = call.argument<Int>("fd")
|
|
||||||
if (fd != null) {
|
|
||||||
flClashVpnService?.protect(fd)
|
|
||||||
result.success(true)
|
|
||||||
} else {
|
|
||||||
result.success(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
"startForeground" -> {
|
|
||||||
val title = call.argument<String>("title") as String
|
|
||||||
val content = call.argument<String>("content") as String
|
|
||||||
startForeground(title, content)
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
result.notImplemented()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initService() {
|
|
||||||
val intent = VpnService.prepare(context)
|
|
||||||
if (intent != null) {
|
|
||||||
activity?.startActivityForResult(intent, VPN_PERMISSION_REQUEST_CODE)
|
|
||||||
} else {
|
|
||||||
if (flClashVpnService != null) {
|
|
||||||
flClashVpnService!!.initServiceEngine()
|
|
||||||
} else {
|
|
||||||
bindService()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun startVpn() {
|
|
||||||
if (flClashVpnService == null) {
|
|
||||||
bindService()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (GlobalState.runState.value == RunState.START) return
|
|
||||||
GlobalState.runState.value = RunState.START
|
|
||||||
val intent = VpnService.prepare(context)
|
|
||||||
if (intent != null) {
|
|
||||||
stopVpn()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val fd = flClashVpnService?.start(port, props)
|
|
||||||
flutterMethodChannel.invokeMethod("started", fd)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun stopVpn() {
|
|
||||||
if (GlobalState.runState.value == RunState.STOP) return
|
|
||||||
GlobalState.runState.value = RunState.STOP
|
|
||||||
flClashVpnService?.stop()
|
|
||||||
GlobalState.destroyServiceEngine()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun startForeground(title: String, content: String) {
|
|
||||||
if (GlobalState.runState.value != RunState.START) return
|
|
||||||
flClashVpnService?.startForeground(title, content)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
|
||||||
activity = binding.activity
|
|
||||||
binding.addActivityResultListener(::onActivityResult)
|
|
||||||
binding.addRequestPermissionsResultListener(::onRequestPermissionsResultListener)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean {
|
|
||||||
if (requestCode == VPN_PERMISSION_REQUEST_CODE) {
|
|
||||||
if (resultCode == FlutterActivity.RESULT_OK) {
|
|
||||||
bindService()
|
|
||||||
} else {
|
|
||||||
stopVpn()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onRequestPermissionsResultListener(
|
|
||||||
requestCode: Int,
|
|
||||||
permissions: Array<String>,
|
|
||||||
grantResults: IntArray
|
|
||||||
): Boolean {
|
|
||||||
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) {
|
|
||||||
isBlockNotification = true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun requestNotificationsPermission() {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
||||||
val permission = context?.let {
|
|
||||||
ContextCompat.checkSelfPermission(
|
|
||||||
it,
|
|
||||||
Manifest.permission.POST_NOTIFICATIONS
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
if (isBlockNotification) return
|
|
||||||
if (activity == null) return
|
|
||||||
ActivityCompat.requestPermissions(
|
|
||||||
activity!!,
|
|
||||||
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
|
||||||
NOTIFICATION_PERMISSION_REQUEST_CODE
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDetachedFromActivityForConfigChanges() {
|
|
||||||
activity = null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
|
|
||||||
activity = binding.activity
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDetachedFromActivity() {
|
|
||||||
activity = null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun bindService() {
|
|
||||||
val intent = Intent(context, FlClashVpnService::class.java)
|
|
||||||
context?.bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.follow.clash.plugins
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.follow.clash.GlobalState
|
||||||
|
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||||
|
import io.flutter.plugin.common.MethodCall
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
|
||||||
|
|
||||||
|
class ServicePlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
||||||
|
|
||||||
|
private lateinit var flutterMethodChannel: MethodChannel
|
||||||
|
|
||||||
|
private lateinit var context: Context
|
||||||
|
|
||||||
|
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
context = flutterPluginBinding.applicationContext
|
||||||
|
flutterMethodChannel = MethodChannel(flutterPluginBinding.binaryMessenger, "service")
|
||||||
|
flutterMethodChannel.setMethodCallHandler(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetachedFromEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
flutterMethodChannel.setMethodCallHandler(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) = when (call.method) {
|
||||||
|
"init" -> {
|
||||||
|
GlobalState.getCurrentAppPlugin()?.requestNotificationsPermission(context)
|
||||||
|
GlobalState.initServiceEngine(context)
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
"destroy" -> {
|
||||||
|
handleDestroy()
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleDestroy() {
|
||||||
|
GlobalState.getCurrentVPNPlugin()?.stop()
|
||||||
|
GlobalState.destroyServiceEngine()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
package com.follow.clash.plugins
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.ServiceConnection
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.util.Log
|
||||||
|
import com.follow.clash.BaseServiceInterface
|
||||||
|
import com.follow.clash.GlobalState
|
||||||
|
import com.follow.clash.RunState
|
||||||
|
import com.follow.clash.models.Props
|
||||||
|
import com.follow.clash.services.FlClashService
|
||||||
|
import com.follow.clash.services.FlClashVpnService
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||||
|
import io.flutter.plugin.common.MethodCall
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
import kotlin.concurrent.withLock
|
||||||
|
|
||||||
|
|
||||||
|
class VpnPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
||||||
|
private lateinit var flutterMethodChannel: MethodChannel
|
||||||
|
private lateinit var context: Context
|
||||||
|
private var flClashService: BaseServiceInterface? = null
|
||||||
|
private var port: Int = 7890
|
||||||
|
private var props: Props? = null
|
||||||
|
|
||||||
|
private val connection = object : ServiceConnection {
|
||||||
|
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||||
|
flClashService = when (service) {
|
||||||
|
is FlClashVpnService.LocalBinder -> service.getService()
|
||||||
|
is FlClashService.LocalBinder -> service.getService()
|
||||||
|
else -> throw Exception("invalid binder")
|
||||||
|
}
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceDisconnected(arg: ComponentName) {
|
||||||
|
flClashService = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
context = flutterPluginBinding.applicationContext
|
||||||
|
flutterMethodChannel = MethodChannel(flutterPluginBinding.binaryMessenger, "vpn")
|
||||||
|
flutterMethodChannel.setMethodCallHandler(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetachedFromEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
flutterMethodChannel.setMethodCallHandler(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) = when (call.method) {
|
||||||
|
|
||||||
|
"start" -> {
|
||||||
|
port = call.argument<Int>("port")!!
|
||||||
|
val args = call.argument<String>("args")
|
||||||
|
props =
|
||||||
|
if (args != null) Gson().fromJson(args, Props::class.java) else null
|
||||||
|
when (props?.enable == true) {
|
||||||
|
true -> handleStartVpn()
|
||||||
|
false -> start()
|
||||||
|
}
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
"stop" -> {
|
||||||
|
stop()
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
"setProtect" -> {
|
||||||
|
val fd = call.argument<Int>("fd")
|
||||||
|
if (fd != null) {
|
||||||
|
if (flClashService is FlClashVpnService) {
|
||||||
|
(flClashService as FlClashVpnService).protect(fd)
|
||||||
|
}
|
||||||
|
result.success(true)
|
||||||
|
} else {
|
||||||
|
result.success(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"startForeground" -> {
|
||||||
|
val title = call.argument<String>("title") as String
|
||||||
|
val content = call.argument<String>("content") as String
|
||||||
|
startForeground(title, content)
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ForegroundServiceType")
|
||||||
|
fun handleStartVpn() {
|
||||||
|
GlobalState.getCurrentAppPlugin()?.requestVpnPermission(context) {
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ForegroundServiceType")
|
||||||
|
private fun startForeground(title: String, content: String) {
|
||||||
|
GlobalState.runLock.withLock {
|
||||||
|
if (GlobalState.runState.value != RunState.START) return
|
||||||
|
flClashService?.startForeground(title, content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun start() {
|
||||||
|
if (flClashService == null) {
|
||||||
|
bindService()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
GlobalState.runLock.withLock {
|
||||||
|
if (GlobalState.runState.value == RunState.START) return
|
||||||
|
GlobalState.runState.value = RunState.START
|
||||||
|
val fd = flClashService?.start(port, props)
|
||||||
|
flutterMethodChannel.invokeMethod("started", fd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun stop() {
|
||||||
|
GlobalState.runLock.withLock {
|
||||||
|
if (GlobalState.runState.value == RunState.STOP) return
|
||||||
|
GlobalState.runState.value = RunState.STOP
|
||||||
|
flClashService?.stop()
|
||||||
|
}
|
||||||
|
GlobalState.destroyServiceEngine()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun bindService() {
|
||||||
|
val intent = when (props?.enable == true) {
|
||||||
|
true -> Intent(context, FlClashVpnService::class.java)
|
||||||
|
false -> Intent(context, FlClashService::class.java)
|
||||||
|
}
|
||||||
|
context.bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package com.follow.clash.services
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
|
||||||
|
import android.app.NotificationChannel
|
||||||
|
import android.app.NotificationManager
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.app.Service
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
|
||||||
|
import android.os.Binder
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.core.app.NotificationCompat
|
||||||
|
import com.follow.clash.BaseServiceInterface
|
||||||
|
import com.follow.clash.MainActivity
|
||||||
|
import com.follow.clash.models.Props
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint("WrongConstant")
|
||||||
|
class FlClashService : Service(), BaseServiceInterface {
|
||||||
|
|
||||||
|
private val binder = LocalBinder()
|
||||||
|
|
||||||
|
inner class LocalBinder : Binder() {
|
||||||
|
fun getService(): FlClashService = this@FlClashService
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBind(intent: Intent): IBinder {
|
||||||
|
return binder
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUnbind(intent: Intent?): Boolean {
|
||||||
|
return super.onUnbind(intent)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val CHANNEL = "FlClash"
|
||||||
|
|
||||||
|
private val notificationId: Int = 1
|
||||||
|
|
||||||
|
private val notificationBuilder: NotificationCompat.Builder by lazy {
|
||||||
|
val intent = Intent(this, MainActivity::class.java)
|
||||||
|
|
||||||
|
val pendingIntent = if (Build.VERSION.SDK_INT >= 31) {
|
||||||
|
PendingIntent.getActivity(
|
||||||
|
this,
|
||||||
|
0,
|
||||||
|
intent,
|
||||||
|
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
PendingIntent.getActivity(
|
||||||
|
this,
|
||||||
|
0,
|
||||||
|
intent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
)
|
||||||
|
}
|
||||||
|
with(NotificationCompat.Builder(this, CHANNEL)) {
|
||||||
|
setSmallIcon(com.follow.clash.R.drawable.ic_stat_name)
|
||||||
|
setContentTitle("FlClash")
|
||||||
|
setContentIntent(pendingIntent)
|
||||||
|
setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||||
|
priority = NotificationCompat.PRIORITY_MIN
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
foregroundServiceBehavior = FOREGROUND_SERVICE_IMMEDIATE
|
||||||
|
}
|
||||||
|
setOngoing(true)
|
||||||
|
setShowWhen(false)
|
||||||
|
setOnlyAlertOnce(true)
|
||||||
|
setAutoCancel(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun start(port: Int, props: Props?): Int? = null
|
||||||
|
|
||||||
|
override fun stop() {
|
||||||
|
stopSelf()
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ForegroundServiceType", "WrongConstant")
|
||||||
|
override fun startForeground(title: String, content: String) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
val manager = getSystemService(NotificationManager::class.java)
|
||||||
|
var channel = manager?.getNotificationChannel(CHANNEL)
|
||||||
|
if (channel == null) {
|
||||||
|
channel =
|
||||||
|
NotificationChannel(CHANNEL, "FlClash", NotificationManager.IMPORTANCE_LOW)
|
||||||
|
manager?.createNotificationChannel(channel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val notification =
|
||||||
|
notificationBuilder.setContentTitle(title).setContentText(content).build()
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
|
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
||||||
|
} else {
|
||||||
|
startForeground(notificationId, notification)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.follow.clash.services
|
package com.follow.clash.services
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
|
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
|
||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
@@ -15,6 +16,7 @@ import android.os.Parcel
|
|||||||
import android.os.RemoteException
|
import android.os.RemoteException
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
import com.follow.clash.BaseServiceInterface
|
||||||
import com.follow.clash.GlobalState
|
import com.follow.clash.GlobalState
|
||||||
import com.follow.clash.MainActivity
|
import com.follow.clash.MainActivity
|
||||||
import com.follow.clash.R
|
import com.follow.clash.R
|
||||||
@@ -25,10 +27,8 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
|
||||||
class FlClashVpnService : VpnService() {
|
@SuppressLint("WrongConstant")
|
||||||
private val CHANNEL = "FlClash"
|
class FlClashVpnService : VpnService(), BaseServiceInterface {
|
||||||
|
|
||||||
private val notificationId: Int = 1
|
|
||||||
|
|
||||||
private val passList = listOf(
|
private val passList = listOf(
|
||||||
"*zhihu.com",
|
"*zhihu.com",
|
||||||
@@ -52,10 +52,10 @@ class FlClashVpnService : VpnService() {
|
|||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
initServiceEngine()
|
GlobalState.initServiceEngine(applicationContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun start(port: Int, props: Props?): Int? {
|
override fun start(port: Int, props: Props?): Int? {
|
||||||
return with(Builder()) {
|
return with(Builder()) {
|
||||||
addAddress("172.16.0.1", 30)
|
addAddress("172.16.0.1", 30)
|
||||||
setMtu(9000)
|
setMtu(9000)
|
||||||
@@ -97,11 +97,18 @@ class FlClashVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stop() {
|
|
||||||
|
override fun stop() {
|
||||||
stopSelf()
|
stopSelf()
|
||||||
stopForeground()
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val CHANNEL = "FlClash"
|
||||||
|
|
||||||
|
private val notificationId: Int = 1
|
||||||
|
|
||||||
private val notificationBuilder: NotificationCompat.Builder by lazy {
|
private val notificationBuilder: NotificationCompat.Builder by lazy {
|
||||||
val intent = Intent(this, MainActivity::class.java)
|
val intent = Intent(this, MainActivity::class.java)
|
||||||
|
|
||||||
@@ -136,16 +143,8 @@ class FlClashVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initServiceEngine() {
|
@SuppressLint("ForegroundServiceType", "WrongConstant")
|
||||||
GlobalState.initServiceEngine(applicationContext)
|
override fun startForeground(title: String, content: String) {
|
||||||
}
|
|
||||||
|
|
||||||
override fun onTrimMemory(level: Int) {
|
|
||||||
super.onTrimMemory(level)
|
|
||||||
GlobalState.getCurrentAppPlugin()?.requestGc()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun startForeground(title: String, content: String) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
val manager = getSystemService(NotificationManager::class.java)
|
val manager = getSystemService(NotificationManager::class.java)
|
||||||
var channel = manager?.getNotificationChannel(CHANNEL)
|
var channel = manager?.getNotificationChannel(CHANNEL)
|
||||||
@@ -157,17 +156,16 @@ class FlClashVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
val notification =
|
val notification =
|
||||||
notificationBuilder.setContentTitle(title).setContentText(content).build()
|
notificationBuilder.setContentTitle(title).setContentText(content).build()
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
||||||
} else {
|
} else {
|
||||||
startForeground(notificationId, notification)
|
startForeground(notificationId, notification)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stopForeground() {
|
override fun onTrimMemory(level: Int) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
super.onTrimMemory(level)
|
||||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
GlobalState.getCurrentAppPlugin()?.requestGc()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val binder = LocalBinder()
|
private val binder = LocalBinder()
|
||||||
@@ -190,7 +188,6 @@ class FlClashVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onBind(intent: Intent): IBinder {
|
override fun onBind(intent: Intent): IBinder {
|
||||||
return binder
|
return binder
|
||||||
}
|
}
|
||||||
|
|||||||
Submodule core/Clash.Meta updated: 44d4b6dab2...0125a90a77
116
core/common.go
116
core/common.go
@@ -4,6 +4,16 @@ import "C"
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"math"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/metacubex/mihomo/adapter"
|
"github.com/metacubex/mihomo/adapter"
|
||||||
"github.com/metacubex/mihomo/adapter/inbound"
|
"github.com/metacubex/mihomo/adapter/inbound"
|
||||||
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
||||||
@@ -21,51 +31,8 @@ import (
|
|||||||
"github.com/metacubex/mihomo/log"
|
"github.com/metacubex/mihomo/log"
|
||||||
rp "github.com/metacubex/mihomo/rules/provider"
|
rp "github.com/metacubex/mihomo/rules/provider"
|
||||||
"github.com/metacubex/mihomo/tunnel"
|
"github.com/metacubex/mihomo/tunnel"
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
"syscall"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//type healthCheckSchema struct {
|
|
||||||
// Enable bool `provider:"enable"`
|
|
||||||
// URL string `provider:"url"`
|
|
||||||
// Interval int `provider:"interval"`
|
|
||||||
// TestTimeout int `provider:"timeout,omitempty"`
|
|
||||||
// Lazy bool `provider:"lazy,omitempty"`
|
|
||||||
// ExpectedStatus string `provider:"expected-status,omitempty"`
|
|
||||||
//}
|
|
||||||
|
|
||||||
//type proxyProviderSchema struct {
|
|
||||||
// Type string `provider:"type"`
|
|
||||||
// Path string `provider:"path,omitempty"`
|
|
||||||
// URL string `provider:"url,omitempty"`
|
|
||||||
// Proxy string `provider:"proxy,omitempty"`
|
|
||||||
// Interval int `provider:"interval,omitempty"`
|
|
||||||
// Filter string `provider:"filter,omitempty"`
|
|
||||||
// ExcludeFilter string `provider:"exclude-filter,omitempty"`
|
|
||||||
// ExcludeType string `provider:"exclude-type,omitempty"`
|
|
||||||
// DialerProxy string `provider:"dialer-proxy,omitempty"`
|
|
||||||
//
|
|
||||||
// HealthCheck healthCheckSchema `provider:"health-check,omitempty"`
|
|
||||||
// Override ap.OverrideSchema `provider:"override,omitempty"`
|
|
||||||
// Header map[string][]string `provider:"header,omitempty"`
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//type ruleProviderSchema struct {
|
|
||||||
// Type string `provider:"type"`
|
|
||||||
// Behavior string `provider:"behavior"`
|
|
||||||
// Path string `provider:"path,omitempty"`
|
|
||||||
// URL string `provider:"url,omitempty"`
|
|
||||||
// Proxy string `provider:"proxy,omitempty"`
|
|
||||||
// Format string `provider:"format,omitempty"`
|
|
||||||
// Interval int `provider:"interval,omitempty"`
|
|
||||||
//}
|
|
||||||
|
|
||||||
type ConfigExtendedParams struct {
|
type ConfigExtendedParams struct {
|
||||||
IsPatch bool `json:"is-patch"`
|
IsPatch bool `json:"is-patch"`
|
||||||
IsCompatible bool `json:"is-compatible"`
|
IsCompatible bool `json:"is-compatible"`
|
||||||
@@ -455,30 +422,63 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
|
|||||||
func patchConfig(general *config.General) {
|
func patchConfig(general *config.General) {
|
||||||
log.Infoln("[Apply] patch")
|
log.Infoln("[Apply] patch")
|
||||||
route.ReStartServer(general.ExternalController)
|
route.ReStartServer(general.ExternalController)
|
||||||
listener.SetAllowLan(general.AllowLan)
|
|
||||||
inbound.SetSkipAuthPrefixes(general.SkipAuthPrefixes)
|
|
||||||
inbound.SetAllowedIPs(general.LanAllowedIPs)
|
|
||||||
inbound.SetDisAllowedIPs(general.LanDisAllowedIPs)
|
|
||||||
listener.SetBindAddress(general.BindAddress)
|
|
||||||
tunnel.SetSniffing(general.Sniffing)
|
tunnel.SetSniffing(general.Sniffing)
|
||||||
tunnel.SetFindProcessMode(general.FindProcessMode)
|
tunnel.SetFindProcessMode(general.FindProcessMode)
|
||||||
dialer.SetTcpConcurrent(general.TCPConcurrent)
|
dialer.SetTcpConcurrent(general.TCPConcurrent)
|
||||||
dialer.DefaultInterface.Store(general.Interface)
|
dialer.DefaultInterface.Store(general.Interface)
|
||||||
adapter.UnifiedDelay.Store(general.UnifiedDelay)
|
adapter.UnifiedDelay.Store(general.UnifiedDelay)
|
||||||
|
tunnel.SetMode(general.Mode)
|
||||||
|
log.SetLevel(general.LogLevel)
|
||||||
|
resolver.DisableIPv6 = !general.IPv6
|
||||||
|
}
|
||||||
|
|
||||||
|
var isRunning = false
|
||||||
|
|
||||||
|
var runLock sync.Mutex
|
||||||
|
|
||||||
|
func updateListeners(general *config.General, listeners map[string]constant.InboundListener) {
|
||||||
|
listener.PatchInboundListeners(listeners, tunnel.Tunnel, true)
|
||||||
|
listener.SetAllowLan(general.AllowLan)
|
||||||
|
inbound.SetSkipAuthPrefixes(general.SkipAuthPrefixes)
|
||||||
|
inbound.SetAllowedIPs(general.LanAllowedIPs)
|
||||||
|
inbound.SetDisAllowedIPs(general.LanDisAllowedIPs)
|
||||||
|
listener.SetBindAddress(general.BindAddress)
|
||||||
listener.ReCreateHTTP(general.Port, tunnel.Tunnel)
|
listener.ReCreateHTTP(general.Port, tunnel.Tunnel)
|
||||||
listener.ReCreateSocks(general.SocksPort, tunnel.Tunnel)
|
listener.ReCreateSocks(general.SocksPort, tunnel.Tunnel)
|
||||||
listener.ReCreateRedir(general.RedirPort, tunnel.Tunnel)
|
listener.ReCreateRedir(general.RedirPort, tunnel.Tunnel)
|
||||||
listener.ReCreateAutoRedir(general.EBpf.AutoRedir, tunnel.Tunnel)
|
listener.ReCreateAutoRedir(general.EBpf.AutoRedir, tunnel.Tunnel)
|
||||||
listener.ReCreateTProxy(general.TProxyPort, tunnel.Tunnel)
|
listener.ReCreateTProxy(general.TProxyPort, tunnel.Tunnel)
|
||||||
listener.ReCreateTun(general.Tun, tunnel.Tunnel)
|
|
||||||
listener.ReCreateMixed(general.MixedPort, tunnel.Tunnel)
|
listener.ReCreateMixed(general.MixedPort, tunnel.Tunnel)
|
||||||
listener.ReCreateShadowSocks(general.ShadowSocksConfig, tunnel.Tunnel)
|
listener.ReCreateShadowSocks(general.ShadowSocksConfig, tunnel.Tunnel)
|
||||||
listener.ReCreateVmess(general.VmessConfig, tunnel.Tunnel)
|
listener.ReCreateVmess(general.VmessConfig, tunnel.Tunnel)
|
||||||
listener.ReCreateTuic(general.TuicServer, tunnel.Tunnel)
|
listener.ReCreateTuic(general.TuicServer, tunnel.Tunnel)
|
||||||
tunnel.SetMode(general.Mode)
|
listener.ReCreateTun(general.Tun, tunnel.Tunnel)
|
||||||
log.SetLevel(general.LogLevel)
|
listener.ReCreateRedirToTun(general.EBpf.RedirectToTun)
|
||||||
|
}
|
||||||
|
|
||||||
|
func stopListeners() {
|
||||||
|
listener.StopListener()
|
||||||
|
}
|
||||||
|
|
||||||
|
func hcCompatibleProvider(proxyProviders map[string]cp.ProxyProvider) {
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
ch := make(chan struct{}, math.MaxInt)
|
||||||
|
for _, proxyProvider := range proxyProviders {
|
||||||
|
proxyProvider := proxyProvider
|
||||||
|
if proxyProvider.VehicleType() == cp.Compatible {
|
||||||
|
log.Infoln("Start initial Compatible provider %s", proxyProvider.Name())
|
||||||
|
wg.Add(1)
|
||||||
|
ch <- struct{}{}
|
||||||
|
go func() {
|
||||||
|
defer func() { <-ch; wg.Done() }()
|
||||||
|
if err := proxyProvider.Initial(); err != nil {
|
||||||
|
log.Errorln("initial Compatible provider %s error: %v", proxyProvider.Name(), err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
resolver.DisableIPv6 = !general.IPv6
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func patchSelectGroup() {
|
func patchSelectGroup() {
|
||||||
@@ -506,12 +506,8 @@ func patchSelectGroup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var applyLock sync.Mutex
|
|
||||||
|
|
||||||
func applyConfig() error {
|
func applyConfig() error {
|
||||||
applyLock.Lock()
|
cfg, err := config.ParseRawConfig(currentRawConfig)
|
||||||
defer applyLock.Unlock()
|
|
||||||
cfg, err := config.ParseRawConfig(currentConfig)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cfg, _ = config.ParseRawConfig(config.DefaultRawConfig())
|
cfg, _ = config.ParseRawConfig(config.DefaultRawConfig())
|
||||||
}
|
}
|
||||||
@@ -523,9 +519,13 @@ func applyConfig() error {
|
|||||||
} else {
|
} else {
|
||||||
closeConnections()
|
closeConnections()
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
hub.UltraApplyConfig(cfg, true)
|
hub.UltraApplyConfig(cfg)
|
||||||
patchSelectGroup()
|
patchSelectGroup()
|
||||||
}
|
}
|
||||||
|
if isRunning {
|
||||||
|
updateListeners(cfg.General, cfg.Listeners)
|
||||||
|
hcCompatibleProvider(cfg.Providers)
|
||||||
|
}
|
||||||
externalProviders = getExternalProvidersRaw()
|
externalProviders = getExternalProvidersRaw()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
37
core/hub.go
37
core/hub.go
@@ -8,6 +8,13 @@ import (
|
|||||||
bridge "core/dart-bridge"
|
bridge "core/dart-bridge"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"sort"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/metacubex/mihomo/adapter"
|
"github.com/metacubex/mihomo/adapter"
|
||||||
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
||||||
"github.com/metacubex/mihomo/adapter/provider"
|
"github.com/metacubex/mihomo/adapter/provider"
|
||||||
@@ -21,14 +28,9 @@ import (
|
|||||||
"github.com/metacubex/mihomo/tunnel"
|
"github.com/metacubex/mihomo/tunnel"
|
||||||
"github.com/metacubex/mihomo/tunnel/statistic"
|
"github.com/metacubex/mihomo/tunnel/statistic"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"os"
|
|
||||||
"runtime"
|
|
||||||
"sort"
|
|
||||||
"time"
|
|
||||||
"unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var currentConfig = config.DefaultRawConfig()
|
var currentRawConfig = config.DefaultRawConfig()
|
||||||
|
|
||||||
var configParams = ConfigExtendedParams{}
|
var configParams = ConfigExtendedParams{}
|
||||||
|
|
||||||
@@ -36,6 +38,21 @@ var externalProviders = map[string]cp.Provider{}
|
|||||||
|
|
||||||
var isInit = false
|
var isInit = false
|
||||||
|
|
||||||
|
//export start
|
||||||
|
func start() {
|
||||||
|
runLock.Lock()
|
||||||
|
defer runLock.Unlock()
|
||||||
|
isRunning = true
|
||||||
|
}
|
||||||
|
|
||||||
|
//export stop
|
||||||
|
func stop() {
|
||||||
|
runLock.Lock()
|
||||||
|
defer runLock.Unlock()
|
||||||
|
isRunning = false
|
||||||
|
stopListeners()
|
||||||
|
}
|
||||||
|
|
||||||
//export initClash
|
//export initClash
|
||||||
func initClash(homeDirStr *C.char) bool {
|
func initClash(homeDirStr *C.char) bool {
|
||||||
if !isInit {
|
if !isInit {
|
||||||
@@ -59,10 +76,10 @@ func restartClash() bool {
|
|||||||
|
|
||||||
//export shutdownClash
|
//export shutdownClash
|
||||||
func shutdownClash() bool {
|
func shutdownClash() bool {
|
||||||
|
stopListeners()
|
||||||
executor.Shutdown()
|
executor.Shutdown()
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
isInit = false
|
isInit = false
|
||||||
currentConfig = nil
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,11 +105,15 @@ func validateConfig(s *C.char, port C.longlong) {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var updateLock sync.Mutex
|
||||||
|
|
||||||
//export updateConfig
|
//export updateConfig
|
||||||
func updateConfig(s *C.char, port C.longlong) {
|
func updateConfig(s *C.char, port C.longlong) {
|
||||||
i := int64(port)
|
i := int64(port)
|
||||||
paramsString := C.GoString(s)
|
paramsString := C.GoString(s)
|
||||||
go func() {
|
go func() {
|
||||||
|
updateLock.Lock()
|
||||||
|
defer updateLock.Unlock()
|
||||||
var params = &GenerateConfigParams{}
|
var params = &GenerateConfigParams{}
|
||||||
err := json.Unmarshal([]byte(paramsString), params)
|
err := json.Unmarshal([]byte(paramsString), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -101,7 +122,7 @@ func updateConfig(s *C.char, port C.longlong) {
|
|||||||
}
|
}
|
||||||
configParams = params.Params
|
configParams = params.Params
|
||||||
prof := decorationConfig(params.ProfileId, params.Config)
|
prof := decorationConfig(params.ProfileId, params.Config)
|
||||||
currentConfig = prof
|
currentRawConfig = prof
|
||||||
err = applyConfig()
|
err = applyConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bridge.SendToPort(i, err.Error())
|
bridge.SendToPort(i, err.Error())
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ type AccessControl struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AndroidProps struct {
|
type AndroidProps struct {
|
||||||
|
Enable bool `json:"enable"`
|
||||||
AccessControl *AccessControl `json:"accessControl"`
|
AccessControl *AccessControl `json:"accessControl"`
|
||||||
AllowBypass bool `json:"allowBypass"`
|
AllowBypass bool `json:"allowBypass"`
|
||||||
SystemProxy bool `json:"systemProxy"`
|
SystemProxy bool `json:"systemProxy"`
|
||||||
|
|||||||
27
core/tun.go
27
core/tun.go
@@ -7,14 +7,15 @@ import (
|
|||||||
"core/platform"
|
"core/platform"
|
||||||
t "core/tun"
|
t "core/tun"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/metacubex/mihomo/component/dialer"
|
|
||||||
"github.com/metacubex/mihomo/log"
|
|
||||||
"golang.org/x/sync/semaphore"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/metacubex/mihomo/component/dialer"
|
||||||
|
"github.com/metacubex/mihomo/log"
|
||||||
|
"golang.org/x/sync/semaphore"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tunLock sync.Mutex
|
var tunLock sync.Mutex
|
||||||
@@ -40,6 +41,18 @@ var fdMap FdMap
|
|||||||
func startTUN(fd C.int, port C.longlong) {
|
func startTUN(fd C.int, port C.longlong) {
|
||||||
i := int64(port)
|
i := int64(port)
|
||||||
ServicePort = i
|
ServicePort = i
|
||||||
|
if fd == 0 {
|
||||||
|
tunLock.Lock()
|
||||||
|
defer tunLock.Unlock()
|
||||||
|
now := time.Now()
|
||||||
|
runTime = &now
|
||||||
|
SendMessage(Message{
|
||||||
|
Type: StartedMessage,
|
||||||
|
Data: strconv.FormatInt(runTime.UnixMilli(), 10),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
initSocketHook()
|
||||||
go func() {
|
go func() {
|
||||||
tunLock.Lock()
|
tunLock.Lock()
|
||||||
defer tunLock.Unlock()
|
defer tunLock.Unlock()
|
||||||
@@ -88,6 +101,7 @@ func getRunTime() *C.char {
|
|||||||
|
|
||||||
//export stopTun
|
//export stopTun
|
||||||
func stopTun() {
|
func stopTun() {
|
||||||
|
removeSocketHook()
|
||||||
go func() {
|
go func() {
|
||||||
tunLock.Lock()
|
tunLock.Lock()
|
||||||
defer tunLock.Unlock()
|
defer tunLock.Unlock()
|
||||||
@@ -95,6 +109,7 @@ func stopTun() {
|
|||||||
runTime = nil
|
runTime = nil
|
||||||
|
|
||||||
if tun != nil {
|
if tun != nil {
|
||||||
|
log.Errorln("[Tun] stopTun")
|
||||||
tun.Close()
|
tun.Close()
|
||||||
tun = nil
|
tun = nil
|
||||||
}
|
}
|
||||||
@@ -125,7 +140,7 @@ func markSocket(fd Fd) {
|
|||||||
|
|
||||||
var fdCounter int64 = 0
|
var fdCounter int64 = 0
|
||||||
|
|
||||||
func init() {
|
func initSocketHook() {
|
||||||
dialer.DefaultSocketHook = func(network, address string, conn syscall.RawConn) error {
|
dialer.DefaultSocketHook = func(network, address string, conn syscall.RawConn) error {
|
||||||
if platform.ShouldBlockConnection() {
|
if platform.ShouldBlockConnection() {
|
||||||
return errBlocked
|
return errBlocked
|
||||||
@@ -159,3 +174,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeSocketHook() {
|
||||||
|
dialer.DefaultSocketHook = nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:dynamic_color/dynamic_color.dart';
|
|||||||
import 'package:fl_clash/l10n/l10n.dart';
|
import 'package:fl_clash/l10n/l10n.dart';
|
||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
|
import 'package:fl_clash/widgets/proxy_container.dart';
|
||||||
import 'package:fl_clash/widgets/widgets.dart';
|
import 'package:fl_clash/widgets/widgets.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
@@ -95,7 +96,9 @@ class ApplicationState extends State<Application> {
|
|||||||
if (system.isDesktop) {
|
if (system.isDesktop) {
|
||||||
return WindowContainer(
|
return WindowContainer(
|
||||||
child: TrayContainer(
|
child: TrayContainer(
|
||||||
child: app,
|
child: ProxyContainer(
|
||||||
|
child: app,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -121,59 +124,65 @@ class ApplicationState extends State<Application> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(context) {
|
Widget build(context) {
|
||||||
return AppStateContainer(
|
return _buildApp(
|
||||||
child: ClashContainer(
|
AppStateContainer(
|
||||||
child: Selector2<AppState, Config, ApplicationSelectorState>(
|
child: ClashContainer(
|
||||||
selector: (_, appState, config) => ApplicationSelectorState(
|
child: Selector2<AppState, Config, ApplicationSelectorState>(
|
||||||
locale: config.locale,
|
selector: (_, appState, config) => ApplicationSelectorState(
|
||||||
themeMode: config.themeMode,
|
locale: config.locale,
|
||||||
primaryColor: config.primaryColor,
|
themeMode: config.themeMode,
|
||||||
prueBlack: config.prueBlack,
|
primaryColor: config.primaryColor,
|
||||||
),
|
prueBlack: config.prueBlack,
|
||||||
builder: (_, state, child) {
|
),
|
||||||
return DynamicColorBuilder(
|
builder: (_, state, child) {
|
||||||
builder: (lightDynamic, darkDynamic) {
|
return DynamicColorBuilder(
|
||||||
_updateSystemColorSchemes(lightDynamic, darkDynamic);
|
builder: (lightDynamic, darkDynamic) {
|
||||||
return MaterialApp(
|
_updateSystemColorSchemes(lightDynamic, darkDynamic);
|
||||||
navigatorKey: globalState.navigatorKey,
|
return MaterialApp(
|
||||||
localizationsDelegates: const [
|
navigatorKey: globalState.navigatorKey,
|
||||||
AppLocalizations.delegate,
|
localizationsDelegates: const [
|
||||||
GlobalMaterialLocalizations.delegate,
|
AppLocalizations.delegate,
|
||||||
GlobalCupertinoLocalizations.delegate,
|
GlobalMaterialLocalizations.delegate,
|
||||||
GlobalWidgetsLocalizations.delegate
|
GlobalCupertinoLocalizations.delegate,
|
||||||
],
|
GlobalWidgetsLocalizations.delegate
|
||||||
builder: (_, child) {
|
],
|
||||||
return _buildApp(child!);
|
builder: (_, child) {
|
||||||
},
|
if (system.isDesktop) {
|
||||||
scrollBehavior: BaseScrollBehavior(),
|
return WindowHeaderContainer(child: child!);
|
||||||
title: appName,
|
}
|
||||||
locale: other.getLocaleForString(state.locale),
|
return child!;
|
||||||
supportedLocales: AppLocalizations.delegate.supportedLocales,
|
},
|
||||||
themeMode: state.themeMode,
|
scrollBehavior: BaseScrollBehavior(),
|
||||||
theme: ThemeData(
|
title: appName,
|
||||||
useMaterial3: true,
|
locale: other.getLocaleForString(state.locale),
|
||||||
pageTransitionsTheme: _pageTransitionsTheme,
|
supportedLocales:
|
||||||
colorScheme: _getAppColorScheme(
|
AppLocalizations.delegate.supportedLocales,
|
||||||
brightness: Brightness.light,
|
themeMode: state.themeMode,
|
||||||
systemColorSchemes: systemColorSchemes,
|
theme: ThemeData(
|
||||||
primaryColor: state.primaryColor,
|
useMaterial3: true,
|
||||||
|
pageTransitionsTheme: _pageTransitionsTheme,
|
||||||
|
colorScheme: _getAppColorScheme(
|
||||||
|
brightness: Brightness.light,
|
||||||
|
systemColorSchemes: systemColorSchemes,
|
||||||
|
primaryColor: state.primaryColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
darkTheme: ThemeData(
|
||||||
darkTheme: ThemeData(
|
useMaterial3: true,
|
||||||
useMaterial3: true,
|
pageTransitionsTheme: _pageTransitionsTheme,
|
||||||
pageTransitionsTheme: _pageTransitionsTheme,
|
colorScheme: _getAppColorScheme(
|
||||||
colorScheme: _getAppColorScheme(
|
brightness: Brightness.dark,
|
||||||
brightness: Brightness.dark,
|
systemColorSchemes: systemColorSchemes,
|
||||||
systemColorSchemes: systemColorSchemes,
|
primaryColor: state.primaryColor,
|
||||||
primaryColor: state.primaryColor,
|
).toPrueBlack(state.prueBlack),
|
||||||
).toPrueBlack(state.prueBlack),
|
),
|
||||||
),
|
home: child,
|
||||||
home: child,
|
);
|
||||||
);
|
},
|
||||||
},
|
);
|
||||||
);
|
},
|
||||||
},
|
child: const HomePage(),
|
||||||
child: const HomePage(),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -237,6 +237,14 @@ class ClashCore {
|
|||||||
malloc.free(paramsChar);
|
malloc.free(paramsChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
clashFFI.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
clashFFI.stop();
|
||||||
|
}
|
||||||
|
|
||||||
Future<Delay> getDelay(String proxyName) {
|
Future<Delay> getDelay(String proxyName) {
|
||||||
final delayParams = {
|
final delayParams = {
|
||||||
"proxy-name": proxyName,
|
"proxy-name": proxyName,
|
||||||
|
|||||||
@@ -5144,6 +5144,22 @@ class ClashFFI {
|
|||||||
late final __FCmulcr =
|
late final __FCmulcr =
|
||||||
__FCmulcrPtr.asFunction<_Fcomplex Function(_Fcomplex, double)>();
|
__FCmulcrPtr.asFunction<_Fcomplex Function(_Fcomplex, double)>();
|
||||||
|
|
||||||
|
void start() {
|
||||||
|
return _start();
|
||||||
|
}
|
||||||
|
|
||||||
|
late final _startPtr =
|
||||||
|
_lookup<ffi.NativeFunction<ffi.Void Function()>>('start');
|
||||||
|
late final _start = _startPtr.asFunction<void Function()>();
|
||||||
|
|
||||||
|
void stop() {
|
||||||
|
return _stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
late final _stopPtr =
|
||||||
|
_lookup<ffi.NativeFunction<ffi.Void Function()>>('stop');
|
||||||
|
late final _stop = _stopPtr.asFunction<void Function()>();
|
||||||
|
|
||||||
int initClash(
|
int initClash(
|
||||||
ffi.Pointer<ffi.Char> homeDirStr,
|
ffi.Pointer<ffi.Char> homeDirStr,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ export 'app_localizations.dart';
|
|||||||
export 'function.dart';
|
export 'function.dart';
|
||||||
export 'package.dart';
|
export 'package.dart';
|
||||||
export 'measure.dart';
|
export 'measure.dart';
|
||||||
export 'service.dart';
|
export 'windows.dart';
|
||||||
export 'iterable.dart';
|
export 'iterable.dart';
|
||||||
export 'scroll.dart';
|
export 'scroll.dart';
|
||||||
@@ -24,17 +24,71 @@ class AutoLaunch {
|
|||||||
return await launchAtStartup.isEnabled();
|
return await launchAtStartup.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> get windowsIsEnable async {
|
||||||
|
final res = await Process.run(
|
||||||
|
'schtasks',
|
||||||
|
['/Query', '/TN', appName, '/V', "/FO", "LIST"],
|
||||||
|
runInShell: true,
|
||||||
|
);
|
||||||
|
return res.stdout.toString().contains(Platform.resolvedExecutable);
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> enable() async {
|
Future<bool> enable() async {
|
||||||
return await launchAtStartup.enable();
|
return await launchAtStartup.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
windowsDisable() async {
|
||||||
|
final res = await Process.run(
|
||||||
|
'schtasks',
|
||||||
|
[
|
||||||
|
'/Delete',
|
||||||
|
'/TN',
|
||||||
|
appName,
|
||||||
|
'/F',
|
||||||
|
],
|
||||||
|
runInShell: true,
|
||||||
|
);
|
||||||
|
return res.exitCode == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
windowsEnable() async {
|
||||||
|
await Process.run(
|
||||||
|
'schtasks',
|
||||||
|
[
|
||||||
|
'/Create',
|
||||||
|
'/SC',
|
||||||
|
'ONLOGON',
|
||||||
|
'/TN',
|
||||||
|
appName,
|
||||||
|
'/TR',
|
||||||
|
Platform.resolvedExecutable,
|
||||||
|
'/RL',
|
||||||
|
'HIGHEST',
|
||||||
|
'/F'
|
||||||
|
],
|
||||||
|
runInShell: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> disable() async {
|
Future<bool> disable() async {
|
||||||
return await launchAtStartup.disable();
|
return await launchAtStartup.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStatus(bool value) async {
|
updateStatus(bool value) async {
|
||||||
final isEnable = await this.isEnable;
|
final currentEnable =
|
||||||
if (isEnable == value) return;
|
Platform.isWindows ? await windowsIsEnable : await isEnable;
|
||||||
|
if (value == currentEnable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Platform.isWindows) {
|
||||||
|
if (value) {
|
||||||
|
enable();
|
||||||
|
windowsEnable();
|
||||||
|
} else {
|
||||||
|
windowsDisable();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (value == true) {
|
if (value == true) {
|
||||||
enable();
|
enable();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import 'dart:typed_data';
|
|||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:lpinyin/lpinyin.dart';
|
|
||||||
import 'package:zxing2/qrcode.dart';
|
import 'package:zxing2/qrcode.dart';
|
||||||
import 'package:image/image.dart' as img;
|
import 'package:image/image.dart' as img;
|
||||||
|
|
||||||
@@ -192,7 +191,6 @@ class Other {
|
|||||||
return ViewMode.desktop;
|
return ViewMode.desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int getProxiesColumns(double viewWidth, ProxiesLayout proxiesLayout) {
|
int getProxiesColumns(double viewWidth, ProxiesLayout proxiesLayout) {
|
||||||
final columns = max((viewWidth / 300).ceil(), 2);
|
final columns = max((viewWidth / 300).ceil(), 2);
|
||||||
return switch (proxiesLayout) {
|
return switch (proxiesLayout) {
|
||||||
|
|||||||
@@ -1,37 +1,4 @@
|
|||||||
import 'package:fl_clash/common/datetime.dart';
|
import 'package:fl_clash/common/system.dart';
|
||||||
import 'package:fl_clash/plugins/proxy.dart';
|
import 'package:proxy/proxy.dart';
|
||||||
import 'package:proxy/proxy.dart' as proxy_plugin;
|
|
||||||
import 'package:proxy/proxy_platform_interface.dart';
|
|
||||||
|
|
||||||
class ProxyManager {
|
final proxy = system.isDesktop ? Proxy() : null;
|
||||||
static ProxyManager? _instance;
|
|
||||||
late ProxyPlatform _proxy;
|
|
||||||
|
|
||||||
ProxyManager._internal() {
|
|
||||||
_proxy = proxy ?? proxy_plugin.Proxy();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get isStart => startTime != null && startTime!.isBeforeNow;
|
|
||||||
|
|
||||||
DateTime? get startTime => _proxy.startTime;
|
|
||||||
|
|
||||||
Future<bool?> startProxy({required int port}) async {
|
|
||||||
return await _proxy.startProxy(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool?> stopProxy() async {
|
|
||||||
return await _proxy.stopProxy();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<DateTime?> updateStartTime() async {
|
|
||||||
if (_proxy is! Proxy) return null;
|
|
||||||
return await (_proxy as Proxy).updateStartTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
factory ProxyManager() {
|
|
||||||
_instance ??= ProxyManager._internal();
|
|
||||||
return _instance!;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final proxyManager = ProxyManager();
|
|
||||||
|
|||||||
@@ -101,6 +101,9 @@ class Request {
|
|||||||
return source.value(response.data!);
|
return source.value(response.data!);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if(cancelToken?.isCancelled == true){
|
||||||
|
throw "cancelled";
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,110 +0,0 @@
|
|||||||
import 'dart:ffi';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'package:ffi/ffi.dart';
|
|
||||||
import 'package:win32/win32.dart';
|
|
||||||
|
|
||||||
typedef CreateServiceNative = IntPtr Function(
|
|
||||||
IntPtr hSCManager,
|
|
||||||
Pointer<Utf16> lpServiceName,
|
|
||||||
Pointer<Utf16> lpDisplayName,
|
|
||||||
Uint32 dwDesiredAccess,
|
|
||||||
Uint32 dwServiceType,
|
|
||||||
Uint32 dwStartType,
|
|
||||||
Uint32 dwErrorControl,
|
|
||||||
Pointer<Utf16> lpBinaryPathName,
|
|
||||||
Pointer<Utf16> lpLoadOrderGroup,
|
|
||||||
Pointer<Uint32> lpdwTagId,
|
|
||||||
Pointer<Utf16> lpDependencies,
|
|
||||||
Pointer<Utf16> lpServiceStartName,
|
|
||||||
Pointer<Utf16> lpPassword,
|
|
||||||
);
|
|
||||||
|
|
||||||
typedef CreateServiceDart = int Function(
|
|
||||||
int hSCManager,
|
|
||||||
Pointer<Utf16> lpServiceName,
|
|
||||||
Pointer<Utf16> lpDisplayName,
|
|
||||||
int dwDesiredAccess,
|
|
||||||
int dwServiceType,
|
|
||||||
int dwStartType,
|
|
||||||
int dwErrorControl,
|
|
||||||
Pointer<Utf16> lpBinaryPathName,
|
|
||||||
Pointer<Utf16> lpLoadOrderGroup,
|
|
||||||
Pointer<Uint32> lpdwTagId,
|
|
||||||
Pointer<Utf16> lpDependencies,
|
|
||||||
Pointer<Utf16> lpServiceStartName,
|
|
||||||
Pointer<Utf16> lpPassword,
|
|
||||||
);
|
|
||||||
|
|
||||||
const _SERVICE_ALL_ACCESS = 0xF003F;
|
|
||||||
|
|
||||||
const _SERVICE_WIN32_OWN_PROCESS = 0x00000010;
|
|
||||||
|
|
||||||
const _SERVICE_AUTO_START = 0x00000002;
|
|
||||||
|
|
||||||
const _SERVICE_ERROR_NORMAL = 0x00000001;
|
|
||||||
|
|
||||||
typedef GetLastErrorNative = Uint32 Function();
|
|
||||||
typedef GetLastErrorDart = int Function();
|
|
||||||
|
|
||||||
class Service {
|
|
||||||
static Service? _instance;
|
|
||||||
late DynamicLibrary _advapi32;
|
|
||||||
|
|
||||||
Service._internal() {
|
|
||||||
_advapi32 = DynamicLibrary.open('advapi32.dll');
|
|
||||||
}
|
|
||||||
|
|
||||||
factory Service() {
|
|
||||||
_instance ??= Service._internal();
|
|
||||||
return _instance!;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> createService() async {
|
|
||||||
final int scManager = OpenSCManager(nullptr, nullptr, _SERVICE_ALL_ACCESS);
|
|
||||||
if (scManager == 0) return;
|
|
||||||
final serviceName = 'FlClash Service'.toNativeUtf16();
|
|
||||||
final displayName = 'FlClash Service'.toNativeUtf16();
|
|
||||||
final binaryPathName = "C:\\Application\\Clash.Verge_1.6.6_x64_portable\\resources\\clash-verge-service.exe".toNativeUtf16();
|
|
||||||
final createService =
|
|
||||||
_advapi32.lookupFunction<CreateServiceNative, CreateServiceDart>(
|
|
||||||
'CreateServiceW',
|
|
||||||
);
|
|
||||||
final getLastError = DynamicLibrary.open('kernel32.dll')
|
|
||||||
.lookupFunction<GetLastErrorNative, GetLastErrorDart>('GetLastError');
|
|
||||||
|
|
||||||
final serviceHandle = createService(
|
|
||||||
scManager,
|
|
||||||
serviceName,
|
|
||||||
displayName,
|
|
||||||
_SERVICE_ALL_ACCESS,
|
|
||||||
_SERVICE_WIN32_OWN_PROCESS,
|
|
||||||
_SERVICE_AUTO_START,
|
|
||||||
_SERVICE_ERROR_NORMAL,
|
|
||||||
binaryPathName,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
);
|
|
||||||
|
|
||||||
print("serviceHandle $serviceHandle");
|
|
||||||
|
|
||||||
final errorCode = GetLastError();
|
|
||||||
print('Error code: $errorCode');
|
|
||||||
|
|
||||||
final result = StartService(serviceHandle, 0, nullptr);
|
|
||||||
|
|
||||||
if (result == 0) {
|
|
||||||
print('Failed to start the service.');
|
|
||||||
} else {
|
|
||||||
print('Service started successfully.');
|
|
||||||
}
|
|
||||||
|
|
||||||
calloc.free(serviceName);
|
|
||||||
calloc.free(displayName);
|
|
||||||
calloc.free(binaryPathName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final service = Platform.isWindows ? Service() : null;
|
|
||||||
@@ -34,7 +34,7 @@ class Window {
|
|||||||
// await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
|
// await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
|
||||||
// }
|
// }
|
||||||
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||||
await windowManager.setPreventClose(true);
|
// await windowManager.setPreventClose(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
58
lib/common/windows.dart
Normal file
58
lib/common/windows.dart
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import 'dart:ffi';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:ffi/ffi.dart';
|
||||||
|
|
||||||
|
class Windows {
|
||||||
|
static Windows? _instance;
|
||||||
|
late DynamicLibrary _shell32;
|
||||||
|
|
||||||
|
Windows._internal() {
|
||||||
|
_shell32 = DynamicLibrary.open('shell32.dll');
|
||||||
|
}
|
||||||
|
|
||||||
|
factory Windows() {
|
||||||
|
_instance ??= Windows._internal();
|
||||||
|
return _instance!;
|
||||||
|
}
|
||||||
|
|
||||||
|
void runAsAdministrator(String command, String arguments) async {
|
||||||
|
final commandPtr = command.toNativeUtf16();
|
||||||
|
final argumentsPtr = arguments.toNativeUtf16();
|
||||||
|
final operationPtr = 'runas'.toNativeUtf16();
|
||||||
|
|
||||||
|
final shellExecute = _shell32.lookupFunction<
|
||||||
|
Int32 Function(
|
||||||
|
Pointer<Utf16> hwnd,
|
||||||
|
Pointer<Utf16> lpOperation,
|
||||||
|
Pointer<Utf16> lpFile,
|
||||||
|
Pointer<Utf16> lpParameters,
|
||||||
|
Pointer<Utf16> lpDirectory,
|
||||||
|
Int32 nShowCmd),
|
||||||
|
int Function(
|
||||||
|
Pointer<Utf16> hwnd,
|
||||||
|
Pointer<Utf16> lpOperation,
|
||||||
|
Pointer<Utf16> lpFile,
|
||||||
|
Pointer<Utf16> lpParameters,
|
||||||
|
Pointer<Utf16> lpDirectory,
|
||||||
|
int nShowCmd)>('ShellExecuteW');
|
||||||
|
|
||||||
|
final result = shellExecute(
|
||||||
|
nullptr,
|
||||||
|
operationPtr,
|
||||||
|
commandPtr,
|
||||||
|
argumentsPtr,
|
||||||
|
nullptr,
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
|
||||||
|
calloc.free(commandPtr);
|
||||||
|
calloc.free(argumentsPtr);
|
||||||
|
calloc.free(operationPtr);
|
||||||
|
|
||||||
|
if (result <= 32) {
|
||||||
|
throw Exception('Failed to launch $command with UAC');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final windows = Platform.isWindows ? Windows() : null;
|
||||||
@@ -2,7 +2,6 @@ import 'dart:async';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import 'package:archive/archive.dart';
|
import 'package:archive/archive.dart';
|
||||||
import 'package:fl_clash/common/archive.dart';
|
import 'package:fl_clash/common/archive.dart';
|
||||||
@@ -44,10 +43,9 @@ class AppController {
|
|||||||
measure = Measure.of(context);
|
measure = Measure.of(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateSystemProxy(bool isStart) async {
|
updateStatus(bool isStart) async {
|
||||||
if (isStart) {
|
if (isStart) {
|
||||||
await globalState.startSystemProxy(
|
await globalState.handleStart(
|
||||||
appState: appState,
|
|
||||||
config: config,
|
config: config,
|
||||||
clashConfig: clashConfig,
|
clashConfig: clashConfig,
|
||||||
);
|
);
|
||||||
@@ -60,7 +58,7 @@ class AppController {
|
|||||||
if (Platform.isAndroid) return;
|
if (Platform.isAndroid) return;
|
||||||
await applyProfile(isPrue: true);
|
await applyProfile(isPrue: true);
|
||||||
} else {
|
} else {
|
||||||
await globalState.stopSystemProxy();
|
await globalState.handleStop();
|
||||||
clashCore.resetTraffic();
|
clashCore.resetTraffic();
|
||||||
appState.traffics = [];
|
appState.traffics = [];
|
||||||
appState.totalTraffic = Traffic();
|
appState.totalTraffic = Traffic();
|
||||||
@@ -74,8 +72,9 @@ class AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateRunTime() {
|
updateRunTime() {
|
||||||
if (proxyManager.startTime != null) {
|
final startTime = globalState.startTime;
|
||||||
final startTimeStamp = proxyManager.startTime!.millisecondsSinceEpoch;
|
if (startTime != null) {
|
||||||
|
final startTimeStamp = startTime.millisecondsSinceEpoch;
|
||||||
final nowTimeStamp = DateTime.now().millisecondsSinceEpoch;
|
final nowTimeStamp = DateTime.now().millisecondsSinceEpoch;
|
||||||
appState.runTime = nowTimeStamp - startTimeStamp;
|
appState.runTime = nowTimeStamp - startTimeStamp;
|
||||||
} else {
|
} else {
|
||||||
@@ -103,7 +102,7 @@ class AppController {
|
|||||||
final updateId = config.profiles.first.id;
|
final updateId = config.profiles.first.id;
|
||||||
changeProfile(updateId);
|
changeProfile(updateId);
|
||||||
} else {
|
} else {
|
||||||
updateSystemProxy(false);
|
updateStatus(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,7 +228,7 @@ class AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleExit() async {
|
handleExit() async {
|
||||||
await updateSystemProxy(false);
|
await updateStatus(false);
|
||||||
await savePreferences();
|
await savePreferences();
|
||||||
clashCore.shutdown();
|
clashCore.shutdown();
|
||||||
system.exit();
|
system.exit();
|
||||||
@@ -298,11 +297,13 @@ class AppController {
|
|||||||
if (!config.silentLaunch) {
|
if (!config.silentLaunch) {
|
||||||
window?.show();
|
window?.show();
|
||||||
}
|
}
|
||||||
await proxyManager.updateStartTime();
|
if (Platform.isAndroid) {
|
||||||
if (proxyManager.isStart) {
|
globalState.updateStartTime();
|
||||||
await updateSystemProxy(true);
|
}
|
||||||
|
if (globalState.isStart) {
|
||||||
|
await updateStatus(true);
|
||||||
} else {
|
} else {
|
||||||
await updateSystemProxy(config.autoRun);
|
await updateStatus(config.autoRun);
|
||||||
}
|
}
|
||||||
autoUpdateProfiles();
|
autoUpdateProfiles();
|
||||||
autoCheckUpdate();
|
autoCheckUpdate();
|
||||||
@@ -415,7 +416,6 @@ class AppController {
|
|||||||
addProfileFormURL(url);
|
addProfileFormURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
updateViewWidth(double width) {
|
updateViewWidth(double width) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
appState.viewWidth = width;
|
appState.viewWidth = width;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class ApplicationSettingFragment extends StatelessWidget {
|
|||||||
selector: (_, config) => config.autoRun,
|
selector: (_, config) => config.autoRun,
|
||||||
builder: (_, autoRun, child) {
|
builder: (_, autoRun, child) {
|
||||||
return ListItem.switchItem(
|
return ListItem.switchItem(
|
||||||
leading: const Icon(Icons.start),
|
leading: const Icon(Icons.not_started),
|
||||||
title: Text(appLocalizations.autoRun),
|
title: Text(appLocalizations.autoRun),
|
||||||
subtitle: Text(appLocalizations.autoRunDesc),
|
subtitle: Text(appLocalizations.autoRunDesc),
|
||||||
delegate: SwitchDelegate(
|
delegate: SwitchDelegate(
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
final mixedPort = int.parse(port);
|
final mixedPort = int.parse(port);
|
||||||
if (mixedPort < 1024 || mixedPort > 49151) throw "Invalid port";
|
if (mixedPort < 1024 || mixedPort > 49151) throw "Invalid port";
|
||||||
globalState.appController.clashConfig.mixedPort = mixedPort;
|
globalState.appController.clashConfig.mixedPort = mixedPort;
|
||||||
globalState.appController.updateClashConfigDebounce();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
globalState.showMessage(
|
globalState.showMessage(
|
||||||
title: appLocalizations.proxyPort,
|
title: appLocalizations.proxyPort,
|
||||||
@@ -62,7 +61,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
}
|
}
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.logLevel = value;
|
appController.clashConfig.logLevel = value;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -100,7 +98,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.globalRealUa = value;
|
appController.clashConfig.globalRealUa = value;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -125,7 +122,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
throw "Invalid url";
|
throw "Invalid url";
|
||||||
}
|
}
|
||||||
globalState.appController.config.testUrl = newTestUrl;
|
globalState.appController.config.testUrl = newTestUrl;
|
||||||
globalState.appController.updateClashConfigDebounce();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
globalState.showMessage(
|
globalState.showMessage(
|
||||||
title: appLocalizations.testUrl,
|
title: appLocalizations.testUrl,
|
||||||
@@ -172,7 +168,7 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
items: [
|
items: [
|
||||||
if (Platform.isAndroid) ...[
|
if (Platform.isAndroid) ...[
|
||||||
Selector<Config, bool>(
|
Selector<Config, bool>(
|
||||||
selector: (_, config) => config.allowBypass,
|
selector: (_, config) => config.vpnProps.allowBypass,
|
||||||
builder: (_, allowBypass, __) {
|
builder: (_, allowBypass, __) {
|
||||||
return ListItem.switchItem(
|
return ListItem.switchItem(
|
||||||
leading: const Icon(Icons.arrow_forward_outlined),
|
leading: const Icon(Icons.arrow_forward_outlined),
|
||||||
@@ -181,15 +177,18 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
delegate: SwitchDelegate(
|
delegate: SwitchDelegate(
|
||||||
value: allowBypass,
|
value: allowBypass,
|
||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final appController = globalState.appController;
|
final config = globalState.appController.config;
|
||||||
appController.config.allowBypass = value;
|
final vpnProps = config.vpnProps;
|
||||||
|
config.vpnProps = vpnProps.copyWith(
|
||||||
|
allowBypass: value,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Selector<Config, bool>(
|
Selector<Config, bool>(
|
||||||
selector: (_, config) => config.systemProxy,
|
selector: (_, config) => config.vpnProps.systemProxy,
|
||||||
builder: (_, systemProxy, __) {
|
builder: (_, systemProxy, __) {
|
||||||
return ListItem.switchItem(
|
return ListItem.switchItem(
|
||||||
leading: const Icon(Icons.settings_ethernet),
|
leading: const Icon(Icons.settings_ethernet),
|
||||||
@@ -198,8 +197,11 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
delegate: SwitchDelegate(
|
delegate: SwitchDelegate(
|
||||||
value: systemProxy,
|
value: systemProxy,
|
||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final appController = globalState.appController;
|
final config = globalState.appController.config;
|
||||||
appController.config.systemProxy = value;
|
final vpnProps = config.vpnProps;
|
||||||
|
config.vpnProps = vpnProps.copyWith(
|
||||||
|
systemProxy: value,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -351,7 +353,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.ipv6 = value;
|
appController.clashConfig.ipv6 = value;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -369,7 +370,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final clashConfig = context.read<ClashConfig>();
|
final clashConfig = context.read<ClashConfig>();
|
||||||
clashConfig.allowLan = value;
|
clashConfig.allowLan = value;
|
||||||
globalState.appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -387,7 +387,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.unifiedDelay = value;
|
appController.clashConfig.unifiedDelay = value;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -407,7 +406,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.findProcessMode =
|
appController.clashConfig.findProcessMode =
|
||||||
value ? FindProcessMode.always : FindProcessMode.off;
|
value ? FindProcessMode.always : FindProcessMode.off;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -425,7 +423,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.tcpConcurrent = value;
|
appController.clashConfig.tcpConcurrent = value;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -446,7 +443,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
appController.clashConfig.geodataLoader = value
|
appController.clashConfig.geodataLoader = value
|
||||||
? geodataLoaderMemconservative
|
? geodataLoaderMemconservative
|
||||||
: geodataLoaderStandard;
|
: geodataLoaderStandard;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -466,7 +462,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.externalController =
|
appController.clashConfig.externalController =
|
||||||
value ? defaultExternalController : '';
|
value ? defaultExternalController : '';
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -493,7 +488,6 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
|||||||
onChanged: (bool value) async {
|
onChanged: (bool value) async {
|
||||||
final clashConfig = context.read<ClashConfig>();
|
final clashConfig = context.read<ClashConfig>();
|
||||||
clashConfig.tun = Tun(enable: value);
|
clashConfig.tun = Tun(enable: value);
|
||||||
globalState.appController.updateClashConfigDebounce();
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -652,8 +646,9 @@ class _KeepAliveIntervalFormDialogState
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
keepAliveIntervalController =
|
keepAliveIntervalController = TextEditingController(
|
||||||
TextEditingController(text: "${widget.keepAliveInterval}");
|
text: "${widget.keepAliveInterval}",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleUpdate() async {
|
_handleUpdate() async {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/fragments/dashboard/intranet_ip.dart';
|
import 'package:fl_clash/fragments/dashboard/intranet_ip.dart';
|
||||||
|
import 'package:fl_clash/fragments/dashboard/status_switch.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fl_clash/widgets/widgets.dart';
|
import 'package:fl_clash/widgets/widgets.dart';
|
||||||
@@ -28,34 +31,51 @@ class _DashboardFragmentState extends State<DashboardFragment> {
|
|||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16).copyWith(
|
||||||
|
bottom: 88,
|
||||||
|
),
|
||||||
child: Selector<AppState, double>(
|
child: Selector<AppState, double>(
|
||||||
selector: (_, appState) => appState.viewWidth,
|
selector: (_, appState) => appState.viewWidth,
|
||||||
builder: (_, viewWidth, ___) {
|
builder: (_, viewWidth, ___) {
|
||||||
// final viewMode = other.getViewMode(viewWidth);
|
final columns = max(4 * ((viewWidth / 350).ceil()), 8);
|
||||||
// final isDesktop = viewMode == ViewMode.desktop;
|
final int switchCount = (4 / columns) * viewWidth < 200 ? 8 : 4;
|
||||||
return Grid(
|
return Grid(
|
||||||
crossAxisCount: max(4 * ((viewWidth / 350).ceil()), 8),
|
crossAxisCount: columns,
|
||||||
crossAxisSpacing: 16,
|
crossAxisSpacing: 16,
|
||||||
mainAxisSpacing: 16,
|
mainAxisSpacing: 16,
|
||||||
children: const [
|
children: [
|
||||||
GridItem(
|
const GridItem(
|
||||||
crossAxisCellCount: 8,
|
crossAxisCellCount: 8,
|
||||||
child: NetworkSpeed(),
|
child: NetworkSpeed(),
|
||||||
),
|
),
|
||||||
GridItem(
|
if (Platform.isAndroid)
|
||||||
|
GridItem(
|
||||||
|
crossAxisCellCount: switchCount,
|
||||||
|
child: const VPNSwitch(),
|
||||||
|
),
|
||||||
|
if (system.isDesktop) ...[
|
||||||
|
GridItem(
|
||||||
|
crossAxisCellCount: switchCount,
|
||||||
|
child: const TUNSwitch(),
|
||||||
|
),
|
||||||
|
GridItem(
|
||||||
|
crossAxisCellCount: switchCount,
|
||||||
|
child: const ProxySwitch(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
const GridItem(
|
||||||
crossAxisCellCount: 4,
|
crossAxisCellCount: 4,
|
||||||
child: OutboundMode(),
|
child: OutboundMode(),
|
||||||
),
|
),
|
||||||
GridItem(
|
const GridItem(
|
||||||
crossAxisCellCount: 4,
|
crossAxisCellCount: 4,
|
||||||
child: NetworkDetection(),
|
child: NetworkDetection(),
|
||||||
),
|
),
|
||||||
GridItem(
|
const GridItem(
|
||||||
crossAxisCellCount: 4,
|
crossAxisCellCount: 4,
|
||||||
child: TrafficUsage(),
|
child: TrafficUsage(),
|
||||||
),
|
),
|
||||||
GridItem(
|
const GridItem(
|
||||||
crossAxisCellCount: 4,
|
crossAxisCellCount: 4,
|
||||||
child: IntranetIP(),
|
child: IntranetIP(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -14,8 +14,12 @@ class NetworkDetection extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _NetworkDetectionState extends State<NetworkDetection> {
|
class _NetworkDetectionState extends State<NetworkDetection> {
|
||||||
final ipInfoNotifier = ValueNotifier<IpInfo?>(null);
|
final networkDetectionState = ValueNotifier<NetworkDetectionState>(
|
||||||
final timeoutNotifier = ValueNotifier<bool>(false);
|
const NetworkDetectionState(
|
||||||
|
isTesting: true,
|
||||||
|
ipInfo: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
bool? _preIsStart;
|
bool? _preIsStart;
|
||||||
Function? _checkIpDebounce;
|
Function? _checkIpDebounce;
|
||||||
CancelToken? cancelToken;
|
CancelToken? cancelToken;
|
||||||
@@ -23,26 +27,28 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
|||||||
_checkIp() async {
|
_checkIp() async {
|
||||||
final appState = globalState.appController.appState;
|
final appState = globalState.appController.appState;
|
||||||
final isInit = appState.isInit;
|
final isInit = appState.isInit;
|
||||||
final isStart = appState.isStart;
|
|
||||||
if (!isInit) return;
|
if (!isInit) return;
|
||||||
timeoutNotifier.value = false;
|
final isStart = appState.isStart;
|
||||||
if (_preIsStart == false && _preIsStart == isStart) return;
|
if (_preIsStart == false && _preIsStart == isStart) return;
|
||||||
|
networkDetectionState.value = networkDetectionState.value.copyWith(
|
||||||
|
isTesting: true,
|
||||||
|
ipInfo: null,
|
||||||
|
);
|
||||||
_preIsStart = isStart;
|
_preIsStart = isStart;
|
||||||
ipInfoNotifier.value = null;
|
|
||||||
if (cancelToken != null) {
|
if (cancelToken != null) {
|
||||||
cancelToken!.cancel();
|
cancelToken!.cancel();
|
||||||
_preIsStart = null;
|
|
||||||
timeoutNotifier.value == false;
|
|
||||||
cancelToken = null;
|
cancelToken = null;
|
||||||
}
|
}
|
||||||
cancelToken = CancelToken();
|
cancelToken = CancelToken();
|
||||||
final ipInfo = await request.checkIp(cancelToken: cancelToken);
|
try {
|
||||||
if (ipInfo == null) {
|
final ipInfo = await request.checkIp(cancelToken: cancelToken);
|
||||||
timeoutNotifier.value = true;
|
networkDetectionState.value = networkDetectionState.value.copyWith(
|
||||||
return;
|
isTesting: false,
|
||||||
|
ipInfo: ipInfo,
|
||||||
|
);
|
||||||
|
} catch (_) {
|
||||||
|
|
||||||
}
|
}
|
||||||
timeoutNotifier.value = false;
|
|
||||||
ipInfoNotifier.value = ipInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_checkIpContainer(Widget child) {
|
_checkIpContainer(Widget child) {
|
||||||
@@ -63,8 +69,7 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
ipInfoNotifier.dispose();
|
networkDetectionState.dispose();
|
||||||
timeoutNotifier.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String countryCodeToEmoji(String countryCode) {
|
String countryCodeToEmoji(String countryCode) {
|
||||||
@@ -81,9 +86,11 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
_checkIpDebounce ??= debounce(_checkIp);
|
_checkIpDebounce ??= debounce(_checkIp);
|
||||||
return _checkIpContainer(
|
return _checkIpContainer(
|
||||||
ValueListenableBuilder<IpInfo?>(
|
ValueListenableBuilder<NetworkDetectionState>(
|
||||||
valueListenable: ipInfoNotifier,
|
valueListenable: networkDetectionState,
|
||||||
builder: (_, ipInfo, __) {
|
builder: (_, state, __) {
|
||||||
|
final ipInfo = state.ipInfo;
|
||||||
|
final isTesting = state.isTesting;
|
||||||
return CommonCard(
|
return CommonCard(
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -104,46 +111,38 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
|||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FadeBox(
|
child: FadeBox(
|
||||||
child: ipInfo != null
|
child: isTesting
|
||||||
? Container(
|
? Text(
|
||||||
alignment: Alignment.centerLeft,
|
appLocalizations.checking,
|
||||||
height: globalState.appController.measure
|
maxLines: 1,
|
||||||
.titleMediumHeight,
|
overflow: TextOverflow.ellipsis,
|
||||||
child: Text(
|
style:
|
||||||
countryCodeToEmoji(ipInfo.countryCode),
|
Theme.of(context).textTheme.titleMedium,
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.titleLarge
|
|
||||||
?.copyWith(
|
|
||||||
fontFamily: "Twemoji",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
: ValueListenableBuilder(
|
: ipInfo != null
|
||||||
valueListenable: timeoutNotifier,
|
? Container(
|
||||||
builder: (_, timeout, __) {
|
alignment: Alignment.centerLeft,
|
||||||
if (timeout) {
|
height: globalState.appController
|
||||||
return Text(
|
.measure.titleMediumHeight,
|
||||||
appLocalizations.checkError,
|
child: Text(
|
||||||
|
countryCodeToEmoji(
|
||||||
|
ipInfo.countryCode),
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.titleMedium,
|
.titleLarge
|
||||||
maxLines: 1,
|
?.copyWith(
|
||||||
overflow: TextOverflow.ellipsis,
|
fontFamily: "Twemoji",
|
||||||
);
|
),
|
||||||
}
|
|
||||||
return TooltipText(
|
|
||||||
text: Text(
|
|
||||||
appLocalizations.checking,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.titleMedium,
|
|
||||||
),
|
),
|
||||||
);
|
)
|
||||||
},
|
: Text(
|
||||||
),
|
appLocalizations.checkError,
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.titleMedium,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -176,28 +175,24 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: ValueListenableBuilder(
|
: FadeBox(
|
||||||
valueListenable: timeoutNotifier,
|
child: isTesting == false && ipInfo == null
|
||||||
builder: (_, timeout, __) {
|
? Text(
|
||||||
if (timeout) {
|
"timeout",
|
||||||
return Text(
|
style: context.textTheme.titleLarge
|
||||||
"timeout",
|
?.copyWith(color: Colors.red)
|
||||||
style: context.textTheme.titleLarge
|
.toSoftBold
|
||||||
?.copyWith(color: Colors.red)
|
.toMinus,
|
||||||
.toSoftBold
|
maxLines: 1,
|
||||||
.toMinus,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 1,
|
)
|
||||||
overflow: TextOverflow.ellipsis,
|
: Container(
|
||||||
);
|
padding: const EdgeInsets.all(2),
|
||||||
}
|
child: const AspectRatio(
|
||||||
return Container(
|
aspectRatio: 1,
|
||||||
padding: const EdgeInsets.all(2),
|
child: CircularProgressIndicator(),
|
||||||
child: const AspectRatio(
|
),
|
||||||
aspectRatio: 1,
|
),
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class _NetworkSpeedState extends State<NetworkSpeed> {
|
|||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
info: Info(
|
info: Info(
|
||||||
label: appLocalizations.networkSpeed,
|
label: appLocalizations.networkSpeed,
|
||||||
iconData: Icons.speed,
|
iconData: Icons.speed_sharp,
|
||||||
),
|
),
|
||||||
child: Selector<AppState, List<Traffic>>(
|
child: Selector<AppState, List<Traffic>>(
|
||||||
selector: (_, appState) => appState.traffics,
|
selector: (_, appState) => appState.traffics,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ class OutboundMode extends StatelessWidget {
|
|||||||
final clashConfig = appController.clashConfig;
|
final clashConfig = appController.clashConfig;
|
||||||
if (value == null || clashConfig.mode == value) return;
|
if (value == null || clashConfig.mode == value) return;
|
||||||
clashConfig.mode = value;
|
clashConfig.mode = value;
|
||||||
await appController.updateClashConfig();
|
|
||||||
appController.addCheckIpNumDebounce();
|
appController.addCheckIpNumDebounce();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ class OutboundMode extends StatelessWidget {
|
|||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
info: Info(
|
info: Info(
|
||||||
label: appLocalizations.outboundMode,
|
label: appLocalizations.outboundMode,
|
||||||
iconData: Icons.call_split,
|
iconData: Icons.call_split_sharp,
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 16),
|
padding: const EdgeInsets.only(bottom: 16),
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class _StartButtonState extends State<StartButton>
|
|||||||
if (isStart == appController.appState.isStart) {
|
if (isStart == appController.appState.isStart) {
|
||||||
isStart = !isStart;
|
isStart = !isStart;
|
||||||
updateController();
|
updateController();
|
||||||
appController.updateSystemProxy(isStart);
|
appController.updateStatus(isStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class _StartButtonState extends State<StartButton>
|
|||||||
return Selector<AppState, bool>(
|
return Selector<AppState, bool>(
|
||||||
selector: (_, appState) => appState.isStart,
|
selector: (_, appState) => appState.isStart,
|
||||||
builder: (_, isStart, child) {
|
builder: (_, isStart, child) {
|
||||||
if(isStart != this.isStart){
|
if (isStart != this.isStart) {
|
||||||
this.isStart = isStart;
|
this.isStart = isStart;
|
||||||
updateController();
|
updateController();
|
||||||
}
|
}
|
||||||
|
|||||||
121
lib/fragments/dashboard/status_switch.dart
Normal file
121
lib/fragments/dashboard/status_switch.dart
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
import 'package:fl_clash/common/app_localizations.dart';
|
||||||
|
import 'package:fl_clash/models/models.dart';
|
||||||
|
import 'package:fl_clash/state.dart';
|
||||||
|
import 'package:fl_clash/widgets/widgets.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class VPNSwitch extends StatelessWidget {
|
||||||
|
const VPNSwitch({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SwitchContainer(
|
||||||
|
info: const Info(
|
||||||
|
label: "VPN",
|
||||||
|
iconData: Icons.stacked_line_chart,
|
||||||
|
),
|
||||||
|
child: Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.vpnProps.enable,
|
||||||
|
builder: (_, enable, __) {
|
||||||
|
return Switch(
|
||||||
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
|
value: enable,
|
||||||
|
onChanged: (value) {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
config.vpnProps = config.vpnProps.copyWith(
|
||||||
|
enable: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TUNSwitch extends StatelessWidget {
|
||||||
|
const TUNSwitch({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SwitchContainer(
|
||||||
|
info: Info(
|
||||||
|
label: appLocalizations.tun,
|
||||||
|
iconData: Icons.stacked_line_chart,
|
||||||
|
),
|
||||||
|
child: Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.tun.enable,
|
||||||
|
builder: (_, enable, __) {
|
||||||
|
return Switch(
|
||||||
|
value: enable,
|
||||||
|
onChanged: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
clashConfig.tun = clashConfig.tun.copyWith(
|
||||||
|
enable: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ProxySwitch extends StatelessWidget {
|
||||||
|
const ProxySwitch({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SwitchContainer(
|
||||||
|
info: Info(
|
||||||
|
label: appLocalizations.systemProxy,
|
||||||
|
iconData: Icons.shuffle,
|
||||||
|
),
|
||||||
|
child: Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.desktopProps.systemProxy,
|
||||||
|
builder: (_, systemProxy, __) {
|
||||||
|
return Switch(
|
||||||
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
|
value: systemProxy,
|
||||||
|
onChanged: (value) {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
config.desktopProps =
|
||||||
|
config.desktopProps.copyWith(systemProxy: value);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SwitchContainer extends StatelessWidget {
|
||||||
|
final Info info;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const SwitchContainer({
|
||||||
|
super.key,
|
||||||
|
required this.info,
|
||||||
|
required this.child,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return CommonCard(
|
||||||
|
onPressed: () {},
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
InfoHeader(
|
||||||
|
info: info,
|
||||||
|
actions: [
|
||||||
|
child,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -91,7 +91,6 @@ class _GeoDataListItemState extends State<GeoDataListItem> {
|
|||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.clashConfig.geoXUrl =
|
appController.clashConfig.geoXUrl =
|
||||||
Map.from(appController.clashConfig.geoXUrl)..[geoItem.key] = newUrl;
|
Map.from(appController.clashConfig.geoXUrl)..[geoItem.key] = newUrl;
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
globalState.showMessage(
|
globalState.showMessage(
|
||||||
title: geoItem.label,
|
title: geoItem.label,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
"overrideDesc": "Override Proxy related config",
|
"overrideDesc": "Override Proxy related config",
|
||||||
"allowLan": "AllowLan",
|
"allowLan": "AllowLan",
|
||||||
"allowLanDesc": "Allow access proxy through the LAN",
|
"allowLanDesc": "Allow access proxy through the LAN",
|
||||||
"tun": "TUN mode",
|
"tun": "TUN",
|
||||||
"tunDesc": "only effective in administrator mode",
|
"tunDesc": "only effective in administrator mode",
|
||||||
"minimizeOnExit": "Minimize on exit",
|
"minimizeOnExit": "Minimize on exit",
|
||||||
"minimizeOnExitDesc": "Modify the default system exit event",
|
"minimizeOnExitDesc": "Modify the default system exit event",
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
"logLevel": "LogLevel",
|
"logLevel": "LogLevel",
|
||||||
"show": "Show",
|
"show": "Show",
|
||||||
"exit": "Exit",
|
"exit": "Exit",
|
||||||
"systemProxy": "SystemProxy",
|
"systemProxy": "System proxy",
|
||||||
"project": "Project",
|
"project": "Project",
|
||||||
"core": "Core",
|
"core": "Core",
|
||||||
"tabAnimation": "Tab animation",
|
"tabAnimation": "Tab animation",
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
"overrideDesc": "覆写代理相关配置",
|
"overrideDesc": "覆写代理相关配置",
|
||||||
"allowLan": "局域网代理",
|
"allowLan": "局域网代理",
|
||||||
"allowLanDesc": "允许通过局域网访问代理",
|
"allowLanDesc": "允许通过局域网访问代理",
|
||||||
"tun": "TUN模式",
|
"tun": "虚拟网卡",
|
||||||
"tunDesc": "仅在管理员模式生效",
|
"tunDesc": "仅在管理员模式生效",
|
||||||
"minimizeOnExit": "退出时最小化",
|
"minimizeOnExit": "退出时最小化",
|
||||||
"minimizeOnExitDesc": "修改系统默认退出事件",
|
"minimizeOnExitDesc": "修改系统默认退出事件",
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"style": MessageLookupByLibrary.simpleMessage("Style"),
|
"style": MessageLookupByLibrary.simpleMessage("Style"),
|
||||||
"submit": MessageLookupByLibrary.simpleMessage("Submit"),
|
"submit": MessageLookupByLibrary.simpleMessage("Submit"),
|
||||||
"sync": MessageLookupByLibrary.simpleMessage("Sync"),
|
"sync": MessageLookupByLibrary.simpleMessage("Sync"),
|
||||||
"systemProxy": MessageLookupByLibrary.simpleMessage("SystemProxy"),
|
"systemProxy": MessageLookupByLibrary.simpleMessage("System proxy"),
|
||||||
"systemProxyDesc": MessageLookupByLibrary.simpleMessage(
|
"systemProxyDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"Attach HTTP proxy to VpnService"),
|
"Attach HTTP proxy to VpnService"),
|
||||||
"tab": MessageLookupByLibrary.simpleMessage("Tab"),
|
"tab": MessageLookupByLibrary.simpleMessage("Tab"),
|
||||||
@@ -343,7 +343,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"tip": MessageLookupByLibrary.simpleMessage("tip"),
|
"tip": MessageLookupByLibrary.simpleMessage("tip"),
|
||||||
"tools": MessageLookupByLibrary.simpleMessage("Tools"),
|
"tools": MessageLookupByLibrary.simpleMessage("Tools"),
|
||||||
"trafficUsage": MessageLookupByLibrary.simpleMessage("Traffic usage"),
|
"trafficUsage": MessageLookupByLibrary.simpleMessage("Traffic usage"),
|
||||||
"tun": MessageLookupByLibrary.simpleMessage("TUN mode"),
|
"tun": MessageLookupByLibrary.simpleMessage("TUN"),
|
||||||
"tunDesc": MessageLookupByLibrary.simpleMessage(
|
"tunDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"only effective in administrator mode"),
|
"only effective in administrator mode"),
|
||||||
"twoColumns": MessageLookupByLibrary.simpleMessage("Two columns"),
|
"twoColumns": MessageLookupByLibrary.simpleMessage("Two columns"),
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"tip": MessageLookupByLibrary.simpleMessage("提示"),
|
"tip": MessageLookupByLibrary.simpleMessage("提示"),
|
||||||
"tools": MessageLookupByLibrary.simpleMessage("工具"),
|
"tools": MessageLookupByLibrary.simpleMessage("工具"),
|
||||||
"trafficUsage": MessageLookupByLibrary.simpleMessage("流量统计"),
|
"trafficUsage": MessageLookupByLibrary.simpleMessage("流量统计"),
|
||||||
"tun": MessageLookupByLibrary.simpleMessage("TUN模式"),
|
"tun": MessageLookupByLibrary.simpleMessage("虚拟网卡"),
|
||||||
"tunDesc": MessageLookupByLibrary.simpleMessage("仅在管理员模式生效"),
|
"tunDesc": MessageLookupByLibrary.simpleMessage("仅在管理员模式生效"),
|
||||||
"twoColumns": MessageLookupByLibrary.simpleMessage("两列"),
|
"twoColumns": MessageLookupByLibrary.simpleMessage("两列"),
|
||||||
"unableToUpdateCurrentProfileDesc":
|
"unableToUpdateCurrentProfileDesc":
|
||||||
|
|||||||
@@ -430,10 +430,10 @@ class AppLocalizations {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `TUN mode`
|
/// `TUN`
|
||||||
String get tun {
|
String get tun {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
'TUN mode',
|
'TUN',
|
||||||
name: 'tun',
|
name: 'tun',
|
||||||
desc: '',
|
desc: '',
|
||||||
args: [],
|
args: [],
|
||||||
@@ -1230,10 +1230,10 @@ class AppLocalizations {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `SystemProxy`
|
/// `System proxy`
|
||||||
String get systemProxy {
|
String get systemProxy {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
'SystemProxy',
|
'System proxy',
|
||||||
name: 'systemProxy',
|
name: 'systemProxy',
|
||||||
desc: '',
|
desc: '',
|
||||||
args: [],
|
args: [],
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:fl_clash/clash/clash.dart';
|
import 'package:fl_clash/clash/clash.dart';
|
||||||
import 'package:fl_clash/plugins/app.dart';
|
import 'package:fl_clash/plugins/app.dart';
|
||||||
import 'package:fl_clash/plugins/proxy.dart';
|
|
||||||
import 'package:fl_clash/plugins/tile.dart';
|
import 'package:fl_clash/plugins/tile.dart';
|
||||||
|
import 'package:fl_clash/plugins/vpn.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
@@ -61,14 +61,14 @@ Future<void> vpnService() async {
|
|||||||
clashConfig: clashConfig,
|
clashConfig: clashConfig,
|
||||||
);
|
);
|
||||||
|
|
||||||
proxy?.setServiceMessageHandler(
|
vpn?.setServiceMessageHandler(
|
||||||
ServiceMessageHandler(
|
ServiceMessageHandler(
|
||||||
onProtect: (Fd fd) async {
|
onProtect: (Fd fd) async {
|
||||||
await proxy?.setProtect(fd.value);
|
await vpn?.setProtect(fd.value);
|
||||||
clashCore.setFdMap(fd.id);
|
clashCore.setFdMap(fd.id);
|
||||||
},
|
},
|
||||||
onProcess: (Process process) async {
|
onProcess: (Process process) async {
|
||||||
var packageName = await app?.resolverProcess(process);
|
final packageName = await app?.resolverProcess(process);
|
||||||
clashCore.setProcessMap(
|
clashCore.setProcessMap(
|
||||||
ProcessMapItem(
|
ProcessMapItem(
|
||||||
id: process.id,
|
id: process.id,
|
||||||
@@ -76,8 +76,8 @@ Future<void> vpnService() async {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
onStarted: (String runTime) {
|
onStarted: (String runTime) async {
|
||||||
globalState.applyProfile(
|
await globalState.applyProfile(
|
||||||
appState: appState,
|
appState: appState,
|
||||||
config: config,
|
config: config,
|
||||||
clashConfig: clashConfig,
|
clashConfig: clashConfig,
|
||||||
@@ -100,8 +100,7 @@ Future<void> vpnService() async {
|
|||||||
WidgetsBinding.instance.platformDispatcher.locale,
|
WidgetsBinding.instance.platformDispatcher.locale,
|
||||||
);
|
);
|
||||||
await app?.tip(appLocalizations.startVpn);
|
await app?.tip(appLocalizations.startVpn);
|
||||||
await globalState.startSystemProxy(
|
await globalState.handleStart(
|
||||||
appState: appState,
|
|
||||||
config: config,
|
config: config,
|
||||||
clashConfig: clashConfig,
|
clashConfig: clashConfig,
|
||||||
);
|
);
|
||||||
@@ -110,7 +109,7 @@ Future<void> vpnService() async {
|
|||||||
TileListenerWithVpn(
|
TileListenerWithVpn(
|
||||||
onStop: () async {
|
onStop: () async {
|
||||||
await app?.tip(appLocalizations.stopVpn);
|
await app?.tip(appLocalizations.stopVpn);
|
||||||
await globalState.stopSystemProxy();
|
await globalState.handleStop();
|
||||||
clashCore.shutdown();
|
clashCore.shutdown();
|
||||||
exit(0);
|
exit(0);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class CoreState with _$CoreState {
|
|||||||
const factory CoreState({
|
const factory CoreState({
|
||||||
AccessControl? accessControl,
|
AccessControl? accessControl,
|
||||||
required String currentProfileName,
|
required String currentProfileName,
|
||||||
|
required bool enable,
|
||||||
required bool allowBypass,
|
required bool allowBypass,
|
||||||
required bool systemProxy,
|
required bool systemProxy,
|
||||||
required int mixedPort,
|
required int mixedPort,
|
||||||
@@ -58,10 +59,30 @@ class WindowProps with _$WindowProps {
|
|||||||
}) = _WindowProps;
|
}) = _WindowProps;
|
||||||
|
|
||||||
factory WindowProps.fromJson(Map<String, Object?>? json) =>
|
factory WindowProps.fromJson(Map<String, Object?>? json) =>
|
||||||
json == null ? defaultWindowProps : _$WindowPropsFromJson(json);
|
json == null ? const WindowProps() : _$WindowPropsFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultWindowProps = WindowProps();
|
@freezed
|
||||||
|
class VpnProps with _$VpnProps {
|
||||||
|
const factory VpnProps({
|
||||||
|
@Default(true) bool enable,
|
||||||
|
@Default(false) bool systemProxy,
|
||||||
|
@Default(true) bool allowBypass,
|
||||||
|
}) = _VpnProps;
|
||||||
|
|
||||||
|
factory VpnProps.fromJson(Map<String, Object?>? json) =>
|
||||||
|
json == null ? const VpnProps() : _$VpnPropsFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class DesktopProps with _$DesktopProps {
|
||||||
|
const factory DesktopProps({
|
||||||
|
@Default(true) bool systemProxy,
|
||||||
|
}) = _DesktopProps;
|
||||||
|
|
||||||
|
factory DesktopProps.fromJson(Map<String, Object?>? json) =>
|
||||||
|
json == null ? const DesktopProps() : _$DesktopPropsFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class Config extends ChangeNotifier {
|
class Config extends ChangeNotifier {
|
||||||
@@ -81,8 +102,6 @@ class Config extends ChangeNotifier {
|
|||||||
AccessControl _accessControl;
|
AccessControl _accessControl;
|
||||||
bool _isAnimateToPage;
|
bool _isAnimateToPage;
|
||||||
bool _autoCheckUpdate;
|
bool _autoCheckUpdate;
|
||||||
bool _allowBypass;
|
|
||||||
bool _systemProxy;
|
|
||||||
bool _isExclude;
|
bool _isExclude;
|
||||||
DAV? _dav;
|
DAV? _dav;
|
||||||
bool _isCloseConnections;
|
bool _isCloseConnections;
|
||||||
@@ -93,6 +112,9 @@ class Config extends ChangeNotifier {
|
|||||||
WindowProps _windowProps;
|
WindowProps _windowProps;
|
||||||
bool _onlyProxy;
|
bool _onlyProxy;
|
||||||
bool _prueBlack;
|
bool _prueBlack;
|
||||||
|
VpnProps _vpnProps;
|
||||||
|
DesktopProps _desktopProps;
|
||||||
|
bool _showLabel;
|
||||||
|
|
||||||
Config()
|
Config()
|
||||||
: _profiles = [],
|
: _profiles = [],
|
||||||
@@ -108,18 +130,19 @@ class Config extends ChangeNotifier {
|
|||||||
_isMinimizeOnExit = true,
|
_isMinimizeOnExit = true,
|
||||||
_isAccessControl = false,
|
_isAccessControl = false,
|
||||||
_autoCheckUpdate = true,
|
_autoCheckUpdate = true,
|
||||||
_systemProxy = false,
|
|
||||||
_testUrl = defaultTestUrl,
|
_testUrl = defaultTestUrl,
|
||||||
_accessControl = const AccessControl(),
|
_accessControl = const AccessControl(),
|
||||||
_isAnimateToPage = true,
|
_isAnimateToPage = true,
|
||||||
_allowBypass = true,
|
|
||||||
_isExclude = false,
|
_isExclude = false,
|
||||||
_proxyCardType = ProxyCardType.expand,
|
_proxyCardType = ProxyCardType.expand,
|
||||||
_windowProps = defaultWindowProps,
|
_windowProps = const WindowProps(),
|
||||||
_proxiesType = ProxiesType.tab,
|
_proxiesType = ProxiesType.tab,
|
||||||
_prueBlack = false,
|
_prueBlack = false,
|
||||||
_onlyProxy = false,
|
_onlyProxy = false,
|
||||||
_proxiesLayout = ProxiesLayout.standard;
|
_proxiesLayout = ProxiesLayout.standard,
|
||||||
|
_vpnProps = const VpnProps(),
|
||||||
|
_desktopProps = const DesktopProps(),
|
||||||
|
_showLabel = false;
|
||||||
|
|
||||||
deleteProfileById(String id) {
|
deleteProfileById(String id) {
|
||||||
_profiles = profiles.where((element) => element.id != id).toList();
|
_profiles = profiles.where((element) => element.id != id).toList();
|
||||||
@@ -409,30 +432,6 @@ class Config extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(defaultValue: true)
|
|
||||||
bool get allowBypass {
|
|
||||||
return _allowBypass;
|
|
||||||
}
|
|
||||||
|
|
||||||
set allowBypass(bool value) {
|
|
||||||
if (_allowBypass != value) {
|
|
||||||
_allowBypass = value;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonKey(defaultValue: false)
|
|
||||||
bool get systemProxy {
|
|
||||||
return _systemProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
set systemProxy(bool value) {
|
|
||||||
if (_systemProxy != value) {
|
|
||||||
_systemProxy = value;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonKey(defaultValue: false)
|
@JsonKey(defaultValue: false)
|
||||||
bool get onlyProxy {
|
bool get onlyProxy {
|
||||||
return _onlyProxy;
|
return _onlyProxy;
|
||||||
@@ -521,6 +520,33 @@ class Config extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VpnProps get vpnProps => _vpnProps;
|
||||||
|
|
||||||
|
set vpnProps(VpnProps value) {
|
||||||
|
if (_vpnProps != value) {
|
||||||
|
_vpnProps = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DesktopProps get desktopProps => _desktopProps;
|
||||||
|
|
||||||
|
set desktopProps(DesktopProps value) {
|
||||||
|
if (_desktopProps != value) {
|
||||||
|
_desktopProps = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get showLabel => _showLabel;
|
||||||
|
|
||||||
|
set showLabel(bool value) {
|
||||||
|
if (_showLabel != value) {
|
||||||
|
_showLabel = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
update([
|
update([
|
||||||
Config? config,
|
Config? config,
|
||||||
RecoveryOption recoveryOptions = RecoveryOption.all,
|
RecoveryOption recoveryOptions = RecoveryOption.all,
|
||||||
@@ -545,7 +571,6 @@ class Config extends ChangeNotifier {
|
|||||||
_openLog = config._openLog;
|
_openLog = config._openLog;
|
||||||
_themeMode = config._themeMode;
|
_themeMode = config._themeMode;
|
||||||
_locale = config._locale;
|
_locale = config._locale;
|
||||||
_allowBypass = config._allowBypass;
|
|
||||||
_primaryColor = config._primaryColor;
|
_primaryColor = config._primaryColor;
|
||||||
_proxiesSortType = config._proxiesSortType;
|
_proxiesSortType = config._proxiesSortType;
|
||||||
_isMinimizeOnExit = config._isMinimizeOnExit;
|
_isMinimizeOnExit = config._isMinimizeOnExit;
|
||||||
@@ -557,6 +582,8 @@ class Config extends ChangeNotifier {
|
|||||||
_testUrl = config._testUrl;
|
_testUrl = config._testUrl;
|
||||||
_isExclude = config._isExclude;
|
_isExclude = config._isExclude;
|
||||||
_windowProps = config._windowProps;
|
_windowProps = config._windowProps;
|
||||||
|
_vpnProps = config._vpnProps;
|
||||||
|
_desktopProps = config._desktopProps;
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ CoreState _$CoreStateFromJson(Map<String, dynamic> json) {
|
|||||||
mixin _$CoreState {
|
mixin _$CoreState {
|
||||||
AccessControl? get accessControl => throw _privateConstructorUsedError;
|
AccessControl? get accessControl => throw _privateConstructorUsedError;
|
||||||
String get currentProfileName => throw _privateConstructorUsedError;
|
String get currentProfileName => throw _privateConstructorUsedError;
|
||||||
|
bool get enable => throw _privateConstructorUsedError;
|
||||||
bool get allowBypass => throw _privateConstructorUsedError;
|
bool get allowBypass => throw _privateConstructorUsedError;
|
||||||
bool get systemProxy => throw _privateConstructorUsedError;
|
bool get systemProxy => throw _privateConstructorUsedError;
|
||||||
int get mixedPort => throw _privateConstructorUsedError;
|
int get mixedPort => throw _privateConstructorUsedError;
|
||||||
@@ -289,6 +290,7 @@ abstract class $CoreStateCopyWith<$Res> {
|
|||||||
$Res call(
|
$Res call(
|
||||||
{AccessControl? accessControl,
|
{AccessControl? accessControl,
|
||||||
String currentProfileName,
|
String currentProfileName,
|
||||||
|
bool enable,
|
||||||
bool allowBypass,
|
bool allowBypass,
|
||||||
bool systemProxy,
|
bool systemProxy,
|
||||||
int mixedPort,
|
int mixedPort,
|
||||||
@@ -312,6 +314,7 @@ class _$CoreStateCopyWithImpl<$Res, $Val extends CoreState>
|
|||||||
$Res call({
|
$Res call({
|
||||||
Object? accessControl = freezed,
|
Object? accessControl = freezed,
|
||||||
Object? currentProfileName = null,
|
Object? currentProfileName = null,
|
||||||
|
Object? enable = null,
|
||||||
Object? allowBypass = null,
|
Object? allowBypass = null,
|
||||||
Object? systemProxy = null,
|
Object? systemProxy = null,
|
||||||
Object? mixedPort = null,
|
Object? mixedPort = null,
|
||||||
@@ -326,6 +329,10 @@ class _$CoreStateCopyWithImpl<$Res, $Val extends CoreState>
|
|||||||
? _value.currentProfileName
|
? _value.currentProfileName
|
||||||
: currentProfileName // ignore: cast_nullable_to_non_nullable
|
: currentProfileName // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String,
|
||||||
|
enable: null == enable
|
||||||
|
? _value.enable
|
||||||
|
: enable // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
allowBypass: null == allowBypass
|
allowBypass: null == allowBypass
|
||||||
? _value.allowBypass
|
? _value.allowBypass
|
||||||
: allowBypass // ignore: cast_nullable_to_non_nullable
|
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -369,6 +376,7 @@ abstract class _$$CoreStateImplCopyWith<$Res>
|
|||||||
$Res call(
|
$Res call(
|
||||||
{AccessControl? accessControl,
|
{AccessControl? accessControl,
|
||||||
String currentProfileName,
|
String currentProfileName,
|
||||||
|
bool enable,
|
||||||
bool allowBypass,
|
bool allowBypass,
|
||||||
bool systemProxy,
|
bool systemProxy,
|
||||||
int mixedPort,
|
int mixedPort,
|
||||||
@@ -391,6 +399,7 @@ class __$$CoreStateImplCopyWithImpl<$Res>
|
|||||||
$Res call({
|
$Res call({
|
||||||
Object? accessControl = freezed,
|
Object? accessControl = freezed,
|
||||||
Object? currentProfileName = null,
|
Object? currentProfileName = null,
|
||||||
|
Object? enable = null,
|
||||||
Object? allowBypass = null,
|
Object? allowBypass = null,
|
||||||
Object? systemProxy = null,
|
Object? systemProxy = null,
|
||||||
Object? mixedPort = null,
|
Object? mixedPort = null,
|
||||||
@@ -405,6 +414,10 @@ class __$$CoreStateImplCopyWithImpl<$Res>
|
|||||||
? _value.currentProfileName
|
? _value.currentProfileName
|
||||||
: currentProfileName // ignore: cast_nullable_to_non_nullable
|
: currentProfileName // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String,
|
||||||
|
enable: null == enable
|
||||||
|
? _value.enable
|
||||||
|
: enable // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
allowBypass: null == allowBypass
|
allowBypass: null == allowBypass
|
||||||
? _value.allowBypass
|
? _value.allowBypass
|
||||||
: allowBypass // ignore: cast_nullable_to_non_nullable
|
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -431,6 +444,7 @@ class _$CoreStateImpl implements _CoreState {
|
|||||||
const _$CoreStateImpl(
|
const _$CoreStateImpl(
|
||||||
{this.accessControl,
|
{this.accessControl,
|
||||||
required this.currentProfileName,
|
required this.currentProfileName,
|
||||||
|
required this.enable,
|
||||||
required this.allowBypass,
|
required this.allowBypass,
|
||||||
required this.systemProxy,
|
required this.systemProxy,
|
||||||
required this.mixedPort,
|
required this.mixedPort,
|
||||||
@@ -444,6 +458,8 @@ class _$CoreStateImpl implements _CoreState {
|
|||||||
@override
|
@override
|
||||||
final String currentProfileName;
|
final String currentProfileName;
|
||||||
@override
|
@override
|
||||||
|
final bool enable;
|
||||||
|
@override
|
||||||
final bool allowBypass;
|
final bool allowBypass;
|
||||||
@override
|
@override
|
||||||
final bool systemProxy;
|
final bool systemProxy;
|
||||||
@@ -454,7 +470,7 @@ class _$CoreStateImpl implements _CoreState {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'CoreState(accessControl: $accessControl, currentProfileName: $currentProfileName, allowBypass: $allowBypass, systemProxy: $systemProxy, mixedPort: $mixedPort, onlyProxy: $onlyProxy)';
|
return 'CoreState(accessControl: $accessControl, currentProfileName: $currentProfileName, enable: $enable, allowBypass: $allowBypass, systemProxy: $systemProxy, mixedPort: $mixedPort, onlyProxy: $onlyProxy)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -466,6 +482,7 @@ class _$CoreStateImpl implements _CoreState {
|
|||||||
other.accessControl == accessControl) &&
|
other.accessControl == accessControl) &&
|
||||||
(identical(other.currentProfileName, currentProfileName) ||
|
(identical(other.currentProfileName, currentProfileName) ||
|
||||||
other.currentProfileName == currentProfileName) &&
|
other.currentProfileName == currentProfileName) &&
|
||||||
|
(identical(other.enable, enable) || other.enable == enable) &&
|
||||||
(identical(other.allowBypass, allowBypass) ||
|
(identical(other.allowBypass, allowBypass) ||
|
||||||
other.allowBypass == allowBypass) &&
|
other.allowBypass == allowBypass) &&
|
||||||
(identical(other.systemProxy, systemProxy) ||
|
(identical(other.systemProxy, systemProxy) ||
|
||||||
@@ -478,8 +495,15 @@ class _$CoreStateImpl implements _CoreState {
|
|||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, accessControl,
|
int get hashCode => Object.hash(
|
||||||
currentProfileName, allowBypass, systemProxy, mixedPort, onlyProxy);
|
runtimeType,
|
||||||
|
accessControl,
|
||||||
|
currentProfileName,
|
||||||
|
enable,
|
||||||
|
allowBypass,
|
||||||
|
systemProxy,
|
||||||
|
mixedPort,
|
||||||
|
onlyProxy);
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
@@ -499,6 +523,7 @@ abstract class _CoreState implements CoreState {
|
|||||||
const factory _CoreState(
|
const factory _CoreState(
|
||||||
{final AccessControl? accessControl,
|
{final AccessControl? accessControl,
|
||||||
required final String currentProfileName,
|
required final String currentProfileName,
|
||||||
|
required final bool enable,
|
||||||
required final bool allowBypass,
|
required final bool allowBypass,
|
||||||
required final bool systemProxy,
|
required final bool systemProxy,
|
||||||
required final int mixedPort,
|
required final int mixedPort,
|
||||||
@@ -512,6 +537,8 @@ abstract class _CoreState implements CoreState {
|
|||||||
@override
|
@override
|
||||||
String get currentProfileName;
|
String get currentProfileName;
|
||||||
@override
|
@override
|
||||||
|
bool get enable;
|
||||||
|
@override
|
||||||
bool get allowBypass;
|
bool get allowBypass;
|
||||||
@override
|
@override
|
||||||
bool get systemProxy;
|
bool get systemProxy;
|
||||||
@@ -715,3 +742,318 @@ abstract class _WindowProps implements WindowProps {
|
|||||||
_$$WindowPropsImplCopyWith<_$WindowPropsImpl> get copyWith =>
|
_$$WindowPropsImplCopyWith<_$WindowPropsImpl> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VpnProps _$VpnPropsFromJson(Map<String, dynamic> json) {
|
||||||
|
return _VpnProps.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$VpnProps {
|
||||||
|
bool get enable => throw _privateConstructorUsedError;
|
||||||
|
bool get systemProxy => throw _privateConstructorUsedError;
|
||||||
|
bool get allowBypass => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$VpnPropsCopyWith<VpnProps> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $VpnPropsCopyWith<$Res> {
|
||||||
|
factory $VpnPropsCopyWith(VpnProps value, $Res Function(VpnProps) then) =
|
||||||
|
_$VpnPropsCopyWithImpl<$Res, VpnProps>;
|
||||||
|
@useResult
|
||||||
|
$Res call({bool enable, bool systemProxy, bool allowBypass});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$VpnPropsCopyWithImpl<$Res, $Val extends VpnProps>
|
||||||
|
implements $VpnPropsCopyWith<$Res> {
|
||||||
|
_$VpnPropsCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? enable = null,
|
||||||
|
Object? systemProxy = null,
|
||||||
|
Object? allowBypass = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
enable: null == enable
|
||||||
|
? _value.enable
|
||||||
|
: enable // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
systemProxy: null == systemProxy
|
||||||
|
? _value.systemProxy
|
||||||
|
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
allowBypass: null == allowBypass
|
||||||
|
? _value.allowBypass
|
||||||
|
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$VpnPropsImplCopyWith<$Res>
|
||||||
|
implements $VpnPropsCopyWith<$Res> {
|
||||||
|
factory _$$VpnPropsImplCopyWith(
|
||||||
|
_$VpnPropsImpl value, $Res Function(_$VpnPropsImpl) then) =
|
||||||
|
__$$VpnPropsImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({bool enable, bool systemProxy, bool allowBypass});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$VpnPropsImplCopyWithImpl<$Res>
|
||||||
|
extends _$VpnPropsCopyWithImpl<$Res, _$VpnPropsImpl>
|
||||||
|
implements _$$VpnPropsImplCopyWith<$Res> {
|
||||||
|
__$$VpnPropsImplCopyWithImpl(
|
||||||
|
_$VpnPropsImpl _value, $Res Function(_$VpnPropsImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? enable = null,
|
||||||
|
Object? systemProxy = null,
|
||||||
|
Object? allowBypass = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$VpnPropsImpl(
|
||||||
|
enable: null == enable
|
||||||
|
? _value.enable
|
||||||
|
: enable // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
systemProxy: null == systemProxy
|
||||||
|
? _value.systemProxy
|
||||||
|
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
allowBypass: null == allowBypass
|
||||||
|
? _value.allowBypass
|
||||||
|
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$VpnPropsImpl implements _VpnProps {
|
||||||
|
const _$VpnPropsImpl(
|
||||||
|
{this.enable = true, this.systemProxy = false, this.allowBypass = true});
|
||||||
|
|
||||||
|
factory _$VpnPropsImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$VpnPropsImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool enable;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool systemProxy;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool allowBypass;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'VpnProps(enable: $enable, systemProxy: $systemProxy, allowBypass: $allowBypass)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$VpnPropsImpl &&
|
||||||
|
(identical(other.enable, enable) || other.enable == enable) &&
|
||||||
|
(identical(other.systemProxy, systemProxy) ||
|
||||||
|
other.systemProxy == systemProxy) &&
|
||||||
|
(identical(other.allowBypass, allowBypass) ||
|
||||||
|
other.allowBypass == allowBypass));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
int get hashCode =>
|
||||||
|
Object.hash(runtimeType, enable, systemProxy, allowBypass);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$VpnPropsImplCopyWith<_$VpnPropsImpl> get copyWith =>
|
||||||
|
__$$VpnPropsImplCopyWithImpl<_$VpnPropsImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$VpnPropsImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _VpnProps implements VpnProps {
|
||||||
|
const factory _VpnProps(
|
||||||
|
{final bool enable,
|
||||||
|
final bool systemProxy,
|
||||||
|
final bool allowBypass}) = _$VpnPropsImpl;
|
||||||
|
|
||||||
|
factory _VpnProps.fromJson(Map<String, dynamic> json) =
|
||||||
|
_$VpnPropsImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get enable;
|
||||||
|
@override
|
||||||
|
bool get systemProxy;
|
||||||
|
@override
|
||||||
|
bool get allowBypass;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$VpnPropsImplCopyWith<_$VpnPropsImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
DesktopProps _$DesktopPropsFromJson(Map<String, dynamic> json) {
|
||||||
|
return _DesktopProps.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$DesktopProps {
|
||||||
|
bool get systemProxy => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$DesktopPropsCopyWith<DesktopProps> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $DesktopPropsCopyWith<$Res> {
|
||||||
|
factory $DesktopPropsCopyWith(
|
||||||
|
DesktopProps value, $Res Function(DesktopProps) then) =
|
||||||
|
_$DesktopPropsCopyWithImpl<$Res, DesktopProps>;
|
||||||
|
@useResult
|
||||||
|
$Res call({bool systemProxy});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$DesktopPropsCopyWithImpl<$Res, $Val extends DesktopProps>
|
||||||
|
implements $DesktopPropsCopyWith<$Res> {
|
||||||
|
_$DesktopPropsCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? systemProxy = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
systemProxy: null == systemProxy
|
||||||
|
? _value.systemProxy
|
||||||
|
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$DesktopPropsImplCopyWith<$Res>
|
||||||
|
implements $DesktopPropsCopyWith<$Res> {
|
||||||
|
factory _$$DesktopPropsImplCopyWith(
|
||||||
|
_$DesktopPropsImpl value, $Res Function(_$DesktopPropsImpl) then) =
|
||||||
|
__$$DesktopPropsImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({bool systemProxy});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$DesktopPropsImplCopyWithImpl<$Res>
|
||||||
|
extends _$DesktopPropsCopyWithImpl<$Res, _$DesktopPropsImpl>
|
||||||
|
implements _$$DesktopPropsImplCopyWith<$Res> {
|
||||||
|
__$$DesktopPropsImplCopyWithImpl(
|
||||||
|
_$DesktopPropsImpl _value, $Res Function(_$DesktopPropsImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? systemProxy = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$DesktopPropsImpl(
|
||||||
|
systemProxy: null == systemProxy
|
||||||
|
? _value.systemProxy
|
||||||
|
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$DesktopPropsImpl implements _DesktopProps {
|
||||||
|
const _$DesktopPropsImpl({this.systemProxy = true});
|
||||||
|
|
||||||
|
factory _$DesktopPropsImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$DesktopPropsImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool systemProxy;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'DesktopProps(systemProxy: $systemProxy)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$DesktopPropsImpl &&
|
||||||
|
(identical(other.systemProxy, systemProxy) ||
|
||||||
|
other.systemProxy == systemProxy));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, systemProxy);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$DesktopPropsImplCopyWith<_$DesktopPropsImpl> get copyWith =>
|
||||||
|
__$$DesktopPropsImplCopyWithImpl<_$DesktopPropsImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$DesktopPropsImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _DesktopProps implements DesktopProps {
|
||||||
|
const factory _DesktopProps({final bool systemProxy}) = _$DesktopPropsImpl;
|
||||||
|
|
||||||
|
factory _DesktopProps.fromJson(Map<String, dynamic> json) =
|
||||||
|
_$DesktopPropsImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get systemProxy;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$DesktopPropsImplCopyWith<_$DesktopPropsImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config()
|
|||||||
..isAnimateToPage = json['isAnimateToPage'] as bool? ?? true
|
..isAnimateToPage = json['isAnimateToPage'] as bool? ?? true
|
||||||
..isCompatible = json['isCompatible'] as bool? ?? true
|
..isCompatible = json['isCompatible'] as bool? ?? true
|
||||||
..autoCheckUpdate = json['autoCheckUpdate'] as bool? ?? true
|
..autoCheckUpdate = json['autoCheckUpdate'] as bool? ?? true
|
||||||
..allowBypass = json['allowBypass'] as bool? ?? true
|
|
||||||
..systemProxy = json['systemProxy'] as bool? ?? false
|
|
||||||
..onlyProxy = json['onlyProxy'] as bool? ?? false
|
..onlyProxy = json['onlyProxy'] as bool? ?? false
|
||||||
..prueBlack = json['prueBlack'] as bool? ?? false
|
..prueBlack = json['prueBlack'] as bool? ?? false
|
||||||
..isCloseConnections = json['isCloseConnections'] as bool? ?? false
|
..isCloseConnections = json['isCloseConnections'] as bool? ?? false
|
||||||
@@ -51,7 +49,10 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config()
|
|||||||
json['test-url'] as String? ?? 'https://www.gstatic.com/generate_204'
|
json['test-url'] as String? ?? 'https://www.gstatic.com/generate_204'
|
||||||
..isExclude = json['isExclude'] as bool? ?? false
|
..isExclude = json['isExclude'] as bool? ?? false
|
||||||
..windowProps =
|
..windowProps =
|
||||||
WindowProps.fromJson(json['windowProps'] as Map<String, dynamic>?);
|
WindowProps.fromJson(json['windowProps'] as Map<String, dynamic>?)
|
||||||
|
..vpnProps = VpnProps.fromJson(json['vpnProps'] as Map<String, dynamic>?)
|
||||||
|
..desktopProps =
|
||||||
|
DesktopProps.fromJson(json['desktopProps'] as Map<String, dynamic>?);
|
||||||
|
|
||||||
Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||||
'profiles': instance.profiles,
|
'profiles': instance.profiles,
|
||||||
@@ -72,8 +73,6 @@ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
|||||||
'isAnimateToPage': instance.isAnimateToPage,
|
'isAnimateToPage': instance.isAnimateToPage,
|
||||||
'isCompatible': instance.isCompatible,
|
'isCompatible': instance.isCompatible,
|
||||||
'autoCheckUpdate': instance.autoCheckUpdate,
|
'autoCheckUpdate': instance.autoCheckUpdate,
|
||||||
'allowBypass': instance.allowBypass,
|
|
||||||
'systemProxy': instance.systemProxy,
|
|
||||||
'onlyProxy': instance.onlyProxy,
|
'onlyProxy': instance.onlyProxy,
|
||||||
'prueBlack': instance.prueBlack,
|
'prueBlack': instance.prueBlack,
|
||||||
'isCloseConnections': instance.isCloseConnections,
|
'isCloseConnections': instance.isCloseConnections,
|
||||||
@@ -82,6 +81,8 @@ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
|||||||
'test-url': instance.testUrl,
|
'test-url': instance.testUrl,
|
||||||
'isExclude': instance.isExclude,
|
'isExclude': instance.isExclude,
|
||||||
'windowProps': instance.windowProps,
|
'windowProps': instance.windowProps,
|
||||||
|
'vpnProps': instance.vpnProps,
|
||||||
|
'desktopProps': instance.desktopProps,
|
||||||
};
|
};
|
||||||
|
|
||||||
const _$ThemeModeEnumMap = {
|
const _$ThemeModeEnumMap = {
|
||||||
@@ -157,6 +158,7 @@ _$CoreStateImpl _$$CoreStateImplFromJson(Map<String, dynamic> json) =>
|
|||||||
: AccessControl.fromJson(
|
: AccessControl.fromJson(
|
||||||
json['accessControl'] as Map<String, dynamic>),
|
json['accessControl'] as Map<String, dynamic>),
|
||||||
currentProfileName: json['currentProfileName'] as String,
|
currentProfileName: json['currentProfileName'] as String,
|
||||||
|
enable: json['enable'] as bool,
|
||||||
allowBypass: json['allowBypass'] as bool,
|
allowBypass: json['allowBypass'] as bool,
|
||||||
systemProxy: json['systemProxy'] as bool,
|
systemProxy: json['systemProxy'] as bool,
|
||||||
mixedPort: (json['mixedPort'] as num).toInt(),
|
mixedPort: (json['mixedPort'] as num).toInt(),
|
||||||
@@ -167,6 +169,7 @@ Map<String, dynamic> _$$CoreStateImplToJson(_$CoreStateImpl instance) =>
|
|||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'accessControl': instance.accessControl,
|
'accessControl': instance.accessControl,
|
||||||
'currentProfileName': instance.currentProfileName,
|
'currentProfileName': instance.currentProfileName,
|
||||||
|
'enable': instance.enable,
|
||||||
'allowBypass': instance.allowBypass,
|
'allowBypass': instance.allowBypass,
|
||||||
'systemProxy': instance.systemProxy,
|
'systemProxy': instance.systemProxy,
|
||||||
'mixedPort': instance.mixedPort,
|
'mixedPort': instance.mixedPort,
|
||||||
@@ -188,3 +191,27 @@ Map<String, dynamic> _$$WindowPropsImplToJson(_$WindowPropsImpl instance) =>
|
|||||||
'top': instance.top,
|
'top': instance.top,
|
||||||
'left': instance.left,
|
'left': instance.left,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_$VpnPropsImpl _$$VpnPropsImplFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$VpnPropsImpl(
|
||||||
|
enable: json['enable'] as bool? ?? true,
|
||||||
|
systemProxy: json['systemProxy'] as bool? ?? false,
|
||||||
|
allowBypass: json['allowBypass'] as bool? ?? true,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$VpnPropsImplToJson(_$VpnPropsImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'enable': instance.enable,
|
||||||
|
'systemProxy': instance.systemProxy,
|
||||||
|
'allowBypass': instance.allowBypass,
|
||||||
|
};
|
||||||
|
|
||||||
|
_$DesktopPropsImpl _$$DesktopPropsImplFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$DesktopPropsImpl(
|
||||||
|
systemProxy: json['systemProxy'] as bool? ?? true,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$DesktopPropsImplToJson(_$DesktopPropsImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'systemProxy': instance.systemProxy,
|
||||||
|
};
|
||||||
|
|||||||
@@ -625,6 +625,147 @@ abstract class _ProfilesSelectorState implements ProfilesSelectorState {
|
|||||||
get copyWith => throw _privateConstructorUsedError;
|
get copyWith => throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$NetworkDetectionState {
|
||||||
|
bool get isTesting => throw _privateConstructorUsedError;
|
||||||
|
IpInfo? get ipInfo => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$NetworkDetectionStateCopyWith<NetworkDetectionState> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $NetworkDetectionStateCopyWith<$Res> {
|
||||||
|
factory $NetworkDetectionStateCopyWith(NetworkDetectionState value,
|
||||||
|
$Res Function(NetworkDetectionState) then) =
|
||||||
|
_$NetworkDetectionStateCopyWithImpl<$Res, NetworkDetectionState>;
|
||||||
|
@useResult
|
||||||
|
$Res call({bool isTesting, IpInfo? ipInfo});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$NetworkDetectionStateCopyWithImpl<$Res,
|
||||||
|
$Val extends NetworkDetectionState>
|
||||||
|
implements $NetworkDetectionStateCopyWith<$Res> {
|
||||||
|
_$NetworkDetectionStateCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? isTesting = null,
|
||||||
|
Object? ipInfo = freezed,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
isTesting: null == isTesting
|
||||||
|
? _value.isTesting
|
||||||
|
: isTesting // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
ipInfo: freezed == ipInfo
|
||||||
|
? _value.ipInfo
|
||||||
|
: ipInfo // ignore: cast_nullable_to_non_nullable
|
||||||
|
as IpInfo?,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$NetworkDetectionStateImplCopyWith<$Res>
|
||||||
|
implements $NetworkDetectionStateCopyWith<$Res> {
|
||||||
|
factory _$$NetworkDetectionStateImplCopyWith(
|
||||||
|
_$NetworkDetectionStateImpl value,
|
||||||
|
$Res Function(_$NetworkDetectionStateImpl) then) =
|
||||||
|
__$$NetworkDetectionStateImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({bool isTesting, IpInfo? ipInfo});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$NetworkDetectionStateImplCopyWithImpl<$Res>
|
||||||
|
extends _$NetworkDetectionStateCopyWithImpl<$Res,
|
||||||
|
_$NetworkDetectionStateImpl>
|
||||||
|
implements _$$NetworkDetectionStateImplCopyWith<$Res> {
|
||||||
|
__$$NetworkDetectionStateImplCopyWithImpl(_$NetworkDetectionStateImpl _value,
|
||||||
|
$Res Function(_$NetworkDetectionStateImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? isTesting = null,
|
||||||
|
Object? ipInfo = freezed,
|
||||||
|
}) {
|
||||||
|
return _then(_$NetworkDetectionStateImpl(
|
||||||
|
isTesting: null == isTesting
|
||||||
|
? _value.isTesting
|
||||||
|
: isTesting // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
ipInfo: freezed == ipInfo
|
||||||
|
? _value.ipInfo
|
||||||
|
: ipInfo // ignore: cast_nullable_to_non_nullable
|
||||||
|
as IpInfo?,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$NetworkDetectionStateImpl implements _NetworkDetectionState {
|
||||||
|
const _$NetworkDetectionStateImpl(
|
||||||
|
{required this.isTesting, required this.ipInfo});
|
||||||
|
|
||||||
|
@override
|
||||||
|
final bool isTesting;
|
||||||
|
@override
|
||||||
|
final IpInfo? ipInfo;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'NetworkDetectionState(isTesting: $isTesting, ipInfo: $ipInfo)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$NetworkDetectionStateImpl &&
|
||||||
|
(identical(other.isTesting, isTesting) ||
|
||||||
|
other.isTesting == isTesting) &&
|
||||||
|
(identical(other.ipInfo, ipInfo) || other.ipInfo == ipInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, isTesting, ipInfo);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$NetworkDetectionStateImplCopyWith<_$NetworkDetectionStateImpl>
|
||||||
|
get copyWith => __$$NetworkDetectionStateImplCopyWithImpl<
|
||||||
|
_$NetworkDetectionStateImpl>(this, _$identity);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _NetworkDetectionState implements NetworkDetectionState {
|
||||||
|
const factory _NetworkDetectionState(
|
||||||
|
{required final bool isTesting,
|
||||||
|
required final IpInfo? ipInfo}) = _$NetworkDetectionStateImpl;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get isTesting;
|
||||||
|
@override
|
||||||
|
IpInfo? get ipInfo;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$NetworkDetectionStateImplCopyWith<_$NetworkDetectionStateImpl>
|
||||||
|
get copyWith => throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$ApplicationSelectorState {
|
mixin _$ApplicationSelectorState {
|
||||||
String? get locale => throw _privateConstructorUsedError;
|
String? get locale => throw _privateConstructorUsedError;
|
||||||
@@ -2845,3 +2986,772 @@ abstract class _ProxiesActionsState implements ProxiesActionsState {
|
|||||||
_$$ProxiesActionsStateImplCopyWith<_$ProxiesActionsStateImpl> get copyWith =>
|
_$$ProxiesActionsStateImplCopyWith<_$ProxiesActionsStateImpl> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$AutoLaunchState {
|
||||||
|
bool get isAutoLaunch => throw _privateConstructorUsedError;
|
||||||
|
bool get isOpenTun => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$AutoLaunchStateCopyWith<AutoLaunchState> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $AutoLaunchStateCopyWith<$Res> {
|
||||||
|
factory $AutoLaunchStateCopyWith(
|
||||||
|
AutoLaunchState value, $Res Function(AutoLaunchState) then) =
|
||||||
|
_$AutoLaunchStateCopyWithImpl<$Res, AutoLaunchState>;
|
||||||
|
@useResult
|
||||||
|
$Res call({bool isAutoLaunch, bool isOpenTun});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$AutoLaunchStateCopyWithImpl<$Res, $Val extends AutoLaunchState>
|
||||||
|
implements $AutoLaunchStateCopyWith<$Res> {
|
||||||
|
_$AutoLaunchStateCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? isAutoLaunch = null,
|
||||||
|
Object? isOpenTun = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
isAutoLaunch: null == isAutoLaunch
|
||||||
|
? _value.isAutoLaunch
|
||||||
|
: isAutoLaunch // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
isOpenTun: null == isOpenTun
|
||||||
|
? _value.isOpenTun
|
||||||
|
: isOpenTun // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$AutoLaunchStateImplCopyWith<$Res>
|
||||||
|
implements $AutoLaunchStateCopyWith<$Res> {
|
||||||
|
factory _$$AutoLaunchStateImplCopyWith(_$AutoLaunchStateImpl value,
|
||||||
|
$Res Function(_$AutoLaunchStateImpl) then) =
|
||||||
|
__$$AutoLaunchStateImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({bool isAutoLaunch, bool isOpenTun});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$AutoLaunchStateImplCopyWithImpl<$Res>
|
||||||
|
extends _$AutoLaunchStateCopyWithImpl<$Res, _$AutoLaunchStateImpl>
|
||||||
|
implements _$$AutoLaunchStateImplCopyWith<$Res> {
|
||||||
|
__$$AutoLaunchStateImplCopyWithImpl(
|
||||||
|
_$AutoLaunchStateImpl _value, $Res Function(_$AutoLaunchStateImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? isAutoLaunch = null,
|
||||||
|
Object? isOpenTun = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$AutoLaunchStateImpl(
|
||||||
|
isAutoLaunch: null == isAutoLaunch
|
||||||
|
? _value.isAutoLaunch
|
||||||
|
: isAutoLaunch // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
isOpenTun: null == isOpenTun
|
||||||
|
? _value.isOpenTun
|
||||||
|
: isOpenTun // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$AutoLaunchStateImpl implements _AutoLaunchState {
|
||||||
|
const _$AutoLaunchStateImpl(
|
||||||
|
{required this.isAutoLaunch, required this.isOpenTun});
|
||||||
|
|
||||||
|
@override
|
||||||
|
final bool isAutoLaunch;
|
||||||
|
@override
|
||||||
|
final bool isOpenTun;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'AutoLaunchState(isAutoLaunch: $isAutoLaunch, isOpenTun: $isOpenTun)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$AutoLaunchStateImpl &&
|
||||||
|
(identical(other.isAutoLaunch, isAutoLaunch) ||
|
||||||
|
other.isAutoLaunch == isAutoLaunch) &&
|
||||||
|
(identical(other.isOpenTun, isOpenTun) ||
|
||||||
|
other.isOpenTun == isOpenTun));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, isAutoLaunch, isOpenTun);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$AutoLaunchStateImplCopyWith<_$AutoLaunchStateImpl> get copyWith =>
|
||||||
|
__$$AutoLaunchStateImplCopyWithImpl<_$AutoLaunchStateImpl>(
|
||||||
|
this, _$identity);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _AutoLaunchState implements AutoLaunchState {
|
||||||
|
const factory _AutoLaunchState(
|
||||||
|
{required final bool isAutoLaunch,
|
||||||
|
required final bool isOpenTun}) = _$AutoLaunchStateImpl;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get isAutoLaunch;
|
||||||
|
@override
|
||||||
|
bool get isOpenTun;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$AutoLaunchStateImplCopyWith<_$AutoLaunchStateImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$ProxyState {
|
||||||
|
bool get isStart => throw _privateConstructorUsedError;
|
||||||
|
bool get systemProxy => throw _privateConstructorUsedError;
|
||||||
|
int get port => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$ProxyStateCopyWith<ProxyState> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $ProxyStateCopyWith<$Res> {
|
||||||
|
factory $ProxyStateCopyWith(
|
||||||
|
ProxyState value, $Res Function(ProxyState) then) =
|
||||||
|
_$ProxyStateCopyWithImpl<$Res, ProxyState>;
|
||||||
|
@useResult
|
||||||
|
$Res call({bool isStart, bool systemProxy, int port});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$ProxyStateCopyWithImpl<$Res, $Val extends ProxyState>
|
||||||
|
implements $ProxyStateCopyWith<$Res> {
|
||||||
|
_$ProxyStateCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? isStart = null,
|
||||||
|
Object? systemProxy = null,
|
||||||
|
Object? port = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
isStart: null == isStart
|
||||||
|
? _value.isStart
|
||||||
|
: isStart // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
systemProxy: null == systemProxy
|
||||||
|
? _value.systemProxy
|
||||||
|
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
port: null == port
|
||||||
|
? _value.port
|
||||||
|
: port // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$ProxyStateImplCopyWith<$Res>
|
||||||
|
implements $ProxyStateCopyWith<$Res> {
|
||||||
|
factory _$$ProxyStateImplCopyWith(
|
||||||
|
_$ProxyStateImpl value, $Res Function(_$ProxyStateImpl) then) =
|
||||||
|
__$$ProxyStateImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({bool isStart, bool systemProxy, int port});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$ProxyStateImplCopyWithImpl<$Res>
|
||||||
|
extends _$ProxyStateCopyWithImpl<$Res, _$ProxyStateImpl>
|
||||||
|
implements _$$ProxyStateImplCopyWith<$Res> {
|
||||||
|
__$$ProxyStateImplCopyWithImpl(
|
||||||
|
_$ProxyStateImpl _value, $Res Function(_$ProxyStateImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? isStart = null,
|
||||||
|
Object? systemProxy = null,
|
||||||
|
Object? port = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$ProxyStateImpl(
|
||||||
|
isStart: null == isStart
|
||||||
|
? _value.isStart
|
||||||
|
: isStart // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
systemProxy: null == systemProxy
|
||||||
|
? _value.systemProxy
|
||||||
|
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
port: null == port
|
||||||
|
? _value.port
|
||||||
|
: port // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$ProxyStateImpl implements _ProxyState {
|
||||||
|
const _$ProxyStateImpl(
|
||||||
|
{required this.isStart, required this.systemProxy, required this.port});
|
||||||
|
|
||||||
|
@override
|
||||||
|
final bool isStart;
|
||||||
|
@override
|
||||||
|
final bool systemProxy;
|
||||||
|
@override
|
||||||
|
final int port;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'ProxyState(isStart: $isStart, systemProxy: $systemProxy, port: $port)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$ProxyStateImpl &&
|
||||||
|
(identical(other.isStart, isStart) || other.isStart == isStart) &&
|
||||||
|
(identical(other.systemProxy, systemProxy) ||
|
||||||
|
other.systemProxy == systemProxy) &&
|
||||||
|
(identical(other.port, port) || other.port == port));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, isStart, systemProxy, port);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$ProxyStateImplCopyWith<_$ProxyStateImpl> get copyWith =>
|
||||||
|
__$$ProxyStateImplCopyWithImpl<_$ProxyStateImpl>(this, _$identity);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _ProxyState implements ProxyState {
|
||||||
|
const factory _ProxyState(
|
||||||
|
{required final bool isStart,
|
||||||
|
required final bool systemProxy,
|
||||||
|
required final int port}) = _$ProxyStateImpl;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get isStart;
|
||||||
|
@override
|
||||||
|
bool get systemProxy;
|
||||||
|
@override
|
||||||
|
int get port;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$ProxyStateImplCopyWith<_$ProxyStateImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$ClashConfigState {
|
||||||
|
int get mixedPort => throw _privateConstructorUsedError;
|
||||||
|
bool get allowLan => throw _privateConstructorUsedError;
|
||||||
|
bool get ipv6 => throw _privateConstructorUsedError;
|
||||||
|
String get geodataLoader => throw _privateConstructorUsedError;
|
||||||
|
LogLevel get logLevel => throw _privateConstructorUsedError;
|
||||||
|
String get externalController => throw _privateConstructorUsedError;
|
||||||
|
Mode get mode => throw _privateConstructorUsedError;
|
||||||
|
FindProcessMode get findProcessMode => throw _privateConstructorUsedError;
|
||||||
|
int get keepAliveInterval => throw _privateConstructorUsedError;
|
||||||
|
bool get unifiedDelay => throw _privateConstructorUsedError;
|
||||||
|
bool get tcpConcurrent => throw _privateConstructorUsedError;
|
||||||
|
Tun get tun => throw _privateConstructorUsedError;
|
||||||
|
Dns get dns => throw _privateConstructorUsedError;
|
||||||
|
Map<String, String> get geoXUrl => throw _privateConstructorUsedError;
|
||||||
|
List<String> get rules => throw _privateConstructorUsedError;
|
||||||
|
String? get globalRealUa => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$ClashConfigStateCopyWith<ClashConfigState> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $ClashConfigStateCopyWith<$Res> {
|
||||||
|
factory $ClashConfigStateCopyWith(
|
||||||
|
ClashConfigState value, $Res Function(ClashConfigState) then) =
|
||||||
|
_$ClashConfigStateCopyWithImpl<$Res, ClashConfigState>;
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{int mixedPort,
|
||||||
|
bool allowLan,
|
||||||
|
bool ipv6,
|
||||||
|
String geodataLoader,
|
||||||
|
LogLevel logLevel,
|
||||||
|
String externalController,
|
||||||
|
Mode mode,
|
||||||
|
FindProcessMode findProcessMode,
|
||||||
|
int keepAliveInterval,
|
||||||
|
bool unifiedDelay,
|
||||||
|
bool tcpConcurrent,
|
||||||
|
Tun tun,
|
||||||
|
Dns dns,
|
||||||
|
Map<String, String> geoXUrl,
|
||||||
|
List<String> rules,
|
||||||
|
String? globalRealUa});
|
||||||
|
|
||||||
|
$TunCopyWith<$Res> get tun;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$ClashConfigStateCopyWithImpl<$Res, $Val extends ClashConfigState>
|
||||||
|
implements $ClashConfigStateCopyWith<$Res> {
|
||||||
|
_$ClashConfigStateCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? mixedPort = null,
|
||||||
|
Object? allowLan = null,
|
||||||
|
Object? ipv6 = null,
|
||||||
|
Object? geodataLoader = null,
|
||||||
|
Object? logLevel = null,
|
||||||
|
Object? externalController = null,
|
||||||
|
Object? mode = null,
|
||||||
|
Object? findProcessMode = null,
|
||||||
|
Object? keepAliveInterval = null,
|
||||||
|
Object? unifiedDelay = null,
|
||||||
|
Object? tcpConcurrent = null,
|
||||||
|
Object? tun = null,
|
||||||
|
Object? dns = null,
|
||||||
|
Object? geoXUrl = null,
|
||||||
|
Object? rules = null,
|
||||||
|
Object? globalRealUa = freezed,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
mixedPort: null == mixedPort
|
||||||
|
? _value.mixedPort
|
||||||
|
: mixedPort // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
|
allowLan: null == allowLan
|
||||||
|
? _value.allowLan
|
||||||
|
: allowLan // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
ipv6: null == ipv6
|
||||||
|
? _value.ipv6
|
||||||
|
: ipv6 // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
geodataLoader: null == geodataLoader
|
||||||
|
? _value.geodataLoader
|
||||||
|
: geodataLoader // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
logLevel: null == logLevel
|
||||||
|
? _value.logLevel
|
||||||
|
: logLevel // ignore: cast_nullable_to_non_nullable
|
||||||
|
as LogLevel,
|
||||||
|
externalController: null == externalController
|
||||||
|
? _value.externalController
|
||||||
|
: externalController // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
mode: null == mode
|
||||||
|
? _value.mode
|
||||||
|
: mode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Mode,
|
||||||
|
findProcessMode: null == findProcessMode
|
||||||
|
? _value.findProcessMode
|
||||||
|
: findProcessMode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as FindProcessMode,
|
||||||
|
keepAliveInterval: null == keepAliveInterval
|
||||||
|
? _value.keepAliveInterval
|
||||||
|
: keepAliveInterval // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
|
unifiedDelay: null == unifiedDelay
|
||||||
|
? _value.unifiedDelay
|
||||||
|
: unifiedDelay // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
tcpConcurrent: null == tcpConcurrent
|
||||||
|
? _value.tcpConcurrent
|
||||||
|
: tcpConcurrent // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
tun: null == tun
|
||||||
|
? _value.tun
|
||||||
|
: tun // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Tun,
|
||||||
|
dns: null == dns
|
||||||
|
? _value.dns
|
||||||
|
: dns // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Dns,
|
||||||
|
geoXUrl: null == geoXUrl
|
||||||
|
? _value.geoXUrl
|
||||||
|
: geoXUrl // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Map<String, String>,
|
||||||
|
rules: null == rules
|
||||||
|
? _value.rules
|
||||||
|
: rules // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
globalRealUa: freezed == globalRealUa
|
||||||
|
? _value.globalRealUa
|
||||||
|
: globalRealUa // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
$TunCopyWith<$Res> get tun {
|
||||||
|
return $TunCopyWith<$Res>(_value.tun, (value) {
|
||||||
|
return _then(_value.copyWith(tun: value) as $Val);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$ClashConfigStateImplCopyWith<$Res>
|
||||||
|
implements $ClashConfigStateCopyWith<$Res> {
|
||||||
|
factory _$$ClashConfigStateImplCopyWith(_$ClashConfigStateImpl value,
|
||||||
|
$Res Function(_$ClashConfigStateImpl) then) =
|
||||||
|
__$$ClashConfigStateImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{int mixedPort,
|
||||||
|
bool allowLan,
|
||||||
|
bool ipv6,
|
||||||
|
String geodataLoader,
|
||||||
|
LogLevel logLevel,
|
||||||
|
String externalController,
|
||||||
|
Mode mode,
|
||||||
|
FindProcessMode findProcessMode,
|
||||||
|
int keepAliveInterval,
|
||||||
|
bool unifiedDelay,
|
||||||
|
bool tcpConcurrent,
|
||||||
|
Tun tun,
|
||||||
|
Dns dns,
|
||||||
|
Map<String, String> geoXUrl,
|
||||||
|
List<String> rules,
|
||||||
|
String? globalRealUa});
|
||||||
|
|
||||||
|
@override
|
||||||
|
$TunCopyWith<$Res> get tun;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$ClashConfigStateImplCopyWithImpl<$Res>
|
||||||
|
extends _$ClashConfigStateCopyWithImpl<$Res, _$ClashConfigStateImpl>
|
||||||
|
implements _$$ClashConfigStateImplCopyWith<$Res> {
|
||||||
|
__$$ClashConfigStateImplCopyWithImpl(_$ClashConfigStateImpl _value,
|
||||||
|
$Res Function(_$ClashConfigStateImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? mixedPort = null,
|
||||||
|
Object? allowLan = null,
|
||||||
|
Object? ipv6 = null,
|
||||||
|
Object? geodataLoader = null,
|
||||||
|
Object? logLevel = null,
|
||||||
|
Object? externalController = null,
|
||||||
|
Object? mode = null,
|
||||||
|
Object? findProcessMode = null,
|
||||||
|
Object? keepAliveInterval = null,
|
||||||
|
Object? unifiedDelay = null,
|
||||||
|
Object? tcpConcurrent = null,
|
||||||
|
Object? tun = null,
|
||||||
|
Object? dns = null,
|
||||||
|
Object? geoXUrl = null,
|
||||||
|
Object? rules = null,
|
||||||
|
Object? globalRealUa = freezed,
|
||||||
|
}) {
|
||||||
|
return _then(_$ClashConfigStateImpl(
|
||||||
|
mixedPort: null == mixedPort
|
||||||
|
? _value.mixedPort
|
||||||
|
: mixedPort // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
|
allowLan: null == allowLan
|
||||||
|
? _value.allowLan
|
||||||
|
: allowLan // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
ipv6: null == ipv6
|
||||||
|
? _value.ipv6
|
||||||
|
: ipv6 // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
geodataLoader: null == geodataLoader
|
||||||
|
? _value.geodataLoader
|
||||||
|
: geodataLoader // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
logLevel: null == logLevel
|
||||||
|
? _value.logLevel
|
||||||
|
: logLevel // ignore: cast_nullable_to_non_nullable
|
||||||
|
as LogLevel,
|
||||||
|
externalController: null == externalController
|
||||||
|
? _value.externalController
|
||||||
|
: externalController // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
mode: null == mode
|
||||||
|
? _value.mode
|
||||||
|
: mode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Mode,
|
||||||
|
findProcessMode: null == findProcessMode
|
||||||
|
? _value.findProcessMode
|
||||||
|
: findProcessMode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as FindProcessMode,
|
||||||
|
keepAliveInterval: null == keepAliveInterval
|
||||||
|
? _value.keepAliveInterval
|
||||||
|
: keepAliveInterval // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
|
unifiedDelay: null == unifiedDelay
|
||||||
|
? _value.unifiedDelay
|
||||||
|
: unifiedDelay // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
tcpConcurrent: null == tcpConcurrent
|
||||||
|
? _value.tcpConcurrent
|
||||||
|
: tcpConcurrent // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
tun: null == tun
|
||||||
|
? _value.tun
|
||||||
|
: tun // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Tun,
|
||||||
|
dns: null == dns
|
||||||
|
? _value.dns
|
||||||
|
: dns // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Dns,
|
||||||
|
geoXUrl: null == geoXUrl
|
||||||
|
? _value._geoXUrl
|
||||||
|
: geoXUrl // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Map<String, String>,
|
||||||
|
rules: null == rules
|
||||||
|
? _value._rules
|
||||||
|
: rules // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
globalRealUa: freezed == globalRealUa
|
||||||
|
? _value.globalRealUa
|
||||||
|
: globalRealUa // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$ClashConfigStateImpl implements _ClashConfigState {
|
||||||
|
const _$ClashConfigStateImpl(
|
||||||
|
{required this.mixedPort,
|
||||||
|
required this.allowLan,
|
||||||
|
required this.ipv6,
|
||||||
|
required this.geodataLoader,
|
||||||
|
required this.logLevel,
|
||||||
|
required this.externalController,
|
||||||
|
required this.mode,
|
||||||
|
required this.findProcessMode,
|
||||||
|
required this.keepAliveInterval,
|
||||||
|
required this.unifiedDelay,
|
||||||
|
required this.tcpConcurrent,
|
||||||
|
required this.tun,
|
||||||
|
required this.dns,
|
||||||
|
required final Map<String, String> geoXUrl,
|
||||||
|
required final List<String> rules,
|
||||||
|
required this.globalRealUa})
|
||||||
|
: _geoXUrl = geoXUrl,
|
||||||
|
_rules = rules;
|
||||||
|
|
||||||
|
@override
|
||||||
|
final int mixedPort;
|
||||||
|
@override
|
||||||
|
final bool allowLan;
|
||||||
|
@override
|
||||||
|
final bool ipv6;
|
||||||
|
@override
|
||||||
|
final String geodataLoader;
|
||||||
|
@override
|
||||||
|
final LogLevel logLevel;
|
||||||
|
@override
|
||||||
|
final String externalController;
|
||||||
|
@override
|
||||||
|
final Mode mode;
|
||||||
|
@override
|
||||||
|
final FindProcessMode findProcessMode;
|
||||||
|
@override
|
||||||
|
final int keepAliveInterval;
|
||||||
|
@override
|
||||||
|
final bool unifiedDelay;
|
||||||
|
@override
|
||||||
|
final bool tcpConcurrent;
|
||||||
|
@override
|
||||||
|
final Tun tun;
|
||||||
|
@override
|
||||||
|
final Dns dns;
|
||||||
|
final Map<String, String> _geoXUrl;
|
||||||
|
@override
|
||||||
|
Map<String, String> get geoXUrl {
|
||||||
|
if (_geoXUrl is EqualUnmodifiableMapView) return _geoXUrl;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableMapView(_geoXUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<String> _rules;
|
||||||
|
@override
|
||||||
|
List<String> get rules {
|
||||||
|
if (_rules is EqualUnmodifiableListView) return _rules;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_rules);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String? globalRealUa;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'ClashConfigState(mixedPort: $mixedPort, allowLan: $allowLan, ipv6: $ipv6, geodataLoader: $geodataLoader, logLevel: $logLevel, externalController: $externalController, mode: $mode, findProcessMode: $findProcessMode, keepAliveInterval: $keepAliveInterval, unifiedDelay: $unifiedDelay, tcpConcurrent: $tcpConcurrent, tun: $tun, dns: $dns, geoXUrl: $geoXUrl, rules: $rules, globalRealUa: $globalRealUa)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$ClashConfigStateImpl &&
|
||||||
|
(identical(other.mixedPort, mixedPort) ||
|
||||||
|
other.mixedPort == mixedPort) &&
|
||||||
|
(identical(other.allowLan, allowLan) ||
|
||||||
|
other.allowLan == allowLan) &&
|
||||||
|
(identical(other.ipv6, ipv6) || other.ipv6 == ipv6) &&
|
||||||
|
(identical(other.geodataLoader, geodataLoader) ||
|
||||||
|
other.geodataLoader == geodataLoader) &&
|
||||||
|
(identical(other.logLevel, logLevel) ||
|
||||||
|
other.logLevel == logLevel) &&
|
||||||
|
(identical(other.externalController, externalController) ||
|
||||||
|
other.externalController == externalController) &&
|
||||||
|
(identical(other.mode, mode) || other.mode == mode) &&
|
||||||
|
(identical(other.findProcessMode, findProcessMode) ||
|
||||||
|
other.findProcessMode == findProcessMode) &&
|
||||||
|
(identical(other.keepAliveInterval, keepAliveInterval) ||
|
||||||
|
other.keepAliveInterval == keepAliveInterval) &&
|
||||||
|
(identical(other.unifiedDelay, unifiedDelay) ||
|
||||||
|
other.unifiedDelay == unifiedDelay) &&
|
||||||
|
(identical(other.tcpConcurrent, tcpConcurrent) ||
|
||||||
|
other.tcpConcurrent == tcpConcurrent) &&
|
||||||
|
(identical(other.tun, tun) || other.tun == tun) &&
|
||||||
|
(identical(other.dns, dns) || other.dns == dns) &&
|
||||||
|
const DeepCollectionEquality().equals(other._geoXUrl, _geoXUrl) &&
|
||||||
|
const DeepCollectionEquality().equals(other._rules, _rules) &&
|
||||||
|
(identical(other.globalRealUa, globalRealUa) ||
|
||||||
|
other.globalRealUa == globalRealUa));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(
|
||||||
|
runtimeType,
|
||||||
|
mixedPort,
|
||||||
|
allowLan,
|
||||||
|
ipv6,
|
||||||
|
geodataLoader,
|
||||||
|
logLevel,
|
||||||
|
externalController,
|
||||||
|
mode,
|
||||||
|
findProcessMode,
|
||||||
|
keepAliveInterval,
|
||||||
|
unifiedDelay,
|
||||||
|
tcpConcurrent,
|
||||||
|
tun,
|
||||||
|
dns,
|
||||||
|
const DeepCollectionEquality().hash(_geoXUrl),
|
||||||
|
const DeepCollectionEquality().hash(_rules),
|
||||||
|
globalRealUa);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$ClashConfigStateImplCopyWith<_$ClashConfigStateImpl> get copyWith =>
|
||||||
|
__$$ClashConfigStateImplCopyWithImpl<_$ClashConfigStateImpl>(
|
||||||
|
this, _$identity);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _ClashConfigState implements ClashConfigState {
|
||||||
|
const factory _ClashConfigState(
|
||||||
|
{required final int mixedPort,
|
||||||
|
required final bool allowLan,
|
||||||
|
required final bool ipv6,
|
||||||
|
required final String geodataLoader,
|
||||||
|
required final LogLevel logLevel,
|
||||||
|
required final String externalController,
|
||||||
|
required final Mode mode,
|
||||||
|
required final FindProcessMode findProcessMode,
|
||||||
|
required final int keepAliveInterval,
|
||||||
|
required final bool unifiedDelay,
|
||||||
|
required final bool tcpConcurrent,
|
||||||
|
required final Tun tun,
|
||||||
|
required final Dns dns,
|
||||||
|
required final Map<String, String> geoXUrl,
|
||||||
|
required final List<String> rules,
|
||||||
|
required final String? globalRealUa}) = _$ClashConfigStateImpl;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get mixedPort;
|
||||||
|
@override
|
||||||
|
bool get allowLan;
|
||||||
|
@override
|
||||||
|
bool get ipv6;
|
||||||
|
@override
|
||||||
|
String get geodataLoader;
|
||||||
|
@override
|
||||||
|
LogLevel get logLevel;
|
||||||
|
@override
|
||||||
|
String get externalController;
|
||||||
|
@override
|
||||||
|
Mode get mode;
|
||||||
|
@override
|
||||||
|
FindProcessMode get findProcessMode;
|
||||||
|
@override
|
||||||
|
int get keepAliveInterval;
|
||||||
|
@override
|
||||||
|
bool get unifiedDelay;
|
||||||
|
@override
|
||||||
|
bool get tcpConcurrent;
|
||||||
|
@override
|
||||||
|
Tun get tun;
|
||||||
|
@override
|
||||||
|
Dns get dns;
|
||||||
|
@override
|
||||||
|
Map<String, String> get geoXUrl;
|
||||||
|
@override
|
||||||
|
List<String> get rules;
|
||||||
|
@override
|
||||||
|
String? get globalRealUa;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$ClashConfigStateImplCopyWith<_$ClashConfigStateImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,6 +41,14 @@ class ProfilesSelectorState with _$ProfilesSelectorState {
|
|||||||
}) = _ProfilesSelectorState;
|
}) = _ProfilesSelectorState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class NetworkDetectionState with _$NetworkDetectionState {
|
||||||
|
const factory NetworkDetectionState({
|
||||||
|
required bool isTesting,
|
||||||
|
required IpInfo? ipInfo,
|
||||||
|
}) = _NetworkDetectionState;
|
||||||
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class ApplicationSelectorState with _$ApplicationSelectorState {
|
class ApplicationSelectorState with _$ApplicationSelectorState {
|
||||||
const factory ApplicationSelectorState({
|
const factory ApplicationSelectorState({
|
||||||
@@ -148,19 +156,19 @@ extension PackageListSelectorStateExt on PackageListSelectorState {
|
|||||||
return packages
|
return packages
|
||||||
.where((item) => isFilterSystemApp ? item.isSystem == false : true)
|
.where((item) => isFilterSystemApp ? item.isSystem == false : true)
|
||||||
.sorted(
|
.sorted(
|
||||||
(a, b) {
|
(a, b) {
|
||||||
return switch (sort) {
|
return switch (sort) {
|
||||||
AccessSortType.none => 0,
|
AccessSortType.none => 0,
|
||||||
AccessSortType.name =>
|
AccessSortType.name => other.sortByChar(
|
||||||
other.sortByChar(
|
PinyinHelper.getPinyin(a.label),
|
||||||
PinyinHelper.getPinyin(a.label),
|
PinyinHelper.getPinyin(b.label),
|
||||||
PinyinHelper.getPinyin(b.label),
|
),
|
||||||
),
|
AccessSortType.time =>
|
||||||
AccessSortType.time => a.firstInstallTime.compareTo(b.firstInstallTime),
|
a.firstInstallTime.compareTo(b.firstInstallTime),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
).sorted(
|
).sorted(
|
||||||
(a, b) {
|
(a, b) {
|
||||||
final isSelectA = selectedList.contains(a.packageName);
|
final isSelectA = selectedList.contains(a.packageName);
|
||||||
final isSelectB = selectedList.contains(b.packageName);
|
final isSelectB = selectedList.contains(b.packageName);
|
||||||
if (isSelectA && isSelectB) return 0;
|
if (isSelectA && isSelectB) return 0;
|
||||||
@@ -187,3 +195,42 @@ class ProxiesActionsState with _$ProxiesActionsState {
|
|||||||
required bool hasProvider,
|
required bool hasProvider,
|
||||||
}) = _ProxiesActionsState;
|
}) = _ProxiesActionsState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class AutoLaunchState with _$AutoLaunchState {
|
||||||
|
const factory AutoLaunchState({
|
||||||
|
required bool isAutoLaunch,
|
||||||
|
required bool isOpenTun,
|
||||||
|
}) = _AutoLaunchState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class ProxyState with _$ProxyState {
|
||||||
|
const factory ProxyState({
|
||||||
|
required bool isStart,
|
||||||
|
required bool systemProxy,
|
||||||
|
required int port,
|
||||||
|
}) = _ProxyState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class ClashConfigState with _$ClashConfigState {
|
||||||
|
const factory ClashConfigState({
|
||||||
|
required int mixedPort,
|
||||||
|
required bool allowLan,
|
||||||
|
required bool ipv6,
|
||||||
|
required String geodataLoader,
|
||||||
|
required LogLevel logLevel,
|
||||||
|
required String externalController,
|
||||||
|
required Mode mode,
|
||||||
|
required FindProcessMode findProcessMode,
|
||||||
|
required int keepAliveInterval,
|
||||||
|
required bool unifiedDelay,
|
||||||
|
required bool tcpConcurrent,
|
||||||
|
required Tun tun,
|
||||||
|
required Dns dns,
|
||||||
|
required GeoXMap geoXUrl,
|
||||||
|
required List<String> rules,
|
||||||
|
required String? globalRealUa,
|
||||||
|
}) = _ClashConfigState;
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,20 +13,6 @@ typedef OnSelected = void Function(int index);
|
|||||||
class HomePage extends StatelessWidget {
|
class HomePage extends StatelessWidget {
|
||||||
const HomePage({super.key});
|
const HomePage({super.key});
|
||||||
|
|
||||||
_navigationBarContainer({
|
|
||||||
required BuildContext context,
|
|
||||||
required Widget child,
|
|
||||||
}) {
|
|
||||||
// if (!system.isDesktop) return child;
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.all(16).copyWith(
|
|
||||||
right: 0,
|
|
||||||
),
|
|
||||||
color: context.colorScheme.surface,
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_getNavigationBar({
|
_getNavigationBar({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required ViewMode viewMode,
|
required ViewMode viewMode,
|
||||||
@@ -47,61 +33,78 @@ class HomePage extends StatelessWidget {
|
|||||||
selectedIndex: currentIndex,
|
selectedIndex: currentIndex,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final extended = viewMode == ViewMode.desktop;
|
return LayoutBuilder(
|
||||||
return _navigationBarContainer(
|
builder: (_, container) {
|
||||||
context: context,
|
return Material(
|
||||||
child: NavigationRail(
|
color: context.colorScheme.surfaceContainer,
|
||||||
groupAlignment: -0.8,
|
child: Container(
|
||||||
selectedIconTheme: IconThemeData(
|
padding: const EdgeInsets.symmetric(
|
||||||
color: context.colorScheme.onSurfaceVariant,
|
vertical: 16,
|
||||||
),
|
|
||||||
unselectedIconTheme: IconThemeData(
|
|
||||||
color: context.colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
selectedLabelTextStyle: context.textTheme.labelLarge!.copyWith(
|
|
||||||
color: context.colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
unselectedLabelTextStyle: context.textTheme.labelLarge!.copyWith(
|
|
||||||
color: context.colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
destinations: navigationItems
|
|
||||||
.map(
|
|
||||||
(e) => NavigationRailDestination(
|
|
||||||
icon: e.icon,
|
|
||||||
label: Text(
|
|
||||||
Intl.message(e.label),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
onDestinationSelected: globalState.appController.toPage,
|
|
||||||
extended: extended,
|
|
||||||
minExtendedWidth: 200,
|
|
||||||
selectedIndex: currentIndex,
|
|
||||||
labelType: extended
|
|
||||||
? NavigationRailLabelType.none
|
|
||||||
: NavigationRailLabelType.selected,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return NavigationRail(
|
|
||||||
groupAlignment: -0.95,
|
|
||||||
destinations: navigationItems
|
|
||||||
.map(
|
|
||||||
(e) => NavigationRailDestination(
|
|
||||||
icon: e.icon,
|
|
||||||
label: Text(
|
|
||||||
Intl.message(e.label),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
height: container.maxHeight,
|
||||||
.toList(),
|
child: Column(
|
||||||
onDestinationSelected: globalState.appController.toPage,
|
children: [
|
||||||
extended: extended,
|
Expanded(
|
||||||
minExtendedWidth: 172,
|
child: SingleChildScrollView(
|
||||||
selectedIndex: currentIndex,
|
child: IntrinsicHeight(
|
||||||
labelType: extended
|
child: Selector<Config, bool>(
|
||||||
? NavigationRailLabelType.none
|
selector: (_, config) => config.showLabel,
|
||||||
: NavigationRailLabelType.selected,
|
builder: (_, showLabel, __) {
|
||||||
|
return NavigationRail(
|
||||||
|
backgroundColor:
|
||||||
|
context.colorScheme.surfaceContainer,
|
||||||
|
selectedIconTheme: IconThemeData(
|
||||||
|
color: context.colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
unselectedIconTheme: IconThemeData(
|
||||||
|
color: context.colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
selectedLabelTextStyle:
|
||||||
|
context.textTheme.labelLarge!.copyWith(
|
||||||
|
color: context.colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
unselectedLabelTextStyle:
|
||||||
|
context.textTheme.labelLarge!.copyWith(
|
||||||
|
color: context.colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
destinations: navigationItems
|
||||||
|
.map(
|
||||||
|
(e) => NavigationRailDestination(
|
||||||
|
icon: e.icon,
|
||||||
|
label: Text(
|
||||||
|
Intl.message(e.label),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
onDestinationSelected:
|
||||||
|
globalState.appController.toPage,
|
||||||
|
extended: false,
|
||||||
|
selectedIndex: currentIndex,
|
||||||
|
labelType: showLabel
|
||||||
|
? NavigationRailLabelType.all
|
||||||
|
: NavigationRailLabelType.none,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 16,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
config.showLabel = !config.showLabel;
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.menu),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
29
lib/plugins/service.dart
Normal file
29
lib/plugins/service.dart
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'dart:isolate';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
class Service {
|
||||||
|
static Service? _instance;
|
||||||
|
late MethodChannel methodChannel;
|
||||||
|
ReceivePort? receiver;
|
||||||
|
|
||||||
|
Service._internal() {
|
||||||
|
methodChannel = const MethodChannel("service");
|
||||||
|
}
|
||||||
|
|
||||||
|
factory Service() {
|
||||||
|
_instance ??= Service._internal();
|
||||||
|
return _instance!;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool?> init() async {
|
||||||
|
return await methodChannel.invokeMethod<bool>("init");
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool?> destroy() async {
|
||||||
|
return await methodChannel.invokeMethod<bool>("destroy");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final service = Platform.isAndroid ? Service() : null;
|
||||||
@@ -4,22 +4,18 @@ import 'dart:ffi';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
import 'package:fl_clash/clash/clash.dart';
|
import 'package:fl_clash/clash/clash.dart';
|
||||||
import 'package:fl_clash/common/common.dart';
|
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:proxy/proxy_platform_interface.dart';
|
|
||||||
|
|
||||||
class Proxy extends ProxyPlatform {
|
class Vpn {
|
||||||
static Proxy? _instance;
|
static Vpn? _instance;
|
||||||
late MethodChannel methodChannel;
|
late MethodChannel methodChannel;
|
||||||
ReceivePort? receiver;
|
ReceivePort? receiver;
|
||||||
ServiceMessageListener? _serviceMessageHandler;
|
ServiceMessageListener? _serviceMessageHandler;
|
||||||
|
|
||||||
Proxy._internal() {
|
Vpn._internal() {
|
||||||
methodChannel = const MethodChannel("proxy");
|
methodChannel = const MethodChannel("vpn");
|
||||||
methodChannel.setMethodCallHandler((call) async {
|
methodChannel.setMethodCallHandler((call) async {
|
||||||
switch (call.method) {
|
switch (call.method) {
|
||||||
case "started":
|
case "started":
|
||||||
@@ -32,36 +28,21 @@ class Proxy extends ProxyPlatform {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
factory Proxy() {
|
factory Vpn() {
|
||||||
_instance ??= Proxy._internal();
|
_instance ??= Vpn._internal();
|
||||||
return _instance!;
|
return _instance!;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool?> initService() async {
|
Future<bool?> startVpn(port) async {
|
||||||
return await methodChannel.invokeMethod<bool>("initService");
|
|
||||||
}
|
|
||||||
|
|
||||||
handleStop() {
|
|
||||||
globalState.stopSystemProxy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<bool?> startProxy(port) async {
|
|
||||||
final state = clashCore.getState();
|
final state = clashCore.getState();
|
||||||
return await methodChannel.invokeMethod<bool>("startProxy", {
|
return await methodChannel.invokeMethod<bool>("start", {
|
||||||
'port': state.mixedPort,
|
'port': state.mixedPort,
|
||||||
'args': json.encode(state),
|
'args': json.encode(state),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
Future<bool?> stopVpn() async {
|
||||||
Future<bool?> stopProxy() async {
|
return await methodChannel.invokeMethod<bool>("stop");
|
||||||
clashCore.stopTun();
|
|
||||||
final isStop = await methodChannel.invokeMethod<bool>("stopProxy");
|
|
||||||
if (isStop == true) {
|
|
||||||
startTime = null;
|
|
||||||
}
|
|
||||||
return isStop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool?> setProtect(int fd) async {
|
Future<bool?> setProtect(int fd) async {
|
||||||
@@ -78,10 +59,7 @@ class Proxy extends ProxyPlatform {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get isStart => startTime != null && startTime!.isBeforeNow;
|
|
||||||
|
|
||||||
onStarted(int? fd) {
|
onStarted(int? fd) {
|
||||||
if (fd == null) return;
|
|
||||||
if (receiver != null) {
|
if (receiver != null) {
|
||||||
receiver!.close();
|
receiver!.close();
|
||||||
receiver == null;
|
receiver == null;
|
||||||
@@ -90,11 +68,7 @@ class Proxy extends ProxyPlatform {
|
|||||||
receiver!.listen((message) {
|
receiver!.listen((message) {
|
||||||
_handleServiceMessage(message);
|
_handleServiceMessage(message);
|
||||||
});
|
});
|
||||||
clashCore.startTun(fd, receiver!.sendPort.nativePort);
|
clashCore.startTun(fd ?? 0, receiver!.sendPort.nativePort);
|
||||||
}
|
|
||||||
|
|
||||||
updateStartTime() {
|
|
||||||
startTime = clashCore.getRunTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setServiceMessageHandler(ServiceMessageListener serviceMessageListener) {
|
setServiceMessageHandler(ServiceMessageListener serviceMessageListener) {
|
||||||
@@ -103,7 +77,6 @@ class Proxy extends ProxyPlatform {
|
|||||||
|
|
||||||
_handleServiceMessage(String message) {
|
_handleServiceMessage(String message) {
|
||||||
final m = ServiceMessage.fromJson(json.decode(message));
|
final m = ServiceMessage.fromJson(json.decode(message));
|
||||||
debugPrint(m.toString());
|
|
||||||
switch (m.type) {
|
switch (m.type) {
|
||||||
case ServiceMessageType.protect:
|
case ServiceMessageType.protect:
|
||||||
_serviceMessageHandler?.onProtect(Fd.fromJson(m.data));
|
_serviceMessageHandler?.onProtect(Fd.fromJson(m.data));
|
||||||
@@ -117,4 +90,4 @@ class Proxy extends ProxyPlatform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final proxy = Platform.isAndroid ? Proxy() : null;
|
final vpn = Platform.isAndroid ? Vpn() : null;
|
||||||
@@ -3,7 +3,8 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:animations/animations.dart';
|
import 'package:animations/animations.dart';
|
||||||
import 'package:fl_clash/clash/clash.dart';
|
import 'package:fl_clash/clash/clash.dart';
|
||||||
import 'package:fl_clash/plugins/proxy.dart';
|
import 'package:fl_clash/plugins/service.dart';
|
||||||
|
import 'package:fl_clash/plugins/vpn.dart';
|
||||||
import 'package:fl_clash/widgets/scaffold.dart';
|
import 'package:fl_clash/widgets/scaffold.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
@@ -21,11 +22,14 @@ class GlobalState {
|
|||||||
late PackageInfo packageInfo;
|
late PackageInfo packageInfo;
|
||||||
Function? updateCurrentDelayDebounce;
|
Function? updateCurrentDelayDebounce;
|
||||||
PageController? pageController;
|
PageController? pageController;
|
||||||
|
DateTime? startTime;
|
||||||
final navigatorKey = GlobalKey<NavigatorState>();
|
final navigatorKey = GlobalKey<NavigatorState>();
|
||||||
late AppController appController;
|
late AppController appController;
|
||||||
GlobalKey<CommonScaffoldState> homeScaffoldKey = GlobalKey();
|
GlobalKey<CommonScaffoldState> homeScaffoldKey = GlobalKey();
|
||||||
List<Function> updateFunctionLists = [];
|
List<Function> updateFunctionLists = [];
|
||||||
|
|
||||||
|
bool get isStart => startTime != null && startTime!.isBeforeNow;
|
||||||
|
|
||||||
startListenUpdate() {
|
startListenUpdate() {
|
||||||
if (timer != null && timer!.isActive == true) return;
|
if (timer != null && timer!.isActive == true) return;
|
||||||
timer = Timer.periodic(const Duration(seconds: 1), (Timer t) {
|
timer = Timer.periodic(const Duration(seconds: 1), (Timer t) {
|
||||||
@@ -65,23 +69,32 @@ class GlobalState {
|
|||||||
appState.versionInfo = clashCore.getVersionInfo();
|
appState.versionInfo = clashCore.getVersionInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> startSystemProxy({
|
handleStart({
|
||||||
required AppState appState,
|
|
||||||
required Config config,
|
required Config config,
|
||||||
required ClashConfig clashConfig,
|
required ClashConfig clashConfig,
|
||||||
}) async {
|
}) async {
|
||||||
if (!globalState.isVpnService && Platform.isAndroid) {
|
clashCore.start();
|
||||||
await proxy?.initService();
|
if (globalState.isVpnService) {
|
||||||
} else {
|
await vpn?.startVpn(clashConfig.mixedPort);
|
||||||
await proxyManager.startProxy(
|
startListenUpdate();
|
||||||
port: clashConfig.mixedPort,
|
return;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
startTime ??= DateTime.now();
|
||||||
|
await service?.init();
|
||||||
startListenUpdate();
|
startListenUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> stopSystemProxy() async {
|
updateStartTime() {
|
||||||
await proxyManager.stopProxy();
|
startTime = clashCore.getRunTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
handleStop() async {
|
||||||
|
clashCore.stop();
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
clashCore.stopTun();
|
||||||
|
}
|
||||||
|
await service?.destroy();
|
||||||
|
startTime = null;
|
||||||
stopListenUpdate();
|
stopListenUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,12 +129,14 @@ class GlobalState {
|
|||||||
);
|
);
|
||||||
clashCore.setState(
|
clashCore.setState(
|
||||||
CoreState(
|
CoreState(
|
||||||
|
enable: config.vpnProps.enable,
|
||||||
accessControl: config.isAccessControl ? config.accessControl : null,
|
accessControl: config.isAccessControl ? config.accessControl : null,
|
||||||
allowBypass: config.allowBypass,
|
allowBypass: config.vpnProps.allowBypass,
|
||||||
systemProxy: config.systemProxy,
|
systemProxy: config.vpnProps.systemProxy,
|
||||||
mixedPort: clashConfig.mixedPort,
|
mixedPort: clashConfig.mixedPort,
|
||||||
onlyProxy: config.onlyProxy,
|
onlyProxy: config.onlyProxy,
|
||||||
currentProfileName: config.currentProfile?.label ?? config.currentProfileId ?? "",
|
currentProfileName:
|
||||||
|
config.currentProfile?.label ?? config.currentProfileId ?? "",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -207,7 +222,7 @@ class GlobalState {
|
|||||||
}) {
|
}) {
|
||||||
final traffic = clashCore.getTraffic();
|
final traffic = clashCore.getTraffic();
|
||||||
if (Platform.isAndroid && isVpnService == true) {
|
if (Platform.isAndroid && isVpnService == true) {
|
||||||
proxy?.startForeground(
|
vpn?.startForeground(
|
||||||
title: clashCore.getState().currentProfileName,
|
title: clashCore.getState().currentProfileName,
|
||||||
content: "$traffic",
|
content: "$traffic",
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
|
import 'package:fl_clash/state.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'text.dart';
|
import 'text.dart';
|
||||||
@@ -29,12 +30,13 @@ class InfoHeader extends StatelessWidget {
|
|||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
if (info.iconData != null) ...[
|
if (info.iconData != null) ...[
|
||||||
Icon(
|
Icon(
|
||||||
@@ -46,6 +48,7 @@ class InfoHeader extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
Flexible(
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
child: TooltipText(
|
child: TooltipText(
|
||||||
text: Text(
|
text: Text(
|
||||||
info.label,
|
info.label,
|
||||||
@@ -58,6 +61,9 @@ class InfoHeader extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 8,
|
||||||
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
@@ -155,6 +161,18 @@ class CommonCard extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (selectWidget != null && isSelected) {
|
||||||
|
final List<Widget> children = [];
|
||||||
|
children.add(childWidget);
|
||||||
|
children.add(
|
||||||
|
Positioned.fill(
|
||||||
|
child: selectWidget!,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
childWidget = Stack(
|
||||||
|
children: children,
|
||||||
|
);
|
||||||
|
}
|
||||||
return OutlinedButton(
|
return OutlinedButton(
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
@@ -172,25 +190,7 @@ class CommonCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
child: Builder(
|
child: childWidget,
|
||||||
builder: (_) {
|
|
||||||
if (selectWidget == null) {
|
|
||||||
return childWidget;
|
|
||||||
}
|
|
||||||
List<Widget> children = [];
|
|
||||||
children.add(childWidget);
|
|
||||||
if (isSelected) {
|
|
||||||
children.add(
|
|
||||||
Positioned.fill(
|
|
||||||
child: selectWidget!,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Stack(
|
|
||||||
children: children,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import 'package:fl_clash/clash/clash.dart';
|
import 'package:fl_clash/clash/clash.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:fl_clash/plugins/proxy.dart';
|
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../common/function.dart';
|
||||||
|
|
||||||
class ClashContainer extends StatefulWidget {
|
class ClashContainer extends StatefulWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
@@ -19,12 +20,49 @@ class ClashContainer extends StatefulWidget {
|
|||||||
|
|
||||||
class _ClashContainerState extends State<ClashContainer>
|
class _ClashContainerState extends State<ClashContainer>
|
||||||
with AppMessageListener {
|
with AppMessageListener {
|
||||||
|
Function? updateClashConfigDebounce;
|
||||||
|
|
||||||
|
Widget _updateContainer(Widget child) {
|
||||||
|
return Selector<ClashConfig, ClashConfigState>(
|
||||||
|
selector: (_, clashConfig) => ClashConfigState(
|
||||||
|
mixedPort: clashConfig.mixedPort,
|
||||||
|
allowLan: clashConfig.allowLan,
|
||||||
|
ipv6: clashConfig.ipv6,
|
||||||
|
logLevel: clashConfig.logLevel,
|
||||||
|
geodataLoader: clashConfig.geodataLoader,
|
||||||
|
externalController: clashConfig.externalController,
|
||||||
|
mode: clashConfig.mode,
|
||||||
|
findProcessMode: clashConfig.findProcessMode,
|
||||||
|
keepAliveInterval: clashConfig.keepAliveInterval,
|
||||||
|
unifiedDelay: clashConfig.unifiedDelay,
|
||||||
|
tcpConcurrent: clashConfig.tcpConcurrent,
|
||||||
|
tun: clashConfig.tun,
|
||||||
|
dns: clashConfig.dns,
|
||||||
|
geoXUrl: clashConfig.geoXUrl,
|
||||||
|
rules: clashConfig.rules,
|
||||||
|
globalRealUa: clashConfig.globalRealUa,
|
||||||
|
),
|
||||||
|
builder: (__, state, child) {
|
||||||
|
if (updateClashConfigDebounce == null) {
|
||||||
|
updateClashConfigDebounce = debounce<Function()>(() async {
|
||||||
|
await globalState.appController.updateClashConfig();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
updateClashConfigDebounce!();
|
||||||
|
}
|
||||||
|
return child!;
|
||||||
|
},
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _updateCoreState(Widget child) {
|
Widget _updateCoreState(Widget child) {
|
||||||
return Selector2<Config, ClashConfig, CoreState>(
|
return Selector2<Config, ClashConfig, CoreState>(
|
||||||
selector: (_, config, clashConfig) => CoreState(
|
selector: (_, config, clashConfig) => CoreState(
|
||||||
accessControl: config.isAccessControl ? config.accessControl : null,
|
accessControl: config.isAccessControl ? config.accessControl : null,
|
||||||
allowBypass: config.allowBypass,
|
enable: config.vpnProps.enable,
|
||||||
systemProxy: config.systemProxy,
|
allowBypass: config.vpnProps.allowBypass,
|
||||||
|
systemProxy: config.vpnProps.systemProxy,
|
||||||
mixedPort: clashConfig.mixedPort,
|
mixedPort: clashConfig.mixedPort,
|
||||||
onlyProxy: config.onlyProxy,
|
onlyProxy: config.onlyProxy,
|
||||||
currentProfileName:
|
currentProfileName:
|
||||||
@@ -61,7 +99,9 @@ class _ClashContainerState extends State<ClashContainer>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return _changeProfileContainer(
|
return _changeProfileContainer(
|
||||||
_updateCoreState(
|
_updateCoreState(
|
||||||
widget.child,
|
_updateContainer(
|
||||||
|
widget.child,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -89,6 +129,7 @@ class _ClashContainerState extends State<ClashContainer>
|
|||||||
@override
|
@override
|
||||||
void onLog(Log log) {
|
void onLog(Log log) {
|
||||||
globalState.appController.appState.addLog(log);
|
globalState.appController.appState.addLog(log);
|
||||||
|
debugPrint("$log");
|
||||||
super.onLog(log);
|
super.onLog(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,9 +154,7 @@ class _ClashContainerState extends State<ClashContainer>
|
|||||||
@override
|
@override
|
||||||
Future<void> onStarted(String runTime) async {
|
Future<void> onStarted(String runTime) async {
|
||||||
super.onStarted(runTime);
|
super.onStarted(runTime);
|
||||||
proxy?.updateStartTime();
|
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
await appController.applyProfile(isPrue: true);
|
await appController.applyProfile(isPrue: true);
|
||||||
appController.addCheckIpNumDebounce();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
37
lib/widgets/proxy_container.dart
Normal file
37
lib/widgets/proxy_container.dart
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import 'package:fl_clash/common/proxy.dart';
|
||||||
|
import 'package:fl_clash/models/models.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ProxyContainer extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const ProxyContainer({super.key, required this.child});
|
||||||
|
|
||||||
|
_updateProxy(ProxyState proxyState) {
|
||||||
|
final isStart = proxyState.isStart;
|
||||||
|
final systemProxy = proxyState.systemProxy;
|
||||||
|
final port = proxyState.port;
|
||||||
|
if (isStart && systemProxy) {
|
||||||
|
proxy?.startProxy(port);
|
||||||
|
}else{
|
||||||
|
proxy?.stopProxy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector3<AppState, Config, ClashConfig, ProxyState>(
|
||||||
|
selector: (_, appState, config, clashConfig) => ProxyState(
|
||||||
|
isStart: appState.isStart,
|
||||||
|
systemProxy: config.desktopProps.systemProxy,
|
||||||
|
port: clashConfig.mixedPort,
|
||||||
|
),
|
||||||
|
builder: (_, state, child) {
|
||||||
|
_updateProxy(state);
|
||||||
|
return child!;
|
||||||
|
},
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -109,7 +109,7 @@ class CommonScaffoldState extends State<CommonScaffold> {
|
|||||||
valueListenable: _actions,
|
valueListenable: _actions,
|
||||||
builder: (_, actions, __) {
|
builder: (_, actions, __) {
|
||||||
final realActions =
|
final realActions =
|
||||||
actions.isNotEmpty ? actions : widget.actions;
|
actions.isNotEmpty ? actions : widget.actions;
|
||||||
return AppBar(
|
return AppBar(
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
automaticallyImplyLeading: widget.automaticallyImplyLeading,
|
automaticallyImplyLeading: widget.automaticallyImplyLeading,
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ class _TileContainerState extends State<TileContainer> with TileListener {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onStart() {
|
void onStart() {
|
||||||
globalState.appController.updateSystemProxy(true);
|
globalState.appController.updateStatus(true);
|
||||||
super.onStart();
|
super.onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onStop() {
|
void onStop() {
|
||||||
globalState.appController.updateSystemProxy(false);
|
globalState.appController.updateStatus(false);
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ class _TrayContainerState extends State<TrayContainer> with TrayListener {
|
|||||||
|
|
||||||
_updateOtherTray() async {
|
_updateOtherTray() async {
|
||||||
if (isTrayInit == false) {
|
if (isTrayInit == false) {
|
||||||
await trayManager.setIcon(
|
|
||||||
other.getTrayIconPath(),
|
|
||||||
);
|
|
||||||
await trayManager.setToolTip(
|
await trayManager.setToolTip(
|
||||||
appName,
|
appName,
|
||||||
);
|
);
|
||||||
|
await trayManager.setIcon(
|
||||||
|
other.getTrayIconPath(),
|
||||||
|
);
|
||||||
isTrayInit = true;
|
isTrayInit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ class _TrayContainerState extends State<TrayContainer> with TrayListener {
|
|||||||
final proxyMenuItem = MenuItem.checkbox(
|
final proxyMenuItem = MenuItem.checkbox(
|
||||||
label: appLocalizations.systemProxy,
|
label: appLocalizations.systemProxy,
|
||||||
onClick: (_) async {
|
onClick: (_) async {
|
||||||
globalState.appController.updateSystemProxy(!state.isRun);
|
globalState.appController.updateStatus(!state.isRun);
|
||||||
},
|
},
|
||||||
checked: state.isRun,
|
checked: state.isRun,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ class _WindowContainerState extends State<WindowContainer> with WindowListener {
|
|||||||
_autoLaunchContainer(Widget child) {
|
_autoLaunchContainer(Widget child) {
|
||||||
return Selector<Config, bool>(
|
return Selector<Config, bool>(
|
||||||
selector: (_, config) => config.autoLaunch,
|
selector: (_, config) => config.autoLaunch,
|
||||||
builder: (_, isAutoLaunch, child) {
|
builder: (_, state, child) {
|
||||||
autoLaunch?.updateStatus(isAutoLaunch);
|
autoLaunch?.updateStatus(state);
|
||||||
return child!;
|
return child!;
|
||||||
},
|
},
|
||||||
child: child,
|
child: child,
|
||||||
@@ -33,22 +33,7 @@ class _WindowContainerState extends State<WindowContainer> with WindowListener {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Stack(
|
return _autoLaunchContainer(widget.child);
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: kHeaderHeight,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 1,
|
|
||||||
child: _autoLaunchContainer(widget.child),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const WindowHeader(),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -98,6 +83,35 @@ class _WindowContainerState extends State<WindowContainer> with WindowListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class WindowHeaderContainer extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const WindowHeaderContainer({
|
||||||
|
super.key,
|
||||||
|
required this.child,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: kHeaderHeight,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const WindowHeader(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class WindowHeader extends StatefulWidget {
|
class WindowHeader extends StatefulWidget {
|
||||||
const WindowHeader({super.key});
|
const WindowHeader({super.key});
|
||||||
|
|
||||||
@@ -188,7 +202,7 @@ class _WindowHeaderState extends State<WindowHeader> {
|
|||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
windowManager.close();
|
globalState.appController.handleBackOrExit();
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.close),
|
icon: const Icon(Icons.close),
|
||||||
),
|
),
|
||||||
@@ -214,7 +228,7 @@ class _WindowHeaderState extends State<WindowHeader> {
|
|||||||
_updateMaximized();
|
_updateMaximized();
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
color: context.colorScheme.surface,
|
color: context.colorScheme.secondary.toSoft(),
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
height: kHeaderHeight,
|
height: kHeaderHeight,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -10,50 +10,22 @@ class Proxy extends ProxyPlatform {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool?> startProxy(int port) async {
|
Future<bool?> startProxy(int port) async {
|
||||||
bool? isStart = false;
|
return switch (Platform.operatingSystem) {
|
||||||
switch (Platform.operatingSystem) {
|
"macos" => await _startProxyWithMacos(port),
|
||||||
case "macos":
|
"linux" => await _startProxyWithLinux(port),
|
||||||
isStart = await _startProxyWithMacos(port);
|
"windows" => await ProxyPlatform.instance.startProxy(port),
|
||||||
break;
|
String() => false,
|
||||||
case "linux":
|
};
|
||||||
isStart = await _startProxyWithLinux(port);
|
|
||||||
break;
|
|
||||||
case "windows":
|
|
||||||
isStart = await ProxyPlatform.instance.startProxy(port);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (isStart == true) {
|
|
||||||
startTime = DateTime.now();
|
|
||||||
}
|
|
||||||
return isStart;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool?> stopProxy() async {
|
Future<bool?> stopProxy() async {
|
||||||
bool? isStop = false;
|
return switch (Platform.operatingSystem) {
|
||||||
switch (Platform.operatingSystem) {
|
"macos" => await _stopProxyWithMacos(),
|
||||||
case "macos":
|
"linux" => await _stopProxyWithLinux(),
|
||||||
isStop = await _stopProxyWithMacos();
|
"windows" => await ProxyPlatform.instance.stopProxy(),
|
||||||
break;
|
String() => false,
|
||||||
case "linux":
|
};
|
||||||
isStop = await _stopProxyWithLinux();
|
|
||||||
break;
|
|
||||||
case "windows":
|
|
||||||
isStop = await ProxyPlatform.instance.stopProxy();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (isStop == true) {
|
|
||||||
startTime = null;
|
|
||||||
}
|
|
||||||
return isStop;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
get startTime => ProxyPlatform.instance.startTime;
|
|
||||||
|
|
||||||
@override
|
|
||||||
set startTime(DateTime? dateTime) {
|
|
||||||
ProxyPlatform.instance.startTime = dateTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _startProxyWithLinux(int port) async {
|
Future<bool> _startProxyWithLinux(int port) async {
|
||||||
@@ -205,4 +177,3 @@ class Proxy extends ProxyPlatform {
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ class MethodChannelProxy extends ProxyPlatform {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool?> stopProxy() async {
|
Future<bool?> stopProxy() async {
|
||||||
final isStop = await methodChannel.invokeMethod<bool>("StopProxy");
|
return await methodChannel.invokeMethod<bool>("StopProxy");
|
||||||
if (isStop == true) {
|
|
||||||
startTime = null;
|
|
||||||
}
|
|
||||||
return isStop;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ abstract class ProxyPlatform extends PlatformInterface {
|
|||||||
_instance = instance;
|
_instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime? startTime;
|
|
||||||
|
|
||||||
Future<bool?> startProxy(int port) {
|
Future<bool?> startProxy(int port) {
|
||||||
throw UnimplementedError('startProxy() has not been implemented.');
|
throw UnimplementedError('startProxy() has not been implemented.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
name: fl_clash
|
name: fl_clash
|
||||||
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
|
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 0.8.53+202408151
|
version: 0.8.54+202408221
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.1.0 <4.0.0'
|
sdk: '>=3.1.0 <4.0.0'
|
||||||
|
flutter: 3.22.3
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ add_executable(${BINARY_NAME} WIN32
|
|||||||
"runner.exe.manifest"
|
"runner.exe.manifest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SET_TARGET_PROPERTIES(${BINARY_NAME} PROPERTIES LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS")
|
||||||
|
|
||||||
# add_executable(service
|
# add_executable(service
|
||||||
# "service.cpp"
|
# "service.cpp"
|
||||||
# )
|
# )
|
||||||
|
|||||||
Reference in New Issue
Block a user