Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79efa67df3 | ||
|
|
ac397393a0 | ||
|
|
b685165230 | ||
|
|
402221aaa2 | ||
|
|
f6d9ed11d9 | ||
|
|
c38a671d57 | ||
|
|
75af47aead | ||
|
|
8dafe3b0ec |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -87,7 +87,7 @@ jobs:
|
|||||||
- name: Setup Flutter
|
- name: Setup Flutter
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: '3.x'
|
flutter-version: 3.22.x
|
||||||
channel: 'stable'
|
channel: 'stable'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
assets/fonts/Icons.ttf
Normal file
BIN
assets/fonts/Icons.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/Twemoji.Mozilla.ttf
Normal file
BIN
assets/fonts/Twemoji.Mozilla.ttf
Normal file
Binary file not shown.
Submodule core/Clash.Meta updated: 44d4b6dab2...8d1f6620f7
146
core/common.go
146
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"
|
||||||
@@ -11,6 +21,7 @@ import (
|
|||||||
"github.com/metacubex/mihomo/common/batch"
|
"github.com/metacubex/mihomo/common/batch"
|
||||||
"github.com/metacubex/mihomo/component/dialer"
|
"github.com/metacubex/mihomo/component/dialer"
|
||||||
"github.com/metacubex/mihomo/component/resolver"
|
"github.com/metacubex/mihomo/component/resolver"
|
||||||
|
"github.com/metacubex/mihomo/component/sniffer"
|
||||||
"github.com/metacubex/mihomo/config"
|
"github.com/metacubex/mihomo/config"
|
||||||
"github.com/metacubex/mihomo/constant"
|
"github.com/metacubex/mihomo/constant"
|
||||||
cp "github.com/metacubex/mihomo/constant/provider"
|
cp "github.com/metacubex/mihomo/constant/provider"
|
||||||
@@ -21,56 +32,14 @@ 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"`
|
||||||
SelectedMap map[string]string `json:"selected-map"`
|
SelectedMap map[string]string `json:"selected-map"`
|
||||||
TestURL *string `json:"test-url"`
|
TestURL *string `json:"test-url"`
|
||||||
|
OverrideDns bool `json:"override-dns"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GenerateConfigParams struct {
|
type GenerateConfigParams struct {
|
||||||
@@ -412,6 +381,12 @@ func generateProxyGroupAndRule(proxyGroup *[]map[string]any, rule *[]string) {
|
|||||||
*rule = computedRule
|
*rule = computedRule
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func genHosts(hosts, patchHosts map[string]any) {
|
||||||
|
for k, v := range patchHosts {
|
||||||
|
hosts[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfig) {
|
func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfig) {
|
||||||
targetConfig.ExternalController = patchConfig.ExternalController
|
targetConfig.ExternalController = patchConfig.ExternalController
|
||||||
targetConfig.ExternalUI = ""
|
targetConfig.ExternalUI = ""
|
||||||
@@ -419,7 +394,6 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
|
|||||||
targetConfig.ExternalUIURL = ""
|
targetConfig.ExternalUIURL = ""
|
||||||
targetConfig.TCPConcurrent = patchConfig.TCPConcurrent
|
targetConfig.TCPConcurrent = patchConfig.TCPConcurrent
|
||||||
targetConfig.UnifiedDelay = patchConfig.UnifiedDelay
|
targetConfig.UnifiedDelay = patchConfig.UnifiedDelay
|
||||||
//targetConfig.GeodataMode = false
|
|
||||||
targetConfig.IPv6 = patchConfig.IPv6
|
targetConfig.IPv6 = patchConfig.IPv6
|
||||||
targetConfig.LogLevel = patchConfig.LogLevel
|
targetConfig.LogLevel = patchConfig.LogLevel
|
||||||
targetConfig.Port = 0
|
targetConfig.Port = 0
|
||||||
@@ -437,7 +411,11 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
|
|||||||
targetConfig.Profile.StoreSelected = false
|
targetConfig.Profile.StoreSelected = false
|
||||||
targetConfig.GeoXUrl = patchConfig.GeoXUrl
|
targetConfig.GeoXUrl = patchConfig.GeoXUrl
|
||||||
targetConfig.GlobalUA = patchConfig.GlobalUA
|
targetConfig.GlobalUA = patchConfig.GlobalUA
|
||||||
if targetConfig.DNS.Enable == false {
|
//if targetConfig.DNS.Enable == false {
|
||||||
|
// targetConfig.DNS = patchConfig.DNS
|
||||||
|
//}
|
||||||
|
genHosts(targetConfig.Hosts, patchConfig.Hosts)
|
||||||
|
if configParams.OverrideDns {
|
||||||
targetConfig.DNS = patchConfig.DNS
|
targetConfig.DNS = patchConfig.DNS
|
||||||
}
|
}
|
||||||
//if runtime.GOOS == "android" {
|
//if runtime.GOOS == "android" {
|
||||||
@@ -445,40 +423,80 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
|
|||||||
//} else if runtime.GOOS == "windows" {
|
//} else if runtime.GOOS == "windows" {
|
||||||
// targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, dns.SystemDNSPlaceholder)
|
// targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, dns.SystemDNSPlaceholder)
|
||||||
//}
|
//}
|
||||||
if configParams.IsCompatible == false {
|
//if configParams.IsCompatible == false {
|
||||||
targetConfig.ProxyProvider = make(map[string]map[string]any)
|
// targetConfig.ProxyProvider = make(map[string]map[string]any)
|
||||||
targetConfig.RuleProvider = make(map[string]map[string]any)
|
// targetConfig.RuleProvider = make(map[string]map[string]any)
|
||||||
generateProxyGroupAndRule(&targetConfig.ProxyGroup, &targetConfig.Rule)
|
// generateProxyGroupAndRule(&targetConfig.ProxyGroup, &targetConfig.Rule)
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
if sniffer.Dispatcher != nil {
|
||||||
|
tunnel.SetSniffing(general.Sniffing)
|
||||||
|
}
|
||||||
|
tunnel.SetFindProcessMode(general.FindProcessMode)
|
||||||
|
dialer.SetTcpConcurrent(general.TCPConcurrent)
|
||||||
|
dialer.DefaultInterface.Store(general.Interface)
|
||||||
|
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) {
|
||||||
|
if !isRunning {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
runLock.Lock()
|
||||||
|
defer runLock.Unlock()
|
||||||
|
listener.PatchInboundListeners(listeners, tunnel.Tunnel, true)
|
||||||
listener.SetAllowLan(general.AllowLan)
|
listener.SetAllowLan(general.AllowLan)
|
||||||
inbound.SetSkipAuthPrefixes(general.SkipAuthPrefixes)
|
inbound.SetSkipAuthPrefixes(general.SkipAuthPrefixes)
|
||||||
inbound.SetAllowedIPs(general.LanAllowedIPs)
|
inbound.SetAllowedIPs(general.LanAllowedIPs)
|
||||||
inbound.SetDisAllowedIPs(general.LanDisAllowedIPs)
|
inbound.SetDisAllowedIPs(general.LanDisAllowedIPs)
|
||||||
listener.SetBindAddress(general.BindAddress)
|
listener.SetBindAddress(general.BindAddress)
|
||||||
tunnel.SetSniffing(general.Sniffing)
|
|
||||||
tunnel.SetFindProcessMode(general.FindProcessMode)
|
|
||||||
dialer.SetTcpConcurrent(general.TCPConcurrent)
|
|
||||||
dialer.DefaultInterface.Store(general.Interface)
|
|
||||||
adapter.UnifiedDelay.Store(general.UnifiedDelay)
|
|
||||||
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 +524,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 +537,11 @@ func applyConfig() error {
|
|||||||
} else {
|
} else {
|
||||||
closeConnections()
|
closeConnections()
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
hub.UltraApplyConfig(cfg, true)
|
hub.UltraApplyConfig(cfg)
|
||||||
patchSelectGroup()
|
patchSelectGroup()
|
||||||
}
|
}
|
||||||
|
updateListeners(cfg.General, cfg.Listeners)
|
||||||
|
hcCompatibleProvider(cfg.Providers)
|
||||||
externalProviders = getExternalProvidersRaw()
|
externalProviders = getExternalProvidersRaw()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
40
core/hub.go
40
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,23 @@ 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()
|
||||||
|
go func() {
|
||||||
|
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 +78,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 +107,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 +124,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())
|
||||||
@@ -215,6 +238,7 @@ func asyncTestDelay(s *C.char, port C.longlong) {
|
|||||||
|
|
||||||
proxies := tunnel.ProxiesWithProviders()
|
proxies := tunnel.ProxiesWithProviders()
|
||||||
proxy := proxies[params.ProxyName]
|
proxy := proxies[params.ProxyName]
|
||||||
|
proxy.Name()
|
||||||
|
|
||||||
delayData := &Delay{
|
delayData := &Delay{
|
||||||
Name: params.ProxyName,
|
Name: params.ProxyName,
|
||||||
|
|||||||
@@ -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"`
|
||||||
|
|||||||
26
core/tun.go
26
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()
|
||||||
@@ -125,7 +139,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 +173,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeSocketHook() {
|
||||||
|
dialer.DefaultSocketHook = nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ func Start(fd int, gateway, portal, dns string) (io.Closer, error) {
|
|||||||
for stack.TCP().SetDeadline(time.Time{}) == nil {
|
for stack.TCP().SetDeadline(time.Time{}) == nil {
|
||||||
conn, err := stack.TCP().Accept()
|
conn, err := stack.TCP().Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("Accept connection: %v", err)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
lAddr := conn.LocalAddr().(*net.TCPAddr)
|
lAddr := conn.LocalAddr().(*net.TCPAddr)
|
||||||
|
|||||||
@@ -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,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -106,6 +109,17 @@ class ApplicationState extends State<Application> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_buildPage(Widget page) {
|
||||||
|
if (system.isDesktop) {
|
||||||
|
return WindowHeaderContainer(
|
||||||
|
child: page,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return VpnContainer(
|
||||||
|
child: page,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
_updateSystemColorSchemes(
|
_updateSystemColorSchemes(
|
||||||
ColorScheme? lightDynamic,
|
ColorScheme? lightDynamic,
|
||||||
ColorScheme? darkDynamic,
|
ColorScheme? darkDynamic,
|
||||||
@@ -121,60 +135,62 @@ 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);
|
||||||
debugShowCheckedModeBanner: false,
|
return MaterialApp(
|
||||||
navigatorKey: globalState.navigatorKey,
|
navigatorKey: globalState.navigatorKey,
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: const [
|
||||||
AppLocalizations.delegate,
|
AppLocalizations.delegate,
|
||||||
GlobalMaterialLocalizations.delegate,
|
GlobalMaterialLocalizations.delegate,
|
||||||
GlobalCupertinoLocalizations.delegate,
|
GlobalCupertinoLocalizations.delegate,
|
||||||
GlobalWidgetsLocalizations.delegate
|
GlobalWidgetsLocalizations.delegate
|
||||||
],
|
],
|
||||||
builder: (_, child) {
|
builder: (_, child) {
|
||||||
return _buildApp(child!);
|
return _buildPage(child!);
|
||||||
},
|
},
|
||||||
scrollBehavior: BaseScrollBehavior(),
|
scrollBehavior: BaseScrollBehavior(),
|
||||||
title: appName,
|
title: appName,
|
||||||
locale: other.getLocaleForString(state.locale),
|
locale: other.getLocaleForString(state.locale),
|
||||||
supportedLocales: AppLocalizations.delegate.supportedLocales,
|
supportedLocales:
|
||||||
themeMode: state.themeMode,
|
AppLocalizations.delegate.supportedLocales,
|
||||||
theme: ThemeData(
|
themeMode: state.themeMode,
|
||||||
useMaterial3: true,
|
theme: ThemeData(
|
||||||
pageTransitionsTheme: _pageTransitionsTheme,
|
useMaterial3: true,
|
||||||
colorScheme: _getAppColorScheme(
|
pageTransitionsTheme: _pageTransitionsTheme,
|
||||||
brightness: Brightness.light,
|
colorScheme: _getAppColorScheme(
|
||||||
systemColorSchemes: systemColorSchemes,
|
brightness: Brightness.light,
|
||||||
primaryColor: state.primaryColor,
|
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,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ extension ColorSchemeExtension on ColorScheme {
|
|||||||
ColorScheme toPrueBlack(bool isPrueBlack) => isPrueBlack
|
ColorScheme toPrueBlack(bool isPrueBlack) => isPrueBlack
|
||||||
? copyWith(
|
? copyWith(
|
||||||
surface: Colors.black,
|
surface: Colors.black,
|
||||||
|
background: Colors.black,
|
||||||
surfaceContainer: surfaceContainer.darken(0.05),
|
surfaceContainer: surfaceContainer.darken(0.05),
|
||||||
)
|
)
|
||||||
: this;
|
: this;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ 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';
|
||||||
|
export 'icons.dart';
|
||||||
|
export 'http.dart';
|
||||||
@@ -47,6 +47,7 @@ class DAVClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<List<int>> recovery() async {
|
Future<List<int>> recovery() async {
|
||||||
|
await client.mkdir("$root");
|
||||||
final data = await client.read(backupFile);
|
final data = await client.read(backupFile);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
19
lib/common/http.dart
Normal file
19
lib/common/http.dart
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import '../state.dart';
|
||||||
|
|
||||||
|
class FlClashHttpOverrides extends HttpOverrides {
|
||||||
|
|
||||||
|
@override
|
||||||
|
HttpClient createHttpClient(SecurityContext? context) {
|
||||||
|
final client = super.createHttpClient(context);
|
||||||
|
client.badCertificateCallback = (_, __, ___) => true;
|
||||||
|
client.findProxy = (url) {
|
||||||
|
final port = globalState.appController.clashConfig.mixedPort;
|
||||||
|
final isStart = globalState.appController.appState.isStart;
|
||||||
|
if(!isStart) return "DIRECT";
|
||||||
|
return "PROXY localhost:$port;DIRECT";
|
||||||
|
};
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
}
|
||||||
6
lib/common/icons.dart
Normal file
6
lib/common/icons.dart
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class IconsExt{
|
||||||
|
static const IconData target =
|
||||||
|
IconData(0xe900, fontFamily: "Icons");
|
||||||
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'package:fl_clash/models/models.dart' hide Process;
|
||||||
import 'package:launch_at_startup/launch_at_startup.dart';
|
import 'package:launch_at_startup/launch_at_startup.dart';
|
||||||
|
|
||||||
import 'constant.dart';
|
import 'constant.dart';
|
||||||
import 'system.dart';
|
import 'system.dart';
|
||||||
|
import 'windows.dart';
|
||||||
|
|
||||||
class AutoLaunch {
|
class AutoLaunch {
|
||||||
static AutoLaunch? _instance;
|
static AutoLaunch? _instance;
|
||||||
@@ -24,18 +26,77 @@ 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 {
|
||||||
|
if (Platform.isWindows) {
|
||||||
|
await windowsDisable();
|
||||||
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> windowsEnable() async {
|
||||||
|
await disable();
|
||||||
|
return windows?.runas(
|
||||||
|
'schtasks',
|
||||||
|
[
|
||||||
|
'/Create',
|
||||||
|
'/SC',
|
||||||
|
'ONLOGON',
|
||||||
|
'/TN',
|
||||||
|
appName,
|
||||||
|
'/TR',
|
||||||
|
'"${Platform.resolvedExecutable}"',
|
||||||
|
'/RL',
|
||||||
|
'HIGHEST',
|
||||||
|
'/F'
|
||||||
|
].join(" "),
|
||||||
|
) ??
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> disable() async {
|
Future<bool> disable() async {
|
||||||
return await launchAtStartup.disable();
|
return await launchAtStartup.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStatus(bool value) async {
|
updateStatus(AutoLaunchState state) async {
|
||||||
final isEnable = await this.isEnable;
|
final isOpenTun = state.isOpenTun;
|
||||||
if (isEnable == value) return;
|
final isAutoLaunch = state.isAutoLaunch;
|
||||||
if (value == true) {
|
if (Platform.isWindows && isOpenTun) {
|
||||||
|
if (await windowsIsEnable == isAutoLaunch) return;
|
||||||
|
if (isAutoLaunch) {
|
||||||
|
final isEnable = await windowsEnable();
|
||||||
|
if (!isEnable) {
|
||||||
|
enable();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
windowsDisable();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (await isEnable == isAutoLaunch) return;
|
||||||
|
if (isAutoLaunch == true) {
|
||||||
enable();
|
enable();
|
||||||
} else {
|
} else {
|
||||||
disable();
|
disable();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
|
import 'dart:math';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
@@ -130,6 +131,12 @@ class Other {
|
|||||||
return build1.compareTo(build2);
|
return build1.compareTo(build2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getPinyin(String value) {
|
||||||
|
return value.isNotEmpty
|
||||||
|
? PinyinHelper.getFirstWordPinyin(value.substring(0, 1))
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
|
||||||
Future<String?> parseQRCode(Uint8List? bytes) {
|
Future<String?> parseQRCode(Uint8List? bytes) {
|
||||||
return Isolate.run<String?>(() {
|
return Isolate.run<String?>(() {
|
||||||
if (bytes == null) return null;
|
if (bytes == null) return null;
|
||||||
@@ -191,22 +198,17 @@ class Other {
|
|||||||
return ViewMode.desktop;
|
return ViewMode.desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getColumns(ViewMode viewMode, int currentColumns) {
|
int getProxiesColumns(double viewWidth, ProxiesLayout proxiesLayout) {
|
||||||
final targetColumnsArray = viewModeColumnsMap[viewMode]!;
|
final columns = max((viewWidth / 300).ceil(), 2);
|
||||||
if (targetColumnsArray.contains(currentColumns)) {
|
return switch (proxiesLayout) {
|
||||||
return currentColumns;
|
ProxiesLayout.tight => columns - 1,
|
||||||
}
|
ProxiesLayout.standard => columns,
|
||||||
return targetColumnsArray.first;
|
ProxiesLayout.loose => columns + 1,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
String getColumnsTextForInt(int number) {
|
int getProfilesColumns(double viewWidth) {
|
||||||
return switch (number) {
|
return max((viewWidth / 400).floor(), 1);
|
||||||
1 => appLocalizations.oneColumn,
|
|
||||||
2 => appLocalizations.twoColumns,
|
|
||||||
3 => appLocalizations.threeColumns,
|
|
||||||
4 => appLocalizations.fourColumns,
|
|
||||||
int() => throw UnimplementedError(),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String getBackupFileName() {
|
String getBackupFileName() {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
@@ -14,12 +15,16 @@ class Picker {
|
|||||||
return filePickerResult?.files.first;
|
return filePickerResult?.files.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> saveFile(String fileName,Uint8List bytes) async {
|
Future<String?> saveFile(String fileName, Uint8List bytes) async {
|
||||||
final path = await FilePicker.platform.saveFile(
|
final path = await FilePicker.platform.saveFile(
|
||||||
fileName: fileName,
|
fileName: fileName,
|
||||||
initialDirectory: await appPath.getDownloadDirPath(),
|
initialDirectory: await appPath.getDownloadDirPath(),
|
||||||
bytes: bytes,
|
bytes: Platform.isAndroid ? bytes : null,
|
||||||
);
|
);
|
||||||
|
if (!Platform.isAndroid && path != null) {
|
||||||
|
final file = await File(path).create(recursive: true);
|
||||||
|
await file.writeAsBytes(bytes);
|
||||||
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
|
||||||
|
|||||||
@@ -1,55 +1,35 @@
|
|||||||
import 'dart:io';
|
import 'dart:math';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:dio/io.dart';
|
|
||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/models/ip.dart';
|
import 'package:fl_clash/models/ip.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
class Request {
|
class Request {
|
||||||
late final Dio _dio;
|
late final Dio _dio;
|
||||||
int? _port;
|
String? userAgent;
|
||||||
bool _isStart = false;
|
|
||||||
|
|
||||||
Request() {
|
Request() {
|
||||||
_dio = Dio();
|
_dio = Dio();
|
||||||
_dio.interceptors.add(
|
_dio.interceptors.add(
|
||||||
InterceptorsWrapper(
|
InterceptorsWrapper(
|
||||||
onRequest: (options, handler) {
|
onRequest: (options, handler) {
|
||||||
_updateAdapter();
|
|
||||||
return handler.next(options); // 继续请求
|
return handler.next(options); // 继续请求
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateAdapter() {
|
|
||||||
final port = globalState.appController.clashConfig.mixedPort;
|
|
||||||
final isStart = globalState.appController.appState.isStart;
|
|
||||||
if (_port != port || isStart != _isStart) {
|
|
||||||
_port = port;
|
|
||||||
_isStart = isStart;
|
|
||||||
_dio.httpClientAdapter = IOHttpClientAdapter(
|
|
||||||
createHttpClient: () {
|
|
||||||
final client = HttpClient();
|
|
||||||
if (!_isStart) return client;
|
|
||||||
client.userAgent = globalState.appController.clashConfig.globalUa;
|
|
||||||
client.findProxy = (url) {
|
|
||||||
return "PROXY localhost:$_port;DIRECT";
|
|
||||||
};
|
|
||||||
return client;
|
|
||||||
},
|
|
||||||
validateCertificate: (_, __, ___) => true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Response> getFileResponseForUrl(String url) async {
|
Future<Response> getFileResponseForUrl(String url) async {
|
||||||
final response = await _dio
|
final response = await _dio
|
||||||
.get(
|
.get(
|
||||||
url,
|
url,
|
||||||
options: Options(
|
options: Options(
|
||||||
headers: {"User-Agent": globalState.appController.clashConfig.globalUa},
|
headers: {
|
||||||
|
"User-Agent": globalState.appController.clashConfig.globalUa
|
||||||
|
},
|
||||||
responseType: ResponseType.bytes,
|
responseType: ResponseType.bytes,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -59,6 +39,19 @@ class Request {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<MemoryImage?> getImage(String url) async {
|
||||||
|
if (url.isEmpty) return null;
|
||||||
|
final response = await _dio.get<Uint8List>(
|
||||||
|
url,
|
||||||
|
options: Options(
|
||||||
|
responseType: ResponseType.bytes,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final data = response.data;
|
||||||
|
if (data == null) return null;
|
||||||
|
return MemoryImage(data);
|
||||||
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>?> checkForUpdate() async {
|
Future<Map<String, dynamic>?> checkForUpdate() async {
|
||||||
final response = await _dio.get(
|
final response = await _dio.get(
|
||||||
"https://api.github.com/repos/$repository/releases/latest",
|
"https://api.github.com/repos/$repository/releases/latest",
|
||||||
@@ -84,10 +77,13 @@ class Request {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Future<IpInfo?> checkIp({CancelToken? cancelToken}) async {
|
Future<IpInfo?> checkIp({CancelToken? cancelToken}) async {
|
||||||
for (final source in _ipInfoSources.entries) {
|
for (final source in _ipInfoSources.entries.toList()..shuffle(Random())) {
|
||||||
try {
|
try {
|
||||||
final response = await _dio
|
final response = await _dio
|
||||||
.get<Map<String, dynamic>>(source.key, cancelToken: cancelToken)
|
.get<Map<String, dynamic>>(
|
||||||
|
source.key,
|
||||||
|
cancelToken: cancelToken,
|
||||||
|
)
|
||||||
.timeout(
|
.timeout(
|
||||||
httpTimeoutDuration,
|
httpTimeoutDuration,
|
||||||
);
|
);
|
||||||
@@ -95,6 +91,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;
|
|
||||||
@@ -18,6 +18,12 @@ class System {
|
|||||||
bool get isDesktop =>
|
bool get isDesktop =>
|
||||||
Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
||||||
|
|
||||||
|
get isAdmin async {
|
||||||
|
if (!Platform.isWindows) return false;
|
||||||
|
final result = await Process.run('net', ['session'], runInShell: true);
|
||||||
|
return result.exitCode == 0;
|
||||||
|
}
|
||||||
|
|
||||||
back() async {
|
back() async {
|
||||||
await app?.moveTaskToBack();
|
await app?.moveTaskToBack();
|
||||||
await window?.hide();
|
await window?.hide();
|
||||||
|
|||||||
59
lib/common/windows.dart
Normal file
59
lib/common/windows.dart
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
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!;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool runas(String command, String arguments) {
|
||||||
|
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) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final windows = Platform.isWindows ? Windows() : null;
|
||||||
@@ -26,6 +26,7 @@ class AppController {
|
|||||||
late Function updateClashConfigDebounce;
|
late Function updateClashConfigDebounce;
|
||||||
late Function updateGroupDebounce;
|
late Function updateGroupDebounce;
|
||||||
late Function addCheckIpNumDebounce;
|
late Function addCheckIpNumDebounce;
|
||||||
|
late Function applyProfileDebounce;
|
||||||
|
|
||||||
AppController(this.context) {
|
AppController(this.context) {
|
||||||
appState = context.read<AppState>();
|
appState = context.read<AppState>();
|
||||||
@@ -34,6 +35,9 @@ class AppController {
|
|||||||
updateClashConfigDebounce = debounce<Function()>(() async {
|
updateClashConfigDebounce = debounce<Function()>(() async {
|
||||||
await updateClashConfig();
|
await updateClashConfig();
|
||||||
});
|
});
|
||||||
|
applyProfileDebounce = debounce<Function()>(() async {
|
||||||
|
await applyProfile(isPrue: true);
|
||||||
|
});
|
||||||
addCheckIpNumDebounce = debounce(() {
|
addCheckIpNumDebounce = debounce(() {
|
||||||
appState.checkIpNum++;
|
appState.checkIpNum++;
|
||||||
});
|
});
|
||||||
@@ -43,10 +47,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,
|
||||||
);
|
);
|
||||||
@@ -56,10 +59,9 @@ class AppController {
|
|||||||
updateRunTime,
|
updateRunTime,
|
||||||
updateTraffic,
|
updateTraffic,
|
||||||
];
|
];
|
||||||
if (Platform.isAndroid) return;
|
applyProfileDebounce();
|
||||||
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();
|
||||||
@@ -73,8 +75,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 {
|
||||||
@@ -102,7 +105,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,6 +125,10 @@ class AppController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTray(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Future applyProfile({bool isPrue = false}) async {
|
Future applyProfile({bool isPrue = false}) async {
|
||||||
if (isPrue) {
|
if (isPrue) {
|
||||||
await globalState.applyProfile(
|
await globalState.applyProfile(
|
||||||
@@ -228,7 +235,8 @@ class AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleExit() async {
|
handleExit() async {
|
||||||
await updateSystemProxy(false);
|
await updateStatus(false);
|
||||||
|
await proxy?.stopProxy();
|
||||||
await savePreferences();
|
await savePreferences();
|
||||||
clashCore.shutdown();
|
clashCore.shutdown();
|
||||||
system.exit();
|
system.exit();
|
||||||
@@ -297,11 +305,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();
|
||||||
@@ -365,6 +375,10 @@ class AppController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showSnackBar(String message) {
|
||||||
|
globalState.showSnackBar(context, message: message);
|
||||||
|
}
|
||||||
|
|
||||||
addProfileFormURL(String url) async {
|
addProfileFormURL(String url) async {
|
||||||
if (globalState.navigatorKey.currentState?.canPop() ?? false) {
|
if (globalState.navigatorKey.currentState?.canPop() ?? false) {
|
||||||
globalState.navigatorKey.currentState?.popUntil((route) => route.isFirst);
|
globalState.navigatorKey.currentState?.popUntil((route) => route.isFirst);
|
||||||
@@ -414,8 +428,6 @@ class AppController {
|
|||||||
addProfileFormURL(url);
|
addProfileFormURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get columns => other.getColumns(appState.viewMode, config.proxiesColumns);
|
|
||||||
|
|
||||||
updateViewWidth(double width) {
|
updateViewWidth(double width) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
appState.viewWidth = width;
|
appState.viewWidth = width;
|
||||||
@@ -426,8 +438,8 @@ class AppController {
|
|||||||
return List.of(proxies)
|
return List.of(proxies)
|
||||||
..sort(
|
..sort(
|
||||||
(a, b) => other.sortByChar(
|
(a, b) => other.sortByChar(
|
||||||
PinyinHelper.getPinyin(a.name),
|
other.getPinyin(a.name),
|
||||||
PinyinHelper.getPinyin(b.name),
|
other.getPinyin(b.name),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
// ignore_for_file: constant_identifier_names
|
// ignore_for_file: constant_identifier_names
|
||||||
|
|
||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
enum GroupType { Selector, URLTest, Fallback, LoadBalance, Relay }
|
enum GroupType { Selector, URLTest, Fallback, LoadBalance, Relay }
|
||||||
|
|
||||||
enum GroupName { GLOBAL, Proxy, Auto, Fallback }
|
enum GroupName { GLOBAL, Proxy, Auto, Fallback }
|
||||||
@@ -86,4 +88,17 @@ enum CommonCardType { plain, filled }
|
|||||||
|
|
||||||
enum ProxiesType { tab, list }
|
enum ProxiesType { tab, list }
|
||||||
|
|
||||||
|
enum ProxiesLayout { loose, standard, tight }
|
||||||
|
|
||||||
enum ProxyCardType { expand, shrink, min }
|
enum ProxyCardType { expand, shrink, min }
|
||||||
|
|
||||||
|
|
||||||
|
enum DnsMode {
|
||||||
|
normal,
|
||||||
|
@JsonValue("fake-ip")
|
||||||
|
fakeIp,
|
||||||
|
@JsonValue("redir-host")
|
||||||
|
redirHost,
|
||||||
|
hosts
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -1,694 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:fl_clash/common/common.dart';
|
|
||||||
import 'package:fl_clash/enum/enum.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 ConfigFragment extends StatefulWidget {
|
|
||||||
const ConfigFragment({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ConfigFragment> createState() => _ConfigFragmentState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ConfigFragmentState extends State<ConfigFragment> {
|
|
||||||
_modifyMixedPort(num mixedPort) async {
|
|
||||||
final port = await globalState.showCommonDialog(
|
|
||||||
child: MixedPortFormDialog(
|
|
||||||
mixedPort: mixedPort,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (port != null && port != mixedPort && mounted) {
|
|
||||||
try {
|
|
||||||
final mixedPort = int.parse(port);
|
|
||||||
if (mixedPort < 1024 || mixedPort > 49151) throw "Invalid port";
|
|
||||||
globalState.appController.clashConfig.mixedPort = mixedPort;
|
|
||||||
globalState.appController.updateClashConfigDebounce();
|
|
||||||
} catch (e) {
|
|
||||||
globalState.showMessage(
|
|
||||||
title: appLocalizations.proxyPort,
|
|
||||||
message: TextSpan(
|
|
||||||
text: e.toString(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_showLogLevelDialog(LogLevel value) {
|
|
||||||
globalState.showCommonDialog(
|
|
||||||
child: AlertDialog(
|
|
||||||
title: Text(appLocalizations.logLevel),
|
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 8,
|
|
||||||
vertical: 16,
|
|
||||||
),
|
|
||||||
content: SizedBox(
|
|
||||||
width: 250,
|
|
||||||
child: Wrap(
|
|
||||||
children: [
|
|
||||||
for (final logLevel in LogLevel.values)
|
|
||||||
ListItem.radio(
|
|
||||||
delegate: RadioDelegate<LogLevel>(
|
|
||||||
value: logLevel,
|
|
||||||
groupValue: value,
|
|
||||||
onChanged: (LogLevel? value) {
|
|
||||||
if (value == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final appController = globalState.appController;
|
|
||||||
appController.clashConfig.logLevel = value;
|
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
title: Text(logLevel.name),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_showUaDialog(String? value) {
|
|
||||||
const uas = [
|
|
||||||
null,
|
|
||||||
"clash-verge/v1.6.6",
|
|
||||||
"ClashforWindows/0.19.23",
|
|
||||||
];
|
|
||||||
globalState.showCommonDialog(
|
|
||||||
child: AlertDialog(
|
|
||||||
title: const Text("UA"),
|
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 8,
|
|
||||||
vertical: 16,
|
|
||||||
),
|
|
||||||
content: SizedBox(
|
|
||||||
width: 250,
|
|
||||||
child: Wrap(
|
|
||||||
children: [
|
|
||||||
for (final ua in uas)
|
|
||||||
ListItem.radio(
|
|
||||||
delegate: RadioDelegate<String?>(
|
|
||||||
value: ua,
|
|
||||||
groupValue: value,
|
|
||||||
onChanged: (String? value) {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
appController.clashConfig.globalRealUa = value;
|
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
title: Text(ua ?? appLocalizations.defaultText),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_modifyTestUrl(String testUrl) async {
|
|
||||||
final newTestUrl = await globalState.showCommonDialog<String>(
|
|
||||||
child: TestUrlFormDialog(
|
|
||||||
testUrl: testUrl,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (newTestUrl != null && newTestUrl != testUrl && mounted) {
|
|
||||||
try {
|
|
||||||
if (!newTestUrl.isUrl) {
|
|
||||||
throw "Invalid url";
|
|
||||||
}
|
|
||||||
globalState.appController.config.testUrl = newTestUrl;
|
|
||||||
globalState.appController.updateClashConfigDebounce();
|
|
||||||
} catch (e) {
|
|
||||||
globalState.showMessage(
|
|
||||||
title: appLocalizations.testUrl,
|
|
||||||
message: TextSpan(
|
|
||||||
text: e.toString(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_updateKeepAliveInterval(int keepAliveInterval) async {
|
|
||||||
final newKeepAliveIntervalString =
|
|
||||||
await globalState.showCommonDialog<String>(
|
|
||||||
child: KeepAliveIntervalFormDialog(
|
|
||||||
keepAliveInterval: keepAliveInterval,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (newKeepAliveIntervalString != null &&
|
|
||||||
newKeepAliveIntervalString != "$keepAliveInterval" &&
|
|
||||||
mounted) {
|
|
||||||
try {
|
|
||||||
final newKeepAliveInterval = int.parse(newKeepAliveIntervalString);
|
|
||||||
if (newKeepAliveInterval <= 0) {
|
|
||||||
throw "Invalid keepAliveInterval";
|
|
||||||
}
|
|
||||||
globalState.appController.clashConfig.keepAliveInterval =
|
|
||||||
newKeepAliveInterval;
|
|
||||||
globalState.appController.updateClashConfigDebounce();
|
|
||||||
} catch (e) {
|
|
||||||
globalState.showMessage(
|
|
||||||
title: appLocalizations.testUrl,
|
|
||||||
message: TextSpan(
|
|
||||||
text: e.toString(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> _buildAppSection() {
|
|
||||||
return generateSection(
|
|
||||||
title: appLocalizations.app,
|
|
||||||
items: [
|
|
||||||
if (Platform.isAndroid) ...[
|
|
||||||
Selector<Config, bool>(
|
|
||||||
selector: (_, config) => config.allowBypass,
|
|
||||||
builder: (_, allowBypass, __) {
|
|
||||||
return ListItem.switchItem(
|
|
||||||
leading: const Icon(Icons.arrow_forward_outlined),
|
|
||||||
title: Text(appLocalizations.allowBypass),
|
|
||||||
subtitle: Text(appLocalizations.allowBypassDesc),
|
|
||||||
delegate: SwitchDelegate(
|
|
||||||
value: allowBypass,
|
|
||||||
onChanged: (bool value) async {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
appController.config.allowBypass = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<Config, bool>(
|
|
||||||
selector: (_, config) => config.systemProxy,
|
|
||||||
builder: (_, systemProxy, __) {
|
|
||||||
return ListItem.switchItem(
|
|
||||||
leading: const Icon(Icons.settings_ethernet),
|
|
||||||
title: Text(appLocalizations.systemProxy),
|
|
||||||
subtitle: Text(appLocalizations.systemProxyDesc),
|
|
||||||
delegate: SwitchDelegate(
|
|
||||||
value: systemProxy,
|
|
||||||
onChanged: (bool value) async {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
appController.config.systemProxy = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
Selector<Config, bool>(
|
|
||||||
selector: (_, config) => config.isCloseConnections,
|
|
||||||
builder: (_, isCloseConnections, __) {
|
|
||||||
return ListItem.switchItem(
|
|
||||||
leading: const Icon(Icons.auto_delete_outlined),
|
|
||||||
title: Text(appLocalizations.autoCloseConnections),
|
|
||||||
subtitle: Text(appLocalizations.autoCloseConnectionsDesc),
|
|
||||||
delegate: SwitchDelegate(
|
|
||||||
value: isCloseConnections,
|
|
||||||
onChanged: (bool value) async {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
appController.config.isCloseConnections = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<Config, bool>(
|
|
||||||
selector: (_, config) => config.onlyProxy,
|
|
||||||
builder: (_, onlyProxy, __) {
|
|
||||||
return ListItem.switchItem(
|
|
||||||
leading: const Icon(Icons.data_usage_outlined),
|
|
||||||
title: Text(appLocalizations.onlyStatisticsProxy),
|
|
||||||
subtitle: Text(appLocalizations.onlyStatisticsProxyDesc),
|
|
||||||
delegate: SwitchDelegate(
|
|
||||||
value: onlyProxy,
|
|
||||||
onChanged: (bool value) async {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
appController.config.onlyProxy = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
// Selector<Config, bool>(
|
|
||||||
// selector: (_, config) => config.isCompatible,
|
|
||||||
// builder: (_, isCompatible, __) {
|
|
||||||
// return ListItem.switchItem(
|
|
||||||
// leading: const Icon(Icons.expand_outlined),
|
|
||||||
// title: Text(appLocalizations.compatible),
|
|
||||||
// subtitle: Text(appLocalizations.compatibleDesc),
|
|
||||||
// delegate: SwitchDelegate(
|
|
||||||
// value: isCompatible,
|
|
||||||
// onChanged: (bool value) async {
|
|
||||||
// final appController = globalState.appController;
|
|
||||||
// appController.config.isCompatible = value;
|
|
||||||
// await appController.applyProfile();
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> _buildGeneralSection() {
|
|
||||||
return generateSection(
|
|
||||||
title: appLocalizations.general,
|
|
||||||
items: [
|
|
||||||
Selector<ClashConfig, LogLevel>(
|
|
||||||
selector: (_, clashConfig) => clashConfig.logLevel,
|
|
||||||
builder: (_, value, __) {
|
|
||||||
return ListItem(
|
|
||||||
leading: const Icon(Icons.info_outline),
|
|
||||||
title: Text(appLocalizations.logLevel),
|
|
||||||
subtitle: Text(value.name),
|
|
||||||
onTap: () {
|
|
||||||
_showLogLevelDialog(value);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<ClashConfig, String?>(
|
|
||||||
selector: (_, clashConfig) => clashConfig.globalRealUa,
|
|
||||||
builder: (_, value, __) {
|
|
||||||
return ListItem(
|
|
||||||
leading: const Icon(Icons.computer_outlined),
|
|
||||||
title: const Text("UA"),
|
|
||||||
subtitle: Text(value ?? appLocalizations.defaultText),
|
|
||||||
onTap: () {
|
|
||||||
_showUaDialog(value);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<ClashConfig, int>(
|
|
||||||
selector: (_, config) => config.keepAliveInterval,
|
|
||||||
builder: (_, value, __) {
|
|
||||||
return ListItem(
|
|
||||||
leading: const Icon(Icons.timer_outlined),
|
|
||||||
title: Text(appLocalizations.keepAliveIntervalDesc),
|
|
||||||
subtitle: Text("$value ${appLocalizations.seconds}"),
|
|
||||||
onTap: () {
|
|
||||||
_updateKeepAliveInterval(value);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<Config, String>(
|
|
||||||
selector: (_, config) => config.testUrl,
|
|
||||||
builder: (_, value, __) {
|
|
||||||
return ListItem(
|
|
||||||
leading: const Icon(Icons.timeline),
|
|
||||||
title: Text(appLocalizations.testUrl),
|
|
||||||
subtitle: Text(value),
|
|
||||||
onTap: () {
|
|
||||||
_modifyTestUrl(value);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<ClashConfig, int>(
|
|
||||||
selector: (_, clashConfig) => clashConfig.mixedPort,
|
|
||||||
builder: (_, mixedPort, __) {
|
|
||||||
return ListItem(
|
|
||||||
onTap: () {
|
|
||||||
_modifyMixedPort(mixedPort);
|
|
||||||
},
|
|
||||||
leading: const Icon(Icons.adjust_outlined),
|
|
||||||
title: Text(appLocalizations.proxyPort),
|
|
||||||
subtitle: Text(appLocalizations.proxyPortDesc),
|
|
||||||
trailing: FilledButton.tonal(
|
|
||||||
onPressed: () {
|
|
||||||
_modifyMixedPort(mixedPort);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
"$mixedPort",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<ClashConfig, bool>(
|
|
||||||
selector: (_, clashConfig) => clashConfig.ipv6,
|
|
||||||
builder: (_, ipv6, __) {
|
|
||||||
return ListItem.switchItem(
|
|
||||||
leading: const Icon(Icons.water_outlined),
|
|
||||||
title: const Text("IPv6"),
|
|
||||||
subtitle: Text(appLocalizations.ipv6Desc),
|
|
||||||
delegate: SwitchDelegate(
|
|
||||||
value: ipv6,
|
|
||||||
onChanged: (bool value) async {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
appController.clashConfig.ipv6 = value;
|
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<ClashConfig, bool>(
|
|
||||||
selector: (_, clashConfig) => clashConfig.allowLan,
|
|
||||||
builder: (_, allowLan, __) {
|
|
||||||
return ListItem.switchItem(
|
|
||||||
leading: const Icon(Icons.device_hub),
|
|
||||||
title: Text(appLocalizations.allowLan),
|
|
||||||
subtitle: Text(appLocalizations.allowLanDesc),
|
|
||||||
delegate: SwitchDelegate(
|
|
||||||
value: allowLan,
|
|
||||||
onChanged: (bool value) async {
|
|
||||||
final clashConfig = context.read<ClashConfig>();
|
|
||||||
clashConfig.allowLan = value;
|
|
||||||
globalState.appController.updateClashConfigDebounce();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<ClashConfig, bool>(
|
|
||||||
selector: (_, clashConfig) => clashConfig.unifiedDelay,
|
|
||||||
builder: (_, unifiedDelay, __) {
|
|
||||||
return ListItem.switchItem(
|
|
||||||
leading: const Icon(Icons.compress_outlined),
|
|
||||||
title: Text(appLocalizations.unifiedDelay),
|
|
||||||
subtitle: Text(appLocalizations.unifiedDelayDesc),
|
|
||||||
delegate: SwitchDelegate(
|
|
||||||
value: unifiedDelay,
|
|
||||||
onChanged: (bool value) async {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
appController.clashConfig.unifiedDelay = value;
|
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<ClashConfig, bool>(
|
|
||||||
selector: (_, clashConfig) =>
|
|
||||||
clashConfig.findProcessMode == FindProcessMode.always,
|
|
||||||
builder: (_, findProcess, __) {
|
|
||||||
return ListItem.switchItem(
|
|
||||||
leading: const Icon(Icons.polymer_outlined),
|
|
||||||
title: Text(appLocalizations.findProcessMode),
|
|
||||||
subtitle: Text(appLocalizations.findProcessModeDesc),
|
|
||||||
delegate: SwitchDelegate(
|
|
||||||
value: findProcess,
|
|
||||||
onChanged: (bool value) async {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
appController.clashConfig.findProcessMode =
|
|
||||||
value ? FindProcessMode.always : FindProcessMode.off;
|
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<ClashConfig, bool>(
|
|
||||||
selector: (_, clashConfig) => clashConfig.tcpConcurrent,
|
|
||||||
builder: (_, tcpConcurrent, __) {
|
|
||||||
return ListItem.switchItem(
|
|
||||||
leading: const Icon(Icons.double_arrow_outlined),
|
|
||||||
title: Text(appLocalizations.tcpConcurrent),
|
|
||||||
subtitle: Text(appLocalizations.tcpConcurrentDesc),
|
|
||||||
delegate: SwitchDelegate(
|
|
||||||
value: tcpConcurrent,
|
|
||||||
onChanged: (bool value) async {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
appController.clashConfig.tcpConcurrent = value;
|
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<ClashConfig, bool>(
|
|
||||||
selector: (_, clashConfig) =>
|
|
||||||
clashConfig.geodataLoader == geodataLoaderMemconservative,
|
|
||||||
builder: (_, memconservative, __) {
|
|
||||||
return ListItem.switchItem(
|
|
||||||
leading: const Icon(Icons.memory),
|
|
||||||
title: Text(appLocalizations.geodataLoader),
|
|
||||||
subtitle: Text(appLocalizations.geodataLoaderDesc),
|
|
||||||
delegate: SwitchDelegate(
|
|
||||||
value: memconservative,
|
|
||||||
onChanged: (bool value) async {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
appController.clashConfig.geodataLoader = value
|
|
||||||
? geodataLoaderMemconservative
|
|
||||||
: geodataLoaderStandard;
|
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Selector<ClashConfig, bool>(
|
|
||||||
selector: (_, clashConfig) =>
|
|
||||||
clashConfig.externalController.isNotEmpty,
|
|
||||||
builder: (_, hasExternalController, __) {
|
|
||||||
return ListItem.switchItem(
|
|
||||||
leading: const Icon(Icons.api_outlined),
|
|
||||||
title: Text(appLocalizations.externalController),
|
|
||||||
subtitle: Text(appLocalizations.externalControllerDesc),
|
|
||||||
delegate: SwitchDelegate(
|
|
||||||
value: hasExternalController,
|
|
||||||
onChanged: (bool value) async {
|
|
||||||
final appController = globalState.appController;
|
|
||||||
appController.clashConfig.externalController =
|
|
||||||
value ? defaultExternalController : '';
|
|
||||||
appController.updateClashConfigDebounce();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> _buildMoreSection() {
|
|
||||||
return generateSection(
|
|
||||||
title: appLocalizations.more,
|
|
||||||
items: [
|
|
||||||
if (system.isDesktop)
|
|
||||||
Selector<ClashConfig, bool>(
|
|
||||||
selector: (_, clashConfig) => clashConfig.tun.enable,
|
|
||||||
builder: (_, tunEnable, __) {
|
|
||||||
return ListItem.switchItem(
|
|
||||||
leading: const Icon(Icons.important_devices_outlined),
|
|
||||||
title: Text(appLocalizations.tun),
|
|
||||||
subtitle: Text(appLocalizations.tunDesc),
|
|
||||||
delegate: SwitchDelegate(
|
|
||||||
value: tunEnable,
|
|
||||||
onChanged: (bool value) async {
|
|
||||||
final clashConfig = context.read<ClashConfig>();
|
|
||||||
clashConfig.tun = Tun(enable: value);
|
|
||||||
globalState.appController.updateClashConfigDebounce();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
List<Widget> items = [
|
|
||||||
..._buildAppSection(),
|
|
||||||
..._buildGeneralSection(),
|
|
||||||
..._buildMoreSection(),
|
|
||||||
];
|
|
||||||
return ListView.builder(
|
|
||||||
padding: const EdgeInsets.only(bottom: 32),
|
|
||||||
itemBuilder: (_, index) {
|
|
||||||
return Container(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: items[index],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemCount: items.length,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MixedPortFormDialog extends StatefulWidget {
|
|
||||||
final num mixedPort;
|
|
||||||
|
|
||||||
const MixedPortFormDialog({super.key, required this.mixedPort});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MixedPortFormDialog> createState() => _MixedPortFormDialogState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MixedPortFormDialogState extends State<MixedPortFormDialog> {
|
|
||||||
late TextEditingController portController;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
portController = TextEditingController(text: "${widget.mixedPort}");
|
|
||||||
}
|
|
||||||
|
|
||||||
_handleUpdate() async {
|
|
||||||
final port = portController.value.text;
|
|
||||||
if (port.isEmpty) return;
|
|
||||||
Navigator.of(context).pop<String>(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text(appLocalizations.proxyPort),
|
|
||||||
content: SizedBox(
|
|
||||||
width: 300,
|
|
||||||
child: Wrap(
|
|
||||||
runSpacing: 16,
|
|
||||||
children: [
|
|
||||||
TextField(
|
|
||||||
controller: portController,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: _handleUpdate,
|
|
||||||
child: Text(appLocalizations.submit),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestUrlFormDialog extends StatefulWidget {
|
|
||||||
final String testUrl;
|
|
||||||
|
|
||||||
const TestUrlFormDialog({
|
|
||||||
super.key,
|
|
||||||
required this.testUrl,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<TestUrlFormDialog> createState() => _TestUrlFormDialogState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _TestUrlFormDialogState extends State<TestUrlFormDialog> {
|
|
||||||
late TextEditingController testUrlController;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
testUrlController = TextEditingController(text: widget.testUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
_handleUpdate() async {
|
|
||||||
final testUrl = testUrlController.value.text;
|
|
||||||
if (testUrl.isEmpty) return;
|
|
||||||
Navigator.of(context).pop<String>(testUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text(appLocalizations.testUrl),
|
|
||||||
content: SizedBox(
|
|
||||||
width: 300,
|
|
||||||
child: Wrap(
|
|
||||||
runSpacing: 16,
|
|
||||||
children: [
|
|
||||||
TextField(
|
|
||||||
maxLines: 5,
|
|
||||||
minLines: 1,
|
|
||||||
controller: testUrlController,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: _handleUpdate,
|
|
||||||
child: Text(appLocalizations.submit),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class KeepAliveIntervalFormDialog extends StatefulWidget {
|
|
||||||
final int keepAliveInterval;
|
|
||||||
|
|
||||||
const KeepAliveIntervalFormDialog({
|
|
||||||
super.key,
|
|
||||||
required this.keepAliveInterval,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<KeepAliveIntervalFormDialog> createState() =>
|
|
||||||
_KeepAliveIntervalFormDialogState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _KeepAliveIntervalFormDialogState
|
|
||||||
extends State<KeepAliveIntervalFormDialog> {
|
|
||||||
late TextEditingController keepAliveIntervalController;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
keepAliveIntervalController =
|
|
||||||
TextEditingController(text: "${widget.keepAliveInterval}");
|
|
||||||
}
|
|
||||||
|
|
||||||
_handleUpdate() async {
|
|
||||||
final keepAliveInterval = keepAliveIntervalController.value.text;
|
|
||||||
if (keepAliveInterval.isEmpty) return;
|
|
||||||
Navigator.of(context).pop<String>(keepAliveInterval);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text(appLocalizations.keepAliveIntervalDesc),
|
|
||||||
content: SizedBox(
|
|
||||||
width: 300,
|
|
||||||
child: Wrap(
|
|
||||||
runSpacing: 16,
|
|
||||||
children: [
|
|
||||||
TextField(
|
|
||||||
maxLines: 1,
|
|
||||||
minLines: 1,
|
|
||||||
controller: keepAliveIntervalController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
border: const OutlineInputBorder(),
|
|
||||||
suffixText: appLocalizations.seconds,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: _handleUpdate,
|
|
||||||
child: Text(appLocalizations.submit),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
89
lib/fragments/config/app.dart
Normal file
89
lib/fragments/config/app.dart
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:fl_clash/common/common.dart';
|
||||||
|
import 'package:fl_clash/models/config.dart';
|
||||||
|
import 'package:fl_clash/state.dart';
|
||||||
|
import 'package:fl_clash/widgets/widgets.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:path/path.dart' show dirname, join;
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class CloseConnectionsSwitch extends StatelessWidget {
|
||||||
|
const CloseConnectionsSwitch({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.isCloseConnections,
|
||||||
|
builder: (_, isCloseConnections, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: const Icon(Icons.auto_delete_outlined),
|
||||||
|
title: Text(appLocalizations.autoCloseConnections),
|
||||||
|
subtitle: Text(appLocalizations.autoCloseConnectionsDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: isCloseConnections,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final appController = globalState.appController;
|
||||||
|
appController.config.isCloseConnections = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class UsageSwitch extends StatelessWidget {
|
||||||
|
const UsageSwitch({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.onlyProxy,
|
||||||
|
builder: (_, onlyProxy, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: const Icon(Icons.data_usage_outlined),
|
||||||
|
title: Text(appLocalizations.onlyStatisticsProxy),
|
||||||
|
subtitle: Text(appLocalizations.onlyStatisticsProxyDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: onlyProxy,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final appController = globalState.appController;
|
||||||
|
appController.config.onlyProxy = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class UWPLoopbackUtil extends StatelessWidget {
|
||||||
|
const UWPLoopbackUtil({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.onlyProxy,
|
||||||
|
builder: (_, onlyProxy, __) {
|
||||||
|
return ListItem(
|
||||||
|
leading: const Icon(Icons.lock_open),
|
||||||
|
title: Text(appLocalizations.loopback),
|
||||||
|
subtitle: Text(appLocalizations.loopbackDesc),
|
||||||
|
onTap: () {
|
||||||
|
windows?.runas(
|
||||||
|
'"${join(dirname(Platform.resolvedExecutable), "EnableLoopback.exe")}"',
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final appItems = [
|
||||||
|
if (Platform.isWindows) const UWPLoopbackUtil(),
|
||||||
|
const CloseConnectionsSwitch(),
|
||||||
|
const UsageSwitch(),
|
||||||
|
];
|
||||||
90
lib/fragments/config/config.dart
Normal file
90
lib/fragments/config/config.dart
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:fl_clash/common/common.dart';
|
||||||
|
import 'package:fl_clash/fragments/config/app.dart';
|
||||||
|
import 'package:fl_clash/fragments/config/dns.dart';
|
||||||
|
import 'package:fl_clash/fragments/config/general.dart';
|
||||||
|
import 'package:fl_clash/fragments/config/vpn.dart';
|
||||||
|
import 'package:fl_clash/widgets/widgets.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class ConfigFragment extends StatefulWidget {
|
||||||
|
const ConfigFragment({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ConfigFragment> createState() => _ConfigFragmentState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ConfigFragmentState extends State<ConfigFragment> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
List<Widget> items = [
|
||||||
|
ListItem.open(
|
||||||
|
title: Text(appLocalizations.app),
|
||||||
|
subtitle: Text(appLocalizations.appDesc),
|
||||||
|
leading: const Icon(Icons.settings_applications),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
title: appLocalizations.app,
|
||||||
|
isBlur: false,
|
||||||
|
widget: generateListView(
|
||||||
|
appItems
|
||||||
|
.separated(
|
||||||
|
const Divider(
|
||||||
|
height: 0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (Platform.isAndroid)
|
||||||
|
ListItem.open(
|
||||||
|
title: const Text("VPN"),
|
||||||
|
subtitle: Text(appLocalizations.vpnDesc),
|
||||||
|
leading: const Icon(Icons.vpn_key),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
title: "VPN",
|
||||||
|
isBlur: false,
|
||||||
|
widget: generateListView(
|
||||||
|
vpnItems,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListItem.open(
|
||||||
|
title: Text(appLocalizations.general),
|
||||||
|
subtitle: Text(appLocalizations.generalDesc),
|
||||||
|
leading: const Icon(Icons.build),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
title: appLocalizations.general,
|
||||||
|
widget: generateListView(
|
||||||
|
generalItems,
|
||||||
|
),
|
||||||
|
isBlur: false,
|
||||||
|
extendPageWidth: 360,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListItem.open(
|
||||||
|
title: const Text("DNS"),
|
||||||
|
subtitle: Text(appLocalizations.dnsDesc),
|
||||||
|
leading: const Icon(Icons.dns),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
title: "DNS",
|
||||||
|
widget: generateListView(
|
||||||
|
dnsItems,
|
||||||
|
),
|
||||||
|
isBlur: false,
|
||||||
|
extendPageWidth: 360,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
];
|
||||||
|
return generateListView(
|
||||||
|
items
|
||||||
|
.separated(
|
||||||
|
const Divider(
|
||||||
|
height: 0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
824
lib/fragments/config/dns.dart
Normal file
824
lib/fragments/config/dns.dart
Normal file
@@ -0,0 +1,824 @@
|
|||||||
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:fl_clash/common/app_localizations.dart';
|
||||||
|
import 'package:fl_clash/common/common.dart';
|
||||||
|
import 'package:fl_clash/enum/enum.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 OverrideItem extends StatelessWidget {
|
||||||
|
const OverrideItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.overrideDns,
|
||||||
|
builder: (_, override, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
title: Text(appLocalizations.overrideDns),
|
||||||
|
subtitle: Text(appLocalizations.overrideDnsDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: override,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
config.overrideDns = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DnsDisabledContainer extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const DnsDisabledContainer(
|
||||||
|
this.child, {
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.overrideDns,
|
||||||
|
builder: (_, enable, child) {
|
||||||
|
return AbsorbPointer(
|
||||||
|
absorbing: !enable,
|
||||||
|
child: DisabledMask(
|
||||||
|
status: !enable,
|
||||||
|
child: Container(
|
||||||
|
color: context.colorScheme.surface,
|
||||||
|
child: child!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class StatusItem extends StatelessWidget {
|
||||||
|
const StatusItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.enable,
|
||||||
|
builder: (_, enable, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
title: Text(appLocalizations.status),
|
||||||
|
subtitle: Text(appLocalizations.statusDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: enable,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
enable: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PreferH3Item extends StatelessWidget {
|
||||||
|
const PreferH3Item({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.preferH3,
|
||||||
|
builder: (_, preferH3, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
title: const Text("PreferH3"),
|
||||||
|
subtitle: Text(appLocalizations.preferH3Desc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: preferH3,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
preferH3: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class IPv6Item extends StatelessWidget {
|
||||||
|
const IPv6Item({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.ipv6,
|
||||||
|
builder: (_, ipv6, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
title: const Text("IPv6"),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: ipv6,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
ipv6: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RespectRulesItem extends StatelessWidget {
|
||||||
|
const RespectRulesItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.respectRules,
|
||||||
|
builder: (_, respectRules, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
title: Text(appLocalizations.respectRules),
|
||||||
|
subtitle: Text(appLocalizations.respectRulesDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: respectRules,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
respectRules: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DnsModeItem extends StatelessWidget {
|
||||||
|
const DnsModeItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, DnsMode>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.enhancedMode,
|
||||||
|
builder: (_, enhancedMode, __) {
|
||||||
|
return ListItem<DnsMode>.options(
|
||||||
|
title: Text(appLocalizations.dnsMode),
|
||||||
|
subtitle: Text(enhancedMode.name),
|
||||||
|
delegate: OptionsDelegate(
|
||||||
|
title: appLocalizations.dnsMode,
|
||||||
|
options: DnsMode.values,
|
||||||
|
onChanged: (value) {
|
||||||
|
if (value == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(enhancedMode: value);
|
||||||
|
},
|
||||||
|
textBuilder: (dnsMode) => dnsMode.name,
|
||||||
|
value: enhancedMode,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FakeIpRangeItem extends StatelessWidget {
|
||||||
|
const FakeIpRangeItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, String>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.fakeIpRange,
|
||||||
|
builder: (_, fakeIpRange, __) {
|
||||||
|
return ListItem.input(
|
||||||
|
title: Text(appLocalizations.fakeipRange),
|
||||||
|
subtitle: Text(fakeIpRange),
|
||||||
|
delegate: InputDelegate(
|
||||||
|
title: appLocalizations.fakeipRange,
|
||||||
|
value: fakeIpRange,
|
||||||
|
onChanged: (String? value) {
|
||||||
|
if (value != null) {
|
||||||
|
try {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
clashConfig.dns = clashConfig.dns.copyWith(
|
||||||
|
fakeIpRange: value,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
globalState.showMessage(
|
||||||
|
title: appLocalizations.fakeipRange,
|
||||||
|
message: TextSpan(
|
||||||
|
text: e.toString(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FakeIpFilterItem extends StatelessWidget {
|
||||||
|
const FakeIpFilterItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListItem.open(
|
||||||
|
title: Text(appLocalizations.fakeipFilter),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
isBlur: false,
|
||||||
|
title: appLocalizations.fakeipFilter,
|
||||||
|
widget: Selector<ClashConfig, List<String>>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.fakeIpFilter,
|
||||||
|
shouldRebuild: (prev, next) =>
|
||||||
|
!const ListEquality<String>().equals(prev, next),
|
||||||
|
builder: (_, fakeIpFilter, __) {
|
||||||
|
return UpdatePage(
|
||||||
|
title: appLocalizations.fakeipFilter,
|
||||||
|
items: fakeIpFilter,
|
||||||
|
titleBuilder: (item) => Text(item),
|
||||||
|
onRemove: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
fakeIpFilter: List.from(dns.fakeIpFilter)..remove(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onAdd: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
if (fakeIpFilter.contains(value)) return;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
fakeIpFilter: List.from(dns.fakeIpFilter)..add(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
extendPageWidth: 360,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DefaultNameserverItem extends StatelessWidget {
|
||||||
|
const DefaultNameserverItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListItem.open(
|
||||||
|
title: Text(appLocalizations.defaultNameserver),
|
||||||
|
subtitle: Text(appLocalizations.defaultNameserverDesc),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
isBlur: false,
|
||||||
|
title: appLocalizations.defaultNameserver,
|
||||||
|
widget: Selector<ClashConfig, List<String>>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.defaultNameserver,
|
||||||
|
shouldRebuild: (prev, next) =>
|
||||||
|
!const ListEquality<String>().equals(prev, next),
|
||||||
|
builder: (_, defaultNameserver, __) {
|
||||||
|
return UpdatePage(
|
||||||
|
title: appLocalizations.defaultNameserver,
|
||||||
|
items: defaultNameserver,
|
||||||
|
titleBuilder: (item) => Text(item),
|
||||||
|
onRemove: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
defaultNameserver: List.from(dns.defaultNameserver)
|
||||||
|
..remove(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onAdd: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
if (defaultNameserver.contains(value)) return;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
defaultNameserver: List.from(dns.defaultNameserver)
|
||||||
|
..add(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
extendPageWidth: 360,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NameserverItem extends StatelessWidget {
|
||||||
|
const NameserverItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListItem.open(
|
||||||
|
title: Text(appLocalizations.nameserver),
|
||||||
|
subtitle: Text(appLocalizations.nameserverDesc),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
title: appLocalizations.nameserver,
|
||||||
|
isBlur: false,
|
||||||
|
widget: Selector<ClashConfig, List<String>>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.nameserver,
|
||||||
|
shouldRebuild: (prev, next) =>
|
||||||
|
!const ListEquality<String>().equals(prev, next),
|
||||||
|
builder: (_, nameserver, __) {
|
||||||
|
return UpdatePage(
|
||||||
|
title: "域名服务器",
|
||||||
|
items: nameserver,
|
||||||
|
titleBuilder: (item) => Text(item),
|
||||||
|
onRemove: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
nameserver: List.from(dns.nameserver)..remove(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onAdd: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
if (nameserver.contains(value)) return;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
nameserver: List.from(dns.nameserver)..add(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
extendPageWidth: 360,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class UseHostsItem extends StatelessWidget {
|
||||||
|
const UseHostsItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.useHosts,
|
||||||
|
builder: (_, useHosts, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
title: Text(appLocalizations.useHosts),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: useHosts,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
useHosts: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class UseSystemHostsItem extends StatelessWidget {
|
||||||
|
const UseSystemHostsItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.useSystemHosts,
|
||||||
|
builder: (_, useSystemHosts, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
title: Text(appLocalizations.useSystemHosts),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: useSystemHosts,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
useSystemHosts: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NameserverPolicyItem extends StatelessWidget {
|
||||||
|
const NameserverPolicyItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListItem.open(
|
||||||
|
title: Text(appLocalizations.nameserverPolicy),
|
||||||
|
subtitle: Text(appLocalizations.nameserverPolicyDesc),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
isBlur: false,
|
||||||
|
title: appLocalizations.nameserverPolicy,
|
||||||
|
widget: Selector<ClashConfig, Map<String, String>>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.nameserverPolicy,
|
||||||
|
shouldRebuild: (prev, next) =>
|
||||||
|
!const MapEquality<String, String>().equals(prev, next),
|
||||||
|
builder: (_, nameserverPolicy, __) {
|
||||||
|
return UpdatePage(
|
||||||
|
title: appLocalizations.nameserverPolicy,
|
||||||
|
items: nameserverPolicy.entries,
|
||||||
|
titleBuilder: (item) => Text(item.key),
|
||||||
|
subtitleBuilder: (item) => Text(item.value),
|
||||||
|
isMap: true,
|
||||||
|
onRemove: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
nameserverPolicy: Map.from(dns.nameserverPolicy)
|
||||||
|
..remove(value.key),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onAdd: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
nameserverPolicy: Map.from(dns.nameserverPolicy)
|
||||||
|
..addEntries([value]),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
extendPageWidth: 360,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ProxyServerNameserverItem extends StatelessWidget {
|
||||||
|
const ProxyServerNameserverItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListItem.open(
|
||||||
|
title: Text(appLocalizations.proxyNameserver),
|
||||||
|
subtitle: Text(appLocalizations.proxyNameserverDesc),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
isBlur: false,
|
||||||
|
title: appLocalizations.proxyNameserver,
|
||||||
|
widget: Selector<ClashConfig, List<String>>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.proxyServerNameserver,
|
||||||
|
shouldRebuild: (prev, next) =>
|
||||||
|
!const ListEquality<String>().equals(prev, next),
|
||||||
|
builder: (_, proxyServerNameserver, __) {
|
||||||
|
return UpdatePage(
|
||||||
|
title: appLocalizations.proxyNameserver,
|
||||||
|
items: proxyServerNameserver,
|
||||||
|
titleBuilder: (item) => Text(item),
|
||||||
|
onRemove: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
proxyServerNameserver: List.from(dns.proxyServerNameserver)
|
||||||
|
..remove(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onAdd: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
if (proxyServerNameserver.contains(value)) return;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
proxyServerNameserver: List.from(dns.proxyServerNameserver)
|
||||||
|
..add(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
extendPageWidth: 360,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FallbackItem extends StatelessWidget {
|
||||||
|
const FallbackItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListItem.open(
|
||||||
|
title: Text(appLocalizations.fallback),
|
||||||
|
subtitle: Text(appLocalizations.fallbackDesc),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
isBlur: false,
|
||||||
|
title: appLocalizations.fallback,
|
||||||
|
widget: Selector<ClashConfig, List<String>>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.fallback,
|
||||||
|
shouldRebuild: (prev, next) =>
|
||||||
|
!const ListEquality<String>().equals(prev, next),
|
||||||
|
builder: (_, fallback, __) {
|
||||||
|
return UpdatePage(
|
||||||
|
title: appLocalizations.fallback,
|
||||||
|
items: fallback,
|
||||||
|
titleBuilder: (item) => Text(item),
|
||||||
|
onRemove: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
fallback: List.from(dns.fallback)..remove(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onAdd: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
if (fallback.contains(value)) return;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
fallback: List.from(dns.fallback)..add(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
extendPageWidth: 360,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GeoipItem extends StatelessWidget {
|
||||||
|
const GeoipItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.fallbackFilter.geoip,
|
||||||
|
builder: (_, geoip, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
title: const Text("Geoip"),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: geoip,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
fallbackFilter: dns.fallbackFilter.copyWith(geoip: value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GeoipCodeItem extends StatelessWidget {
|
||||||
|
const GeoipCodeItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, String>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.fallbackFilter.geoipCode,
|
||||||
|
builder: (_, geoipCode, __) {
|
||||||
|
return ListItem.input(
|
||||||
|
title: Text(appLocalizations.geoipCode),
|
||||||
|
subtitle: Text(geoipCode),
|
||||||
|
delegate: InputDelegate(
|
||||||
|
title: appLocalizations.geoipCode,
|
||||||
|
value: geoipCode,
|
||||||
|
onChanged: (String? value) {
|
||||||
|
if (value != null) {
|
||||||
|
try {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||||
|
geoipCode: value,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
globalState.showMessage(
|
||||||
|
title: appLocalizations.geoipCode,
|
||||||
|
message: TextSpan(
|
||||||
|
text: e.toString(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GeositeItem extends StatelessWidget {
|
||||||
|
const GeositeItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListItem.open(
|
||||||
|
title: const Text("Geosite"),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
isBlur: false,
|
||||||
|
title: "Geosite",
|
||||||
|
widget: Selector<ClashConfig, List<String>>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.fallbackFilter.geosite,
|
||||||
|
shouldRebuild: (prev, next) =>
|
||||||
|
!const ListEquality<String>().equals(prev, next),
|
||||||
|
builder: (_, geosite, __) {
|
||||||
|
return UpdatePage(
|
||||||
|
title: "Geosite",
|
||||||
|
items: geosite,
|
||||||
|
titleBuilder: (item) => Text(item),
|
||||||
|
onRemove: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||||
|
geosite: List.from(geosite)..remove(value),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onAdd: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||||
|
geosite: List.from(geosite)..add(value),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
extendPageWidth: 360,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class IpcidrItem extends StatelessWidget {
|
||||||
|
const IpcidrItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListItem.open(
|
||||||
|
title: Text(appLocalizations.ipcidr),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
isBlur: false,
|
||||||
|
title: appLocalizations.ipcidr,
|
||||||
|
widget: Selector<ClashConfig, List<String>>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.fallbackFilter.ipcidr,
|
||||||
|
shouldRebuild: (prev, next) =>
|
||||||
|
!const ListEquality<String>().equals(prev, next),
|
||||||
|
builder: (_, ipcidr, __) {
|
||||||
|
return UpdatePage(
|
||||||
|
title: appLocalizations.ipcidr,
|
||||||
|
items: ipcidr,
|
||||||
|
titleBuilder: (item) => Text(item),
|
||||||
|
onRemove: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||||
|
ipcidr: List.from(ipcidr)..remove(value),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onAdd: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||||
|
ipcidr: List.from(ipcidr)..add(value),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
extendPageWidth: 360,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DomainItem extends StatelessWidget {
|
||||||
|
const DomainItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListItem.open(
|
||||||
|
title: Text(appLocalizations.domain),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
isBlur: false,
|
||||||
|
title: appLocalizations.domain,
|
||||||
|
widget: Selector<ClashConfig, List<String>>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.dns.fallbackFilter.domain,
|
||||||
|
shouldRebuild: (prev, next) =>
|
||||||
|
!const ListEquality<String>().equals(prev, next),
|
||||||
|
builder: (_, domain, __) {
|
||||||
|
return UpdatePage(
|
||||||
|
title: appLocalizations.domain,
|
||||||
|
items: domain,
|
||||||
|
titleBuilder: (item) => Text(item),
|
||||||
|
onRemove: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||||
|
domain: List.from(domain)..remove(value),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onAdd: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
final dns = clashConfig.dns;
|
||||||
|
clashConfig.dns = dns.copyWith(
|
||||||
|
fallbackFilter: dns.fallbackFilter.copyWith(
|
||||||
|
domain: List.from(domain)..add(value),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
extendPageWidth: 360,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DnsOptions extends StatelessWidget {
|
||||||
|
const DnsOptions({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return DnsDisabledContainer(
|
||||||
|
Column(
|
||||||
|
children: generateSection(
|
||||||
|
title: appLocalizations.options,
|
||||||
|
items: [
|
||||||
|
const StatusItem(),
|
||||||
|
const UseHostsItem(),
|
||||||
|
const UseSystemHostsItem(),
|
||||||
|
const IPv6Item(),
|
||||||
|
const RespectRulesItem(),
|
||||||
|
const PreferH3Item(),
|
||||||
|
const DnsModeItem(),
|
||||||
|
const FakeIpRangeItem(),
|
||||||
|
const FakeIpFilterItem(),
|
||||||
|
const DefaultNameserverItem(),
|
||||||
|
const NameserverPolicyItem(),
|
||||||
|
const NameserverItem(),
|
||||||
|
const FallbackItem(),
|
||||||
|
const ProxyServerNameserverItem(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FallbackFilterOptions extends StatelessWidget {
|
||||||
|
const FallbackFilterOptions({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return DnsDisabledContainer(
|
||||||
|
Column(
|
||||||
|
children: generateSection(
|
||||||
|
title: appLocalizations.fallbackFilter,
|
||||||
|
items: [
|
||||||
|
const GeoipItem(),
|
||||||
|
const GeoipCodeItem(),
|
||||||
|
const GeositeItem(),
|
||||||
|
const IpcidrItem(),
|
||||||
|
const DomainItem(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const dnsItems = <Widget>[
|
||||||
|
OverrideItem(),
|
||||||
|
DnsOptions(),
|
||||||
|
FallbackFilterOptions(),
|
||||||
|
];
|
||||||
436
lib/fragments/config/general.dart
Normal file
436
lib/fragments/config/general.dart
Normal file
@@ -0,0 +1,436 @@
|
|||||||
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:fl_clash/common/common.dart';
|
||||||
|
import 'package:fl_clash/enum/enum.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 LogLevelItem extends StatelessWidget {
|
||||||
|
const LogLevelItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, LogLevel>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.logLevel,
|
||||||
|
builder: (_, value, __) {
|
||||||
|
return ListItem<LogLevel>.options(
|
||||||
|
leading: const Icon(Icons.info_outline),
|
||||||
|
title: Text(appLocalizations.logLevel),
|
||||||
|
subtitle: Text(value.name),
|
||||||
|
delegate: OptionsDelegate<LogLevel>(
|
||||||
|
title: appLocalizations.logLevel,
|
||||||
|
options: LogLevel.values,
|
||||||
|
onChanged: (LogLevel? value) {
|
||||||
|
if (value == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final appController = globalState.appController;
|
||||||
|
appController.clashConfig.logLevel = value;
|
||||||
|
},
|
||||||
|
textBuilder: (logLevel) => logLevel.name,
|
||||||
|
value: value,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class UaItem extends StatelessWidget {
|
||||||
|
const UaItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, String?>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.globalRealUa,
|
||||||
|
builder: (_, value, __) {
|
||||||
|
return ListItem<String?>.options(
|
||||||
|
leading: const Icon(Icons.computer_outlined),
|
||||||
|
title: const Text("UA"),
|
||||||
|
subtitle: Text(value ?? appLocalizations.defaultText),
|
||||||
|
delegate: OptionsDelegate<String?>(
|
||||||
|
title: "UA",
|
||||||
|
options: [
|
||||||
|
null,
|
||||||
|
"clash-verge/v1.6.6",
|
||||||
|
"ClashforWindows/0.19.23",
|
||||||
|
],
|
||||||
|
value: value,
|
||||||
|
onChanged: (ua) {
|
||||||
|
final appController = globalState.appController;
|
||||||
|
appController.clashConfig.globalRealUa = ua;
|
||||||
|
},
|
||||||
|
textBuilder: (ua) => ua ?? appLocalizations.defaultText,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class KeepAliveIntervalItem extends StatelessWidget {
|
||||||
|
const KeepAliveIntervalItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, int>(
|
||||||
|
selector: (_, config) => config.keepAliveInterval,
|
||||||
|
builder: (_, value, __) {
|
||||||
|
return ListItem.input(
|
||||||
|
leading: const Icon(Icons.timer_outlined),
|
||||||
|
title: Text(appLocalizations.keepAliveIntervalDesc),
|
||||||
|
subtitle: Text("$value ${appLocalizations.seconds}"),
|
||||||
|
delegate: InputDelegate(
|
||||||
|
title: appLocalizations.keepAliveIntervalDesc,
|
||||||
|
suffixText: appLocalizations.seconds,
|
||||||
|
value: value.toString(),
|
||||||
|
onChanged: (String? value) {
|
||||||
|
if (value != null) {
|
||||||
|
try {
|
||||||
|
final intValue = int.parse(value);
|
||||||
|
if (intValue <= 0) {
|
||||||
|
throw "Invalid keepAliveInterval";
|
||||||
|
}
|
||||||
|
globalState.appController.clashConfig.keepAliveInterval =
|
||||||
|
intValue;
|
||||||
|
} catch (e) {
|
||||||
|
globalState.showMessage(
|
||||||
|
title: appLocalizations.keepAliveIntervalDesc,
|
||||||
|
message: TextSpan(
|
||||||
|
text: e.toString(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestUrlItem extends StatelessWidget {
|
||||||
|
const TestUrlItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<Config, String>(
|
||||||
|
selector: (_, config) => config.testUrl,
|
||||||
|
builder: (_, value, __) {
|
||||||
|
return ListItem.input(
|
||||||
|
leading: const Icon(Icons.timeline),
|
||||||
|
title: Text(appLocalizations.testUrl),
|
||||||
|
subtitle: Text(value),
|
||||||
|
delegate: InputDelegate(
|
||||||
|
title: appLocalizations.testUrl,
|
||||||
|
value: value,
|
||||||
|
onChanged: (String? value) {
|
||||||
|
if (value != null) {
|
||||||
|
try {
|
||||||
|
if (!value.isUrl) {
|
||||||
|
throw "Invalid url";
|
||||||
|
}
|
||||||
|
globalState.appController.config.testUrl = value;
|
||||||
|
} catch (e) {
|
||||||
|
globalState.showMessage(
|
||||||
|
title: appLocalizations.testUrl,
|
||||||
|
message: TextSpan(
|
||||||
|
text: e.toString(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MixedPortItem extends StatelessWidget {
|
||||||
|
const MixedPortItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, int>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.mixedPort,
|
||||||
|
builder: (_, value, __) {
|
||||||
|
return ListItem.input(
|
||||||
|
leading: const Icon(Icons.adjust_outlined),
|
||||||
|
title: Text(appLocalizations.proxyPort),
|
||||||
|
subtitle: Text("$value"),
|
||||||
|
delegate: InputDelegate(
|
||||||
|
title: appLocalizations.proxyPort,
|
||||||
|
value: value.toString(),
|
||||||
|
onChanged: (String? value) {
|
||||||
|
if (value != null) {
|
||||||
|
try {
|
||||||
|
final mixedPort = int.parse(value);
|
||||||
|
if (mixedPort < 1024 || mixedPort > 49151) {
|
||||||
|
throw "Invalid port";
|
||||||
|
}
|
||||||
|
globalState.appController.clashConfig.mixedPort = mixedPort;
|
||||||
|
} catch (e) {
|
||||||
|
globalState.showMessage(
|
||||||
|
title: appLocalizations.proxyPort,
|
||||||
|
message: TextSpan(
|
||||||
|
text: e.toString(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class HostsItem extends StatelessWidget {
|
||||||
|
const HostsItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListItem.open(
|
||||||
|
leading: const Icon(Icons.view_list_outlined),
|
||||||
|
title: const Text("Hosts"),
|
||||||
|
subtitle: Text(appLocalizations.hostsDesc),
|
||||||
|
delegate: OpenDelegate(
|
||||||
|
isBlur: false,
|
||||||
|
title: "Hosts",
|
||||||
|
widget: Selector<ClashConfig, HostsMap>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.hosts,
|
||||||
|
shouldRebuild: (prev, next) =>
|
||||||
|
!const MapEquality<String, String>().equals(prev, next),
|
||||||
|
builder: (_, hosts, ___) {
|
||||||
|
final entries = hosts.entries;
|
||||||
|
return UpdatePage(
|
||||||
|
title: "Hosts",
|
||||||
|
items: entries,
|
||||||
|
titleBuilder: (item) => Text(item.key),
|
||||||
|
subtitleBuilder: (item) => Text(item.value),
|
||||||
|
onRemove: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
clashConfig.hosts = Map.from(hosts)..remove(value.key);
|
||||||
|
},
|
||||||
|
onAdd: (value) {
|
||||||
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
|
clashConfig.hosts = Map.from(clashConfig.hosts)
|
||||||
|
..addEntries([value]);
|
||||||
|
},
|
||||||
|
isMap: true,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
extendPageWidth: 360,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Ipv6Item extends StatelessWidget {
|
||||||
|
const Ipv6Item({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.ipv6,
|
||||||
|
builder: (_, ipv6, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: const Icon(Icons.water_outlined),
|
||||||
|
title: const Text("IPv6"),
|
||||||
|
subtitle: Text(appLocalizations.ipv6Desc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: ipv6,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final appController = globalState.appController;
|
||||||
|
appController.clashConfig.ipv6 = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AllowLanItem extends StatelessWidget {
|
||||||
|
const AllowLanItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.allowLan,
|
||||||
|
builder: (_, allowLan, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: const Icon(Icons.device_hub),
|
||||||
|
title: Text(appLocalizations.allowLan),
|
||||||
|
subtitle: Text(appLocalizations.allowLanDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: allowLan,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final clashConfig = context.read<ClashConfig>();
|
||||||
|
clashConfig.allowLan = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class UnifiedDelayItem extends StatelessWidget {
|
||||||
|
const UnifiedDelayItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.unifiedDelay,
|
||||||
|
builder: (_, unifiedDelay, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: const Icon(Icons.compress_outlined),
|
||||||
|
title: Text(appLocalizations.unifiedDelay),
|
||||||
|
subtitle: Text(appLocalizations.unifiedDelayDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: unifiedDelay,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final appController = globalState.appController;
|
||||||
|
appController.clashConfig.unifiedDelay = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FindProcessItem extends StatelessWidget {
|
||||||
|
const FindProcessItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) =>
|
||||||
|
clashConfig.findProcessMode == FindProcessMode.always,
|
||||||
|
builder: (_, findProcess, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: const Icon(Icons.polymer_outlined),
|
||||||
|
title: Text(appLocalizations.findProcessMode),
|
||||||
|
subtitle: Text(appLocalizations.findProcessModeDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: findProcess,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final appController = globalState.appController;
|
||||||
|
appController.clashConfig.findProcessMode =
|
||||||
|
value ? FindProcessMode.always : FindProcessMode.off;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TcpConcurrentItem extends StatelessWidget {
|
||||||
|
const TcpConcurrentItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.tcpConcurrent,
|
||||||
|
builder: (_, tcpConcurrent, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: const Icon(Icons.double_arrow_outlined),
|
||||||
|
title: Text(appLocalizations.tcpConcurrent),
|
||||||
|
subtitle: Text(appLocalizations.tcpConcurrentDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: tcpConcurrent,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final appController = globalState.appController;
|
||||||
|
appController.clashConfig.tcpConcurrent = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GeodataLoaderItem extends StatelessWidget {
|
||||||
|
const GeodataLoaderItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) =>
|
||||||
|
clashConfig.geodataLoader == geodataLoaderMemconservative,
|
||||||
|
builder: (_, memconservative, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: const Icon(Icons.memory),
|
||||||
|
title: Text(appLocalizations.geodataLoader),
|
||||||
|
subtitle: Text(appLocalizations.geodataLoaderDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: memconservative,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final appController = globalState.appController;
|
||||||
|
appController.clashConfig.geodataLoader =
|
||||||
|
value ? geodataLoaderMemconservative : geodataLoaderStandard;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ExternalControllerItem extends StatelessWidget {
|
||||||
|
const ExternalControllerItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<ClashConfig, bool>(
|
||||||
|
selector: (_, clashConfig) => clashConfig.externalController.isNotEmpty,
|
||||||
|
builder: (_, hasExternalController, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: const Icon(Icons.api_outlined),
|
||||||
|
title: Text(appLocalizations.externalController),
|
||||||
|
subtitle: Text(appLocalizations.externalControllerDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: hasExternalController,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final appController = globalState.appController;
|
||||||
|
appController.clashConfig.externalController =
|
||||||
|
value ? defaultExternalController : '';
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final generalItems = const [
|
||||||
|
LogLevelItem(),
|
||||||
|
UaItem(),
|
||||||
|
KeepAliveIntervalItem(),
|
||||||
|
TestUrlItem(),
|
||||||
|
MixedPortItem(),
|
||||||
|
HostsItem(),
|
||||||
|
Ipv6Item(),
|
||||||
|
AllowLanItem(),
|
||||||
|
UnifiedDelayItem(),
|
||||||
|
FindProcessItem(),
|
||||||
|
TcpConcurrentItem(),
|
||||||
|
GeodataLoaderItem(),
|
||||||
|
ExternalControllerItem(),
|
||||||
|
]
|
||||||
|
.separated(
|
||||||
|
const Divider(
|
||||||
|
height: 0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
140
lib/fragments/config/vpn.dart
Normal file
140
lib/fragments/config/vpn.dart
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
import 'package:fl_clash/common/common.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 Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.vpnProps.enable,
|
||||||
|
builder: (_, enable, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: const Icon(Icons.stacked_line_chart),
|
||||||
|
title: const Text("VPN"),
|
||||||
|
subtitle: Text(appLocalizations.vpnEnableDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: enable,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
final vpnProps = config.vpnProps;
|
||||||
|
config.vpnProps = vpnProps.copyWith(
|
||||||
|
enable: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class VPNDisabledContainer extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const VPNDisabledContainer(
|
||||||
|
this.child, {
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.vpnProps.enable,
|
||||||
|
builder: (_, enable, child) {
|
||||||
|
return AbsorbPointer(
|
||||||
|
absorbing: !enable,
|
||||||
|
child: DisabledMask(
|
||||||
|
status: !enable,
|
||||||
|
child: child!,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AllowBypassSwitch extends StatelessWidget {
|
||||||
|
const AllowBypassSwitch({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.vpnProps.allowBypass,
|
||||||
|
builder: (_, allowBypass, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: const Icon(Icons.arrow_forward_outlined),
|
||||||
|
title: Text(appLocalizations.allowBypass),
|
||||||
|
subtitle: Text(appLocalizations.allowBypassDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: allowBypass,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
final vpnProps = config.vpnProps;
|
||||||
|
config.vpnProps = vpnProps.copyWith(
|
||||||
|
allowBypass: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SystemProxySwitch extends StatelessWidget {
|
||||||
|
const SystemProxySwitch({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<Config, bool>(
|
||||||
|
selector: (_, config) => config.vpnProps.systemProxy,
|
||||||
|
builder: (_, systemProxy, __) {
|
||||||
|
return ListItem.switchItem(
|
||||||
|
leading: const Icon(Icons.settings_ethernet),
|
||||||
|
title: Text(appLocalizations.systemProxy),
|
||||||
|
subtitle: Text(appLocalizations.systemProxyDesc),
|
||||||
|
delegate: SwitchDelegate(
|
||||||
|
value: systemProxy,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
final vpnProps = config.vpnProps;
|
||||||
|
config.vpnProps = vpnProps.copyWith(
|
||||||
|
systemProxy: value,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class VpnOptions extends StatelessWidget {
|
||||||
|
const VpnOptions({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return VPNDisabledContainer(
|
||||||
|
Column(
|
||||||
|
children: generateSection(
|
||||||
|
title: appLocalizations.options,
|
||||||
|
items: [
|
||||||
|
const SystemProxySwitch(),
|
||||||
|
const AllowBypassSwitch(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final vpnItems = [
|
||||||
|
const VPNSwitch(),
|
||||||
|
const VpnOptions(),
|
||||||
|
];
|
||||||
@@ -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(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:country_flags/country_flags.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
@@ -14,28 +14,41 @@ 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;
|
||||||
|
|
||||||
_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) {
|
||||||
final ipInfo = await request.checkIp();
|
cancelToken!.cancel();
|
||||||
if (ipInfo == null) {
|
cancelToken = null;
|
||||||
timeoutNotifier.value = true;
|
}
|
||||||
return;
|
cancelToken = CancelToken();
|
||||||
} else {
|
try {
|
||||||
timeoutNotifier.value = false;
|
final ipInfo = await request.checkIp(cancelToken: cancelToken);
|
||||||
|
networkDetectionState.value = networkDetectionState.value.copyWith(
|
||||||
|
isTesting: false,
|
||||||
|
ipInfo: ipInfo,
|
||||||
|
);
|
||||||
|
} catch (_) {
|
||||||
|
|
||||||
}
|
}
|
||||||
ipInfoNotifier.value = ipInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_checkIpContainer(Widget child) {
|
_checkIpContainer(Widget child) {
|
||||||
@@ -56,17 +69,28 @@ 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) {
|
||||||
|
final String code = countryCode.toUpperCase();
|
||||||
|
if (code.length != 2) {
|
||||||
|
return countryCode;
|
||||||
|
}
|
||||||
|
final int firstLetter = code.codeUnitAt(0) - 0x41 + 0x1F1E6;
|
||||||
|
final int secondLetter = code.codeUnitAt(1) - 0x41 + 0x1F1E6;
|
||||||
|
return String.fromCharCode(firstLetter) + String.fromCharCode(secondLetter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
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(
|
||||||
@@ -87,37 +111,38 @@ class _NetworkDetectionState extends State<NetworkDetection> {
|
|||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FadeBox(
|
child: FadeBox(
|
||||||
child: ipInfo != null
|
child: isTesting
|
||||||
? CountryFlag.fromCountryCode(
|
? Text(
|
||||||
ipInfo.countryCode,
|
appLocalizations.checking,
|
||||||
width: 24,
|
maxLines: 1,
|
||||||
height: 24,
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style:
|
||||||
|
Theme.of(context).textTheme.titleMedium,
|
||||||
)
|
)
|
||||||
: 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,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -150,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,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,9 +5,9 @@ export 'profiles/profiles.dart';
|
|||||||
export 'logs.dart';
|
export 'logs.dart';
|
||||||
export 'connections.dart';
|
export 'connections.dart';
|
||||||
export 'access.dart';
|
export 'access.dart';
|
||||||
export 'config.dart';
|
export 'config/config.dart';
|
||||||
export 'application_setting.dart';
|
export 'application_setting.dart';
|
||||||
export 'about.dart';
|
export 'about.dart';
|
||||||
export 'backup_and_recovery.dart';
|
export 'backup_and_recovery.dart';
|
||||||
export 'resources.dart';
|
export 'resources.dart';
|
||||||
export 'requests.dart';
|
export 'requests.dart';
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:fl_clash/enum/enum.dart';
|
import 'package:fl_clash/enum/enum.dart';
|
||||||
import 'package:fl_clash/fragments/profiles/edit_profile.dart';
|
import 'package:fl_clash/fragments/profiles/edit_profile.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
@@ -37,32 +39,24 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_getColumns(ViewMode viewMode) {
|
|
||||||
switch (viewMode) {
|
|
||||||
case ViewMode.mobile:
|
|
||||||
return 1;
|
|
||||||
case ViewMode.laptop:
|
|
||||||
return 1;
|
|
||||||
case ViewMode.desktop:
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_updateProfiles() async {
|
_updateProfiles() async {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
final config = appController.config;
|
final config = appController.config;
|
||||||
final profiles = appController.config.profiles;
|
final profiles = appController.config.profiles;
|
||||||
|
final messages = [];
|
||||||
final updateProfiles = profiles.map<Future>(
|
final updateProfiles = profiles.map<Future>(
|
||||||
(profile) async {
|
(profile) async {
|
||||||
|
if (profile.type == ProfileType.file) return;
|
||||||
config.setProfile(
|
config.setProfile(
|
||||||
profile.copyWith(isUpdating: true),
|
profile.copyWith(isUpdating: true),
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
await appController.updateProfile(profile);
|
await appController.updateProfile(profile);
|
||||||
if (profile.id == appController.config.currentProfile?.id) {
|
if (profile.id == appController.config.currentProfile?.id) {
|
||||||
appController.applyProfile(isPrue: true);
|
appController.applyProfileDebounce();
|
||||||
}
|
}
|
||||||
} catch (_) {
|
} catch (e) {
|
||||||
|
messages.add("${profile.label ?? profile.id}: $e \n");
|
||||||
config.setProfile(
|
config.setProfile(
|
||||||
profile.copyWith(
|
profile.copyWith(
|
||||||
isUpdating: false,
|
isUpdating: false,
|
||||||
@@ -71,13 +65,25 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
final titleMedium = context.textTheme.titleMedium;
|
||||||
await Future.wait(updateProfiles);
|
await Future.wait(updateProfiles);
|
||||||
|
if (messages.isNotEmpty) {
|
||||||
|
globalState.showMessage(
|
||||||
|
title: appLocalizations.tip,
|
||||||
|
message: TextSpan(
|
||||||
|
children: [
|
||||||
|
for (final message in messages)
|
||||||
|
TextSpan(text: message, style: titleMedium)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_initScaffoldState() {
|
_initScaffoldState() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback(
|
WidgetsBinding.instance.addPostFrameCallback(
|
||||||
(_) {
|
(_) {
|
||||||
if (!context.mounted) return;
|
if (!mounted) return;
|
||||||
final commonScaffoldState =
|
final commonScaffoldState =
|
||||||
context.findAncestorStateOfType<CommonScaffoldState>();
|
context.findAncestorStateOfType<CommonScaffoldState>();
|
||||||
commonScaffoldState?.actions = [
|
commonScaffoldState?.actions = [
|
||||||
@@ -87,6 +93,24 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
|||||||
},
|
},
|
||||||
icon: const Icon(Icons.sync),
|
icon: const Icon(Icons.sync),
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 8,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
final profiles = globalState.appController.config.profiles;
|
||||||
|
showSheet(
|
||||||
|
title: appLocalizations.profilesSort,
|
||||||
|
context: context,
|
||||||
|
builder: (_) => SizedBox(
|
||||||
|
height: 400,
|
||||||
|
child: ReorderableProfiles(profiles: profiles),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.sort),
|
||||||
|
iconSize: 26,
|
||||||
|
),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -116,7 +140,7 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
|||||||
selector: (_, appState, config) => ProfilesSelectorState(
|
selector: (_, appState, config) => ProfilesSelectorState(
|
||||||
profiles: config.profiles,
|
profiles: config.profiles,
|
||||||
currentProfileId: config.currentProfileId,
|
currentProfileId: config.currentProfileId,
|
||||||
viewMode: appState.viewMode,
|
columns: other.getProfilesColumns(appState.viewWidth),
|
||||||
),
|
),
|
||||||
builder: (context, state, child) {
|
builder: (context, state, child) {
|
||||||
if (state.profiles.isEmpty) {
|
if (state.profiles.isEmpty) {
|
||||||
@@ -124,7 +148,6 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
|||||||
label: appLocalizations.nullProfileDesc,
|
label: appLocalizations.nullProfileDesc,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final columns = _getColumns(state.viewMode);
|
|
||||||
return Align(
|
return Align(
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
@@ -137,7 +160,7 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
|||||||
child: Grid(
|
child: Grid(
|
||||||
mainAxisSpacing: 16,
|
mainAxisSpacing: 16,
|
||||||
crossAxisSpacing: 16,
|
crossAxisSpacing: 16,
|
||||||
crossAxisCount: columns,
|
crossAxisCount: state.columns,
|
||||||
children: [
|
children: [
|
||||||
for (int i = 0; i < state.profiles.length; i++)
|
for (int i = 0; i < state.profiles.length; i++)
|
||||||
GridItem(
|
GridItem(
|
||||||
@@ -145,8 +168,7 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
|||||||
key: Key(state.profiles[i].id),
|
key: Key(state.profiles[i].id),
|
||||||
profile: state.profiles[i],
|
profile: state.profiles[i],
|
||||||
groupValue: state.currentProfileId,
|
groupValue: state.currentProfileId,
|
||||||
onChanged:
|
onChanged: globalState.appController.changeProfile,
|
||||||
globalState.appController.changeProfile,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -204,7 +226,7 @@ class ProfileItem extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
await appController.updateProfile(profile);
|
await appController.updateProfile(profile);
|
||||||
if (profile.id == appController.config.currentProfile?.id) {
|
if (profile.id == appController.config.currentProfile?.id) {
|
||||||
appController.applyProfile(isPrue: true);
|
appController.applyProfileDebounce();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
config.setProfile(
|
config.setProfile(
|
||||||
@@ -244,6 +266,7 @@ class ProfileItem extends StatelessWidget {
|
|||||||
LinearProgressIndicator(
|
LinearProgressIndicator(
|
||||||
minHeight: 6,
|
minHeight: 6,
|
||||||
value: progress,
|
value: progress,
|
||||||
|
backgroundColor: context.colorScheme.primary.toSoft(),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 8,
|
height: 8,
|
||||||
@@ -372,3 +395,129 @@ class ProfileItem extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ReorderableProfiles extends StatefulWidget {
|
||||||
|
final List<Profile> profiles;
|
||||||
|
|
||||||
|
const ReorderableProfiles({
|
||||||
|
super.key,
|
||||||
|
required this.profiles,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ReorderableProfiles> createState() => _ReorderableProfilesState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ReorderableProfilesState extends State<ReorderableProfiles> {
|
||||||
|
late List<Profile> profiles;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
profiles = List.from(widget.profiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget proxyDecorator(
|
||||||
|
Widget child,
|
||||||
|
int index,
|
||||||
|
Animation<double> animation,
|
||||||
|
) {
|
||||||
|
final profile = profiles[index];
|
||||||
|
return AnimatedBuilder(
|
||||||
|
animation: animation,
|
||||||
|
builder: (_, Widget? child) {
|
||||||
|
final double animValue = Curves.easeInOut.transform(animation.value);
|
||||||
|
final double scale = lerpDouble(1, 1.02, animValue)!;
|
||||||
|
return Transform.scale(
|
||||||
|
scale: scale,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
key: Key(profile.id),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
child: CommonCard(
|
||||||
|
type: CommonCardType.filled,
|
||||||
|
child: ListTile(
|
||||||
|
contentPadding: const EdgeInsets.only(
|
||||||
|
right: 44,
|
||||||
|
left: 16,
|
||||||
|
),
|
||||||
|
title: Text(profile.label ?? profile.id),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: ReorderableListView.builder(
|
||||||
|
buildDefaultDragHandles: false,
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
proxyDecorator: proxyDecorator,
|
||||||
|
onReorder: (int oldIndex, int newIndex) {
|
||||||
|
if (oldIndex == newIndex) return;
|
||||||
|
setState(() {
|
||||||
|
if (oldIndex < newIndex) {
|
||||||
|
newIndex -= 1;
|
||||||
|
}
|
||||||
|
final profile = profiles.removeAt(oldIndex);
|
||||||
|
profiles.insert(newIndex, profile);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
itemBuilder: (_, index) {
|
||||||
|
final profile = profiles[index];
|
||||||
|
return Container(
|
||||||
|
key: Key(profile.id),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
child: CommonCard(
|
||||||
|
type: CommonCardType.filled,
|
||||||
|
child: ListTile(
|
||||||
|
contentPadding: const EdgeInsets.only(
|
||||||
|
right: 16,
|
||||||
|
left: 16,
|
||||||
|
),
|
||||||
|
title: Text(profile.label ?? profile.id),
|
||||||
|
trailing: ReorderableDragStartListener(
|
||||||
|
index: index,
|
||||||
|
child: const Icon(Icons.drag_handle),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemCount: profiles.length,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 8,
|
||||||
|
horizontal: 12,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
globalState.appController.config.profiles = profiles;
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.check,
|
||||||
|
),
|
||||||
|
iconSize: 32,
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -69,23 +69,21 @@ class ProxyCard extends StatelessWidget {
|
|||||||
if (type == ProxyCardType.min) {
|
if (type == ProxyCardType.min) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: measure.bodyMediumHeight * 1,
|
height: measure.bodyMediumHeight * 1,
|
||||||
child: Text(
|
child: EmojiText(
|
||||||
proxy.name,
|
proxy.name,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: measure.bodyMediumHeight * 2,
|
height: measure.bodyMediumHeight * 2,
|
||||||
child: Text(
|
child: EmojiText(
|
||||||
proxy.name,
|
proxy.name,
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -155,14 +153,12 @@ class ProxyCard extends StatelessWidget {
|
|||||||
proxy.name,
|
proxy.name,
|
||||||
),
|
),
|
||||||
builder: (_, desc, __) {
|
builder: (_, desc, __) {
|
||||||
return TooltipText(
|
return EmojiText(
|
||||||
text: Text(
|
desc,
|
||||||
desc,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
overflow: TextOverflow.ellipsis,
|
color: context.textTheme.bodySmall?.color
|
||||||
color: context.textTheme.bodySmall?.color
|
?.toLight(),
|
||||||
?.toLight(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:fl_clash/clash/clash.dart';
|
import 'package:fl_clash/clash/clash.dart';
|
||||||
|
import 'package:fl_clash/common/other.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:fl_clash/state.dart';
|
||||||
@@ -60,7 +61,10 @@ double getScrollToSelectedOffset({
|
|||||||
required List<Proxy> proxies,
|
required List<Proxy> proxies,
|
||||||
}) {
|
}) {
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
final columns = appController.columns;
|
final columns = other.getProxiesColumns(
|
||||||
|
appController.appState.viewWidth,
|
||||||
|
appController.config.proxiesLayout,
|
||||||
|
);
|
||||||
final proxyCardType = appController.config.proxyCardType;
|
final proxyCardType = appController.config.proxyCardType;
|
||||||
final selectedName = appController.getCurrentSelectedName(groupName);
|
final selectedName = appController.getCurrentSelectedName(groupName);
|
||||||
final findSelectedIndex = proxies.indexWhere(
|
final findSelectedIndex = proxies.indexWhere(
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
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/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
import 'package:fl_clash/widgets/card.dart';
|
import 'package:fl_clash/widgets/card.dart';
|
||||||
|
import 'package:fl_clash/widgets/fade_box.dart';
|
||||||
|
import 'package:fl_clash/widgets/text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
@@ -237,7 +240,10 @@ class _ProxiesListFragmentState extends State<ProxiesListFragment> {
|
|||||||
currentUnfoldSet: config.currentUnfoldSet,
|
currentUnfoldSet: config.currentUnfoldSet,
|
||||||
proxyCardType: config.proxyCardType,
|
proxyCardType: config.proxyCardType,
|
||||||
proxiesSortType: config.proxiesSortType,
|
proxiesSortType: config.proxiesSortType,
|
||||||
columns: globalState.appController.columns,
|
columns: other.getProxiesColumns(
|
||||||
|
appState.viewWidth,
|
||||||
|
config.proxiesLayout,
|
||||||
|
),
|
||||||
sortNum: appState.sortNum,
|
sortNum: appState.sortNum,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -349,6 +355,8 @@ class _ListHeaderState extends State<ListHeader>
|
|||||||
late Animation<double> _iconTurns;
|
late Animation<double> _iconTurns;
|
||||||
var isLock = false;
|
var isLock = false;
|
||||||
|
|
||||||
|
String get icon => widget.group.icon;
|
||||||
|
|
||||||
String get groupName => widget.group.name;
|
String get groupName => widget.group.name;
|
||||||
|
|
||||||
String get groupType => widget.group.type.name;
|
String get groupType => widget.group.type.name;
|
||||||
@@ -408,6 +416,7 @@ class _ListHeaderState extends State<ListHeader>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CommonCard(
|
return CommonCard(
|
||||||
key: widget.key,
|
key: widget.key,
|
||||||
|
radius: 24,
|
||||||
type: CommonCardType.filled,
|
type: CommonCardType.filled,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
@@ -415,57 +424,96 @@ class _ListHeaderState extends State<ListHeader>
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Column(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
const SizedBox(
|
||||||
groupName,
|
width: 4,
|
||||||
style: context.textTheme.titleMedium,
|
),
|
||||||
|
Container(
|
||||||
|
height: 48,
|
||||||
|
width: 48,
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: context.colorScheme.secondaryContainer,
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
child: icon.isNotEmpty
|
||||||
|
? CachedNetworkImage(
|
||||||
|
imageUrl: icon,
|
||||||
|
errorWidget: (_, __, ___) => const Icon(
|
||||||
|
IconsExt.target,
|
||||||
|
size: 32,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const Icon(
|
||||||
|
IconsExt.target,
|
||||||
|
size: 32,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 4,
|
width: 16,
|
||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
child: Column(
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
groupType,
|
groupName,
|
||||||
style: context.textTheme.labelMedium?.toLight,
|
style: context.textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 4,
|
||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: currentGroupProxyNameBuilder(
|
child: Row(
|
||||||
groupName: groupName,
|
mainAxisSize: MainAxisSize.min,
|
||||||
builder: (currentGroupName) {
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
return Row(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisSize: MainAxisSize.min,
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
Text(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
groupType,
|
||||||
children: [
|
style: context.textTheme.labelMedium?.toLight,
|
||||||
if (currentGroupName.isNotEmpty) ...[
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: Text(
|
child: currentGroupProxyNameBuilder(
|
||||||
overflow: TextOverflow.ellipsis,
|
groupName: groupName,
|
||||||
" · $currentGroupName",
|
builder: (currentGroupName) {
|
||||||
style: context
|
return Row(
|
||||||
.textTheme.labelMedium?.toLight,
|
mainAxisSize: MainAxisSize.min,
|
||||||
),
|
mainAxisAlignment:
|
||||||
),
|
MainAxisAlignment.start,
|
||||||
]
|
crossAxisAlignment:
|
||||||
],
|
CrossAxisAlignment.center,
|
||||||
);
|
children: [
|
||||||
},
|
if (currentGroupName.isNotEmpty) ...[
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: EmojiText(
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
" · $currentGroupName",
|
||||||
|
style: context.textTheme
|
||||||
|
.labelMedium?.toLight,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 4,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -68,19 +68,30 @@ class _ProvidersState extends State<Providers> {
|
|||||||
return Selector<AppState, List<ExternalProvider>>(
|
return Selector<AppState, List<ExternalProvider>>(
|
||||||
selector: (_, appState) => appState.providers,
|
selector: (_, appState) => appState.providers,
|
||||||
builder: (_, providers, ___) {
|
builder: (_, providers, ___) {
|
||||||
return ListView.separated(
|
final proxyProviders =
|
||||||
itemBuilder: (_, index) {
|
providers.where((item) => item.type == "Proxy").map(
|
||||||
return ProviderItem(
|
(item) => ProviderItem(
|
||||||
provider: providers[index],
|
provider: item,
|
||||||
);
|
),
|
||||||
},
|
);
|
||||||
separatorBuilder: (_, index) {
|
final ruleProviders =
|
||||||
return const Divider(
|
providers.where((item) => item.type == "Rule").map(
|
||||||
height: 0,
|
(item) => ProviderItem(
|
||||||
);
|
provider: item,
|
||||||
},
|
),
|
||||||
itemCount: providers.length,
|
);
|
||||||
|
final proxySection = generateSection(
|
||||||
|
title: appLocalizations.proxyProviders,
|
||||||
|
items: proxyProviders,
|
||||||
);
|
);
|
||||||
|
final ruleSection = generateSection(
|
||||||
|
title: appLocalizations.ruleProviders,
|
||||||
|
items: ruleProviders,
|
||||||
|
);
|
||||||
|
return generateListView([
|
||||||
|
...proxySection,
|
||||||
|
...ruleSection,
|
||||||
|
]);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class _ProxiesFragmentState extends State<ProxiesFragment> {
|
|||||||
extendPageWidth: 360,
|
extendPageWidth: 360,
|
||||||
context,
|
context,
|
||||||
body: const Providers(),
|
body: const Providers(),
|
||||||
title: appLocalizations.externalResources,
|
title: appLocalizations.providers,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
|
|||||||
@@ -33,6 +33,14 @@ class ProxiesSettingWidget extends StatelessWidget {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getTextForProxiesLayout(ProxiesLayout proxiesLayout) {
|
||||||
|
return switch (proxiesLayout) {
|
||||||
|
ProxiesLayout.tight => appLocalizations.tight,
|
||||||
|
ProxiesLayout.standard => appLocalizations.standard,
|
||||||
|
ProxiesLayout.loose => appLocalizations.loose,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
List<Widget> _buildStyleSetting() {
|
List<Widget> _buildStyleSetting() {
|
||||||
return generateSection(
|
return generateSection(
|
||||||
title: appLocalizations.style,
|
title: appLocalizations.style,
|
||||||
@@ -132,36 +140,28 @@ class ProxiesSettingWidget extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildColumnsSetting() {
|
List<Widget> _buildLayoutSetting() {
|
||||||
return generateSection(
|
return generateSection(
|
||||||
title: appLocalizations.columns,
|
title: appLocalizations.layout,
|
||||||
items: [
|
items: [
|
||||||
SingleChildScrollView(
|
SingleChildScrollView(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 16,
|
horizontal: 16,
|
||||||
),
|
),
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: Selector2<AppState, Config, ColumnsSelectorState>(
|
child: Selector< Config, ProxiesLayout>(
|
||||||
selector: (_, appState, config) => ColumnsSelectorState(
|
selector: (_, config) => config.proxiesLayout,
|
||||||
columns: config.proxiesColumns,
|
builder: (_, proxiesLayout, __) {
|
||||||
viewMode: appState.viewMode,
|
|
||||||
),
|
|
||||||
builder: (_, state, __) {
|
|
||||||
final config = globalState.appController.config;
|
final config = globalState.appController.config;
|
||||||
final targetColumnsArray = viewModeColumnsMap[state.viewMode]!;
|
|
||||||
final currentColumns = other.getColumns(
|
|
||||||
state.viewMode,
|
|
||||||
state.columns,
|
|
||||||
);
|
|
||||||
return Wrap(
|
return Wrap(
|
||||||
spacing: 16,
|
spacing: 16,
|
||||||
children: [
|
children: [
|
||||||
for (final item in targetColumnsArray)
|
for (final item in ProxiesLayout.values)
|
||||||
SettingTextCard(
|
SettingTextCard(
|
||||||
other.getColumnsTextForInt(item),
|
getTextForProxiesLayout(item),
|
||||||
isSelected: item == currentColumns,
|
isSelected: item == proxiesLayout,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
config.proxiesColumns = item;
|
config.proxiesLayout = item;
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@@ -183,10 +183,10 @@ class ProxiesSettingWidget extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
..._buildStyleSetting(),
|
..._buildStyleSetting(),
|
||||||
..._buildSortSetting(),
|
..._buildSortSetting(),
|
||||||
..._buildColumnsSetting(),
|
..._buildLayoutSetting(),
|
||||||
..._buildSizeSetting(),
|
..._buildSizeSetting(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,7 +284,10 @@ class ProxyGroupViewState extends State<ProxyGroupView> {
|
|||||||
return ProxyGroupSelectorState(
|
return ProxyGroupSelectorState(
|
||||||
proxyCardType: config.proxyCardType,
|
proxyCardType: config.proxyCardType,
|
||||||
proxiesSortType: config.proxiesSortType,
|
proxiesSortType: config.proxiesSortType,
|
||||||
columns: globalState.appController.columns,
|
columns: other.getProxiesColumns(
|
||||||
|
appState.viewWidth,
|
||||||
|
config.proxiesLayout,
|
||||||
|
),
|
||||||
sortNum: appState.sortNum,
|
sortNum: appState.sortNum,
|
||||||
proxies: group.all,
|
proxies: group.all,
|
||||||
groupType: group.type,
|
groupType: group.type,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import 'package:fl_clash/enum/enum.dart';
|
|||||||
import 'package:fl_clash/fragments/about.dart';
|
import 'package:fl_clash/fragments/about.dart';
|
||||||
import 'package:fl_clash/fragments/access.dart';
|
import 'package:fl_clash/fragments/access.dart';
|
||||||
import 'package:fl_clash/fragments/application_setting.dart';
|
import 'package:fl_clash/fragments/application_setting.dart';
|
||||||
import 'package:fl_clash/fragments/config.dart';
|
import 'package:fl_clash/fragments/config/config.dart';
|
||||||
import 'package:fl_clash/l10n/l10n.dart';
|
import 'package:fl_clash/l10n/l10n.dart';
|
||||||
import 'package:fl_clash/models/models.dart';
|
import 'package:fl_clash/models/models.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
@@ -82,44 +82,23 @@ class _ToolboxFragmentState extends State<ToolsFragment> {
|
|||||||
builder: (_, localeString, __) {
|
builder: (_, localeString, __) {
|
||||||
final subTitle = localeString ?? appLocalizations.defaultText;
|
final subTitle = localeString ?? appLocalizations.defaultText;
|
||||||
final currentLocale = other.getLocaleForString(localeString);
|
final currentLocale = other.getLocaleForString(localeString);
|
||||||
return ListTile(
|
return ListItem<Locale?>.options(
|
||||||
leading: const Icon(Icons.language_outlined),
|
leading: const Icon(Icons.language_outlined),
|
||||||
title: Text(appLocalizations.language),
|
title: Text(appLocalizations.language),
|
||||||
subtitle: Text(Intl.message(subTitle)),
|
subtitle: Text(Intl.message(subTitle)),
|
||||||
onTap: () {
|
delegate: OptionsDelegate(
|
||||||
globalState.showCommonDialog(
|
title: appLocalizations.language,
|
||||||
child: AlertDialog(
|
options: [
|
||||||
title: Text(appLocalizations.language),
|
null,
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
...AppLocalizations.delegate.supportedLocales
|
||||||
horizontal: 8,
|
],
|
||||||
vertical: 16,
|
onChanged: (Locale? value) {
|
||||||
),
|
final config = context.read<Config>();
|
||||||
content: SizedBox(
|
config.locale = value?.toString();
|
||||||
width: 250,
|
},
|
||||||
child: Wrap(
|
textBuilder: (locale) => _getLocaleString(locale),
|
||||||
children: [
|
value: currentLocale,
|
||||||
for (final locale in [
|
),
|
||||||
null,
|
|
||||||
...AppLocalizations.delegate.supportedLocales
|
|
||||||
])
|
|
||||||
ListItem.radio(
|
|
||||||
delegate: RadioDelegate<Locale?>(
|
|
||||||
value: locale,
|
|
||||||
groupValue: currentLocale,
|
|
||||||
onChanged: (Locale? value) {
|
|
||||||
final config = context.read<Config>();
|
|
||||||
config.locale = value?.toString();
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
title: Text(_getLocaleString(locale)),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -159,11 +138,10 @@ class _ToolboxFragmentState extends State<ToolsFragment> {
|
|||||||
delegate: OpenDelegate(
|
delegate: OpenDelegate(
|
||||||
title: appLocalizations.override,
|
title: appLocalizations.override,
|
||||||
widget: const ConfigFragment(),
|
widget: const ConfigFragment(),
|
||||||
extendPageWidth: 360,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
ListItem.open(
|
ListItem.open(
|
||||||
leading: const Icon(Icons.settings_applications),
|
leading: const Icon(Icons.settings),
|
||||||
title: Text(appLocalizations.application),
|
title: Text(appLocalizations.application),
|
||||||
subtitle: Text(appLocalizations.applicationDesc),
|
subtitle: Text(appLocalizations.applicationDesc),
|
||||||
delegate: OpenDelegate(
|
delegate: OpenDelegate(
|
||||||
|
|||||||
@@ -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",
|
||||||
@@ -236,5 +236,55 @@
|
|||||||
"action": "Action",
|
"action": "Action",
|
||||||
"intelligentSelected": "Intelligent selection",
|
"intelligentSelected": "Intelligent selection",
|
||||||
"clipboardImport": "Clipboard import",
|
"clipboardImport": "Clipboard import",
|
||||||
"clipboardExport": "Export clipboard"
|
"clipboardExport": "Export clipboard",
|
||||||
|
"layout": "Layout",
|
||||||
|
"tight": "Tight",
|
||||||
|
"standard": "Standard",
|
||||||
|
"loose": "Loose",
|
||||||
|
"profilesSort": "Profiles sort",
|
||||||
|
"start": "Start",
|
||||||
|
"stop": "Stop",
|
||||||
|
"appDesc": "Processing app related settings",
|
||||||
|
"vpnDesc": "Modify VPN related settings",
|
||||||
|
"generalDesc": "Overwrite general settings",
|
||||||
|
"dnsDesc": "Update DNS related settings",
|
||||||
|
"key": "Key",
|
||||||
|
"value": "Value",
|
||||||
|
"keyNotEmpty": "The key cannot be empty",
|
||||||
|
"valueNotEmpty": "The value cannot be empty",
|
||||||
|
"hostsDesc": "Add Hosts",
|
||||||
|
"vpnTip": "Changes take effect after restarting the VPN",
|
||||||
|
"vpnEnableDesc": "Auto routes all system traffic through VpnService",
|
||||||
|
"options": "Options",
|
||||||
|
"loopback": "Loopback unlock tool",
|
||||||
|
"loopbackDesc": "Used for UWP loopback unlocking",
|
||||||
|
"providers": "Providers",
|
||||||
|
"proxyProviders": "Proxy providers",
|
||||||
|
"ruleProviders": "Rule providers",
|
||||||
|
"overrideDns": "Override Dns",
|
||||||
|
"overrideDnsDesc": "Turning it on will override the DNS options in the profile",
|
||||||
|
"status": "Status",
|
||||||
|
"statusDesc": "System DNS will be used when turned off",
|
||||||
|
"preferH3Desc": "Prioritize the use of DOH's http/3",
|
||||||
|
"respectRules": "Respect rules",
|
||||||
|
"respectRulesDesc": "DNS connection following rules, need to configure proxy-server-nameserver",
|
||||||
|
"dnsMode": "DNS mode",
|
||||||
|
"fakeipRange": "Fakeip range",
|
||||||
|
"fakeipFilter": "Fakeip filter",
|
||||||
|
"defaultNameserver": "Default nameserver",
|
||||||
|
"defaultNameserverDesc": "For resolving DNS server",
|
||||||
|
"nameserver": "Nameserver",
|
||||||
|
"nameserverDesc": "For resolving domain",
|
||||||
|
"useHosts": "Use hosts",
|
||||||
|
"useSystemHosts": "Use system hosts",
|
||||||
|
"nameserverPolicy": "Nameserver policy",
|
||||||
|
"nameserverPolicyDesc": "Specify the corresponding nameserver policy",
|
||||||
|
"proxyNameserver": "Proxy nameserver",
|
||||||
|
"proxyNameserverDesc": "Domain for resolving proxy nodes",
|
||||||
|
"fallback": "Fallback",
|
||||||
|
"fallbackDesc": "Generally use offshore DNS",
|
||||||
|
"fallbackFilter": "Fallback filter",
|
||||||
|
"geoipCode": "Geoip code",
|
||||||
|
"ipcidr": "Ipcidr",
|
||||||
|
"domain": "Domain"
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"overrideDesc": "覆写代理相关配置",
|
"overrideDesc": "覆写代理相关配置",
|
||||||
"allowLan": "局域网代理",
|
"allowLan": "局域网代理",
|
||||||
"allowLanDesc": "允许通过局域网访问代理",
|
"allowLanDesc": "允许通过局域网访问代理",
|
||||||
"tun": "TUN模式",
|
"tun": "虚拟网卡",
|
||||||
"tunDesc": "仅在管理员模式生效",
|
"tunDesc": "仅在管理员模式生效",
|
||||||
"minimizeOnExit": "退出时最小化",
|
"minimizeOnExit": "退出时最小化",
|
||||||
"minimizeOnExitDesc": "修改系统默认退出事件",
|
"minimizeOnExitDesc": "修改系统默认退出事件",
|
||||||
@@ -236,5 +236,55 @@
|
|||||||
"action": "操作",
|
"action": "操作",
|
||||||
"intelligentSelected": "智能选择",
|
"intelligentSelected": "智能选择",
|
||||||
"clipboardImport": "剪贴板导入",
|
"clipboardImport": "剪贴板导入",
|
||||||
"clipboardExport": "导出剪贴板"
|
"clipboardExport": "导出剪贴板",
|
||||||
|
"layout": "布局",
|
||||||
|
"tight": "宽松",
|
||||||
|
"standard": "标准",
|
||||||
|
"loose": "紧凑",
|
||||||
|
"profilesSort": "配置排序",
|
||||||
|
"start": "启动",
|
||||||
|
"stop": "暂停",
|
||||||
|
"appDesc": "处理应用相关设置",
|
||||||
|
"vpnDesc": "修改VPN相关设置",
|
||||||
|
"generalDesc": "覆写基础设置",
|
||||||
|
"dnsDesc": "更新DNS相关设置",
|
||||||
|
"key": "键",
|
||||||
|
"value": "值",
|
||||||
|
"keyNotEmpty": "键不能为空",
|
||||||
|
"valueNotEmpty": "值不能为空",
|
||||||
|
"hostsDesc": "追加Hosts",
|
||||||
|
"vpnTip": "重启VPN后改变生效",
|
||||||
|
"vpnEnableDesc": "通过VpnService自动路由系统所有流量",
|
||||||
|
"options": "选项",
|
||||||
|
"loopback": "回环解锁工具",
|
||||||
|
"loopbackDesc": "用于UWP回环解锁",
|
||||||
|
"providers": "提供者",
|
||||||
|
"proxyProviders": "代理提供者",
|
||||||
|
"ruleProviders": "规则提供者",
|
||||||
|
"overrideDns": "覆写DNS",
|
||||||
|
"overrideDnsDesc": "开启后将覆盖配置中的DNS选项",
|
||||||
|
"status": "状态",
|
||||||
|
"statusDesc": "关闭后将使用系统DNS",
|
||||||
|
"preferH3Desc": "优先使用DOH的http/3",
|
||||||
|
"respectRules": "遵守规则",
|
||||||
|
"respectRulesDesc": "DNS连接跟随rules,需配置proxy-server-nameserver",
|
||||||
|
"dnsMode": "DNS模式",
|
||||||
|
"fakeipRange": "Fakeip范围",
|
||||||
|
"fakeipFilter": "Fakeip过滤",
|
||||||
|
"defaultNameserver": "默认域名服务器",
|
||||||
|
"defaultNameserverDesc": "用于解析DNS服务器",
|
||||||
|
"nameserver": "域名服务器",
|
||||||
|
"nameserverDesc": "用于解析域名",
|
||||||
|
"useHosts": "使用Hosts",
|
||||||
|
"useSystemHosts": "使用系统Hosts",
|
||||||
|
"nameserverPolicy": "域名服务器策略",
|
||||||
|
"nameserverPolicyDesc": "指定对应域名服务器策略",
|
||||||
|
"proxyNameserver": "代理域名服务器",
|
||||||
|
"proxyNameserverDesc": "用于解析代理节点的域名",
|
||||||
|
"fallback": "Fallback",
|
||||||
|
"fallbackDesc": "一般情况下使用境外DNS",
|
||||||
|
"fallbackFilter": "Fallback过滤",
|
||||||
|
"geoipCode": "Geoip代码",
|
||||||
|
"ipcidr": "IP/掩码",
|
||||||
|
"domain": "域名"
|
||||||
}
|
}
|
||||||
@@ -52,6 +52,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"app": MessageLookupByLibrary.simpleMessage("App"),
|
"app": MessageLookupByLibrary.simpleMessage("App"),
|
||||||
"appAccessControl":
|
"appAccessControl":
|
||||||
MessageLookupByLibrary.simpleMessage("App access control"),
|
MessageLookupByLibrary.simpleMessage("App access control"),
|
||||||
|
"appDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
|
"Processing app related settings"),
|
||||||
"application": MessageLookupByLibrary.simpleMessage("Application"),
|
"application": MessageLookupByLibrary.simpleMessage("Application"),
|
||||||
"applicationDesc": MessageLookupByLibrary.simpleMessage(
|
"applicationDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"Modify application related settings"),
|
"Modify application related settings"),
|
||||||
@@ -114,6 +116,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"dark": MessageLookupByLibrary.simpleMessage("Dark"),
|
"dark": MessageLookupByLibrary.simpleMessage("Dark"),
|
||||||
"dashboard": MessageLookupByLibrary.simpleMessage("Dashboard"),
|
"dashboard": MessageLookupByLibrary.simpleMessage("Dashboard"),
|
||||||
"days": MessageLookupByLibrary.simpleMessage("Days"),
|
"days": MessageLookupByLibrary.simpleMessage("Days"),
|
||||||
|
"defaultNameserver":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Default nameserver"),
|
||||||
|
"defaultNameserverDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("For resolving DNS server"),
|
||||||
"defaultSort": MessageLookupByLibrary.simpleMessage("Sort by default"),
|
"defaultSort": MessageLookupByLibrary.simpleMessage("Sort by default"),
|
||||||
"defaultText": MessageLookupByLibrary.simpleMessage("Default"),
|
"defaultText": MessageLookupByLibrary.simpleMessage("Default"),
|
||||||
"delay": MessageLookupByLibrary.simpleMessage("Delay"),
|
"delay": MessageLookupByLibrary.simpleMessage("Delay"),
|
||||||
@@ -128,8 +134,12 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
MessageLookupByLibrary.simpleMessage("Discover the new version"),
|
MessageLookupByLibrary.simpleMessage("Discover the new version"),
|
||||||
"discovery":
|
"discovery":
|
||||||
MessageLookupByLibrary.simpleMessage("Discovery a new version"),
|
MessageLookupByLibrary.simpleMessage("Discovery a new version"),
|
||||||
|
"dnsDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Update DNS related settings"),
|
||||||
|
"dnsMode": MessageLookupByLibrary.simpleMessage("DNS mode"),
|
||||||
"doYouWantToPass":
|
"doYouWantToPass":
|
||||||
MessageLookupByLibrary.simpleMessage("Do you want to pass"),
|
MessageLookupByLibrary.simpleMessage("Do you want to pass"),
|
||||||
|
"domain": MessageLookupByLibrary.simpleMessage("Domain"),
|
||||||
"download": MessageLookupByLibrary.simpleMessage("Download"),
|
"download": MessageLookupByLibrary.simpleMessage("Download"),
|
||||||
"edit": MessageLookupByLibrary.simpleMessage("Edit"),
|
"edit": MessageLookupByLibrary.simpleMessage("Edit"),
|
||||||
"en": MessageLookupByLibrary.simpleMessage("English"),
|
"en": MessageLookupByLibrary.simpleMessage("English"),
|
||||||
@@ -149,6 +159,13 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"externalLink": MessageLookupByLibrary.simpleMessage("External link"),
|
"externalLink": MessageLookupByLibrary.simpleMessage("External link"),
|
||||||
"externalResources":
|
"externalResources":
|
||||||
MessageLookupByLibrary.simpleMessage("External resources"),
|
MessageLookupByLibrary.simpleMessage("External resources"),
|
||||||
|
"fakeipFilter": MessageLookupByLibrary.simpleMessage("Fakeip filter"),
|
||||||
|
"fakeipRange": MessageLookupByLibrary.simpleMessage("Fakeip range"),
|
||||||
|
"fallback": MessageLookupByLibrary.simpleMessage("Fallback"),
|
||||||
|
"fallbackDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Generally use offshore DNS"),
|
||||||
|
"fallbackFilter":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Fallback filter"),
|
||||||
"file": MessageLookupByLibrary.simpleMessage("File"),
|
"file": MessageLookupByLibrary.simpleMessage("File"),
|
||||||
"fileDesc":
|
"fileDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("Directly upload profile"),
|
MessageLookupByLibrary.simpleMessage("Directly upload profile"),
|
||||||
@@ -159,14 +176,18 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"There is a risk of flashback after opening"),
|
"There is a risk of flashback after opening"),
|
||||||
"fourColumns": MessageLookupByLibrary.simpleMessage("Four columns"),
|
"fourColumns": MessageLookupByLibrary.simpleMessage("Four columns"),
|
||||||
"general": MessageLookupByLibrary.simpleMessage("General"),
|
"general": MessageLookupByLibrary.simpleMessage("General"),
|
||||||
|
"generalDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Overwrite general settings"),
|
||||||
"geoData": MessageLookupByLibrary.simpleMessage("GeoData"),
|
"geoData": MessageLookupByLibrary.simpleMessage("GeoData"),
|
||||||
"geodataLoader":
|
"geodataLoader":
|
||||||
MessageLookupByLibrary.simpleMessage("Geo Low Memory Mode"),
|
MessageLookupByLibrary.simpleMessage("Geo Low Memory Mode"),
|
||||||
"geodataLoaderDesc": MessageLookupByLibrary.simpleMessage(
|
"geodataLoaderDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"Enabling will use the Geo low memory loader"),
|
"Enabling will use the Geo low memory loader"),
|
||||||
|
"geoipCode": MessageLookupByLibrary.simpleMessage("Geoip code"),
|
||||||
"global": MessageLookupByLibrary.simpleMessage("Global"),
|
"global": MessageLookupByLibrary.simpleMessage("Global"),
|
||||||
"go": MessageLookupByLibrary.simpleMessage("Go"),
|
"go": MessageLookupByLibrary.simpleMessage("Go"),
|
||||||
"goDownload": MessageLookupByLibrary.simpleMessage("Go to download"),
|
"goDownload": MessageLookupByLibrary.simpleMessage("Go to download"),
|
||||||
|
"hostsDesc": MessageLookupByLibrary.simpleMessage("Add Hosts"),
|
||||||
"hours": MessageLookupByLibrary.simpleMessage("Hours"),
|
"hours": MessageLookupByLibrary.simpleMessage("Hours"),
|
||||||
"importFromURL":
|
"importFromURL":
|
||||||
MessageLookupByLibrary.simpleMessage("Import from URL"),
|
MessageLookupByLibrary.simpleMessage("Import from URL"),
|
||||||
@@ -176,12 +197,17 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"intelligentSelected":
|
"intelligentSelected":
|
||||||
MessageLookupByLibrary.simpleMessage("Intelligent selection"),
|
MessageLookupByLibrary.simpleMessage("Intelligent selection"),
|
||||||
"intranetIP": MessageLookupByLibrary.simpleMessage("Intranet IP"),
|
"intranetIP": MessageLookupByLibrary.simpleMessage("Intranet IP"),
|
||||||
|
"ipcidr": MessageLookupByLibrary.simpleMessage("Ipcidr"),
|
||||||
"ipv6Desc": MessageLookupByLibrary.simpleMessage(
|
"ipv6Desc": MessageLookupByLibrary.simpleMessage(
|
||||||
"When turned on it will be able to receive IPv6 traffic"),
|
"When turned on it will be able to receive IPv6 traffic"),
|
||||||
"just": MessageLookupByLibrary.simpleMessage("Just"),
|
"just": MessageLookupByLibrary.simpleMessage("Just"),
|
||||||
"keepAliveIntervalDesc":
|
"keepAliveIntervalDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("Tcp keep alive interval"),
|
MessageLookupByLibrary.simpleMessage("Tcp keep alive interval"),
|
||||||
|
"key": MessageLookupByLibrary.simpleMessage("Key"),
|
||||||
|
"keyNotEmpty":
|
||||||
|
MessageLookupByLibrary.simpleMessage("The key cannot be empty"),
|
||||||
"language": MessageLookupByLibrary.simpleMessage("Language"),
|
"language": MessageLookupByLibrary.simpleMessage("Language"),
|
||||||
|
"layout": MessageLookupByLibrary.simpleMessage("Layout"),
|
||||||
"light": MessageLookupByLibrary.simpleMessage("Light"),
|
"light": MessageLookupByLibrary.simpleMessage("Light"),
|
||||||
"list": MessageLookupByLibrary.simpleMessage("List"),
|
"list": MessageLookupByLibrary.simpleMessage("List"),
|
||||||
"local": MessageLookupByLibrary.simpleMessage("Local"),
|
"local": MessageLookupByLibrary.simpleMessage("Local"),
|
||||||
@@ -195,6 +221,11 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"Disabling will hide the log entry"),
|
"Disabling will hide the log entry"),
|
||||||
"logs": MessageLookupByLibrary.simpleMessage("Logs"),
|
"logs": MessageLookupByLibrary.simpleMessage("Logs"),
|
||||||
"logsDesc": MessageLookupByLibrary.simpleMessage("Log capture records"),
|
"logsDesc": MessageLookupByLibrary.simpleMessage("Log capture records"),
|
||||||
|
"loopback":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Loopback unlock tool"),
|
||||||
|
"loopbackDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
|
"Used for UWP loopback unlocking"),
|
||||||
|
"loose": MessageLookupByLibrary.simpleMessage("Loose"),
|
||||||
"min": MessageLookupByLibrary.simpleMessage("Min"),
|
"min": MessageLookupByLibrary.simpleMessage("Min"),
|
||||||
"minimizeOnExit":
|
"minimizeOnExit":
|
||||||
MessageLookupByLibrary.simpleMessage("Minimize on exit"),
|
MessageLookupByLibrary.simpleMessage("Minimize on exit"),
|
||||||
@@ -206,6 +237,13 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"more": MessageLookupByLibrary.simpleMessage("More"),
|
"more": MessageLookupByLibrary.simpleMessage("More"),
|
||||||
"name": MessageLookupByLibrary.simpleMessage("Name"),
|
"name": MessageLookupByLibrary.simpleMessage("Name"),
|
||||||
"nameSort": MessageLookupByLibrary.simpleMessage("Sort by name"),
|
"nameSort": MessageLookupByLibrary.simpleMessage("Sort by name"),
|
||||||
|
"nameserver": MessageLookupByLibrary.simpleMessage("Nameserver"),
|
||||||
|
"nameserverDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("For resolving domain"),
|
||||||
|
"nameserverPolicy":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Nameserver policy"),
|
||||||
|
"nameserverPolicyDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
|
"Specify the corresponding nameserver policy"),
|
||||||
"networkDetection":
|
"networkDetection":
|
||||||
MessageLookupByLibrary.simpleMessage("Network detection"),
|
MessageLookupByLibrary.simpleMessage("Network detection"),
|
||||||
"networkSpeed": MessageLookupByLibrary.simpleMessage("Network speed"),
|
"networkSpeed": MessageLookupByLibrary.simpleMessage("Network speed"),
|
||||||
@@ -231,6 +269,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
MessageLookupByLibrary.simpleMessage("Only statistics proxy"),
|
MessageLookupByLibrary.simpleMessage("Only statistics proxy"),
|
||||||
"onlyStatisticsProxyDesc": MessageLookupByLibrary.simpleMessage(
|
"onlyStatisticsProxyDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"When turned on, only statistics proxy traffic"),
|
"When turned on, only statistics proxy traffic"),
|
||||||
|
"options": MessageLookupByLibrary.simpleMessage("Options"),
|
||||||
"other": MessageLookupByLibrary.simpleMessage("Other"),
|
"other": MessageLookupByLibrary.simpleMessage("Other"),
|
||||||
"otherContributors":
|
"otherContributors":
|
||||||
MessageLookupByLibrary.simpleMessage("Other contributors"),
|
MessageLookupByLibrary.simpleMessage("Other contributors"),
|
||||||
@@ -238,6 +277,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"override": MessageLookupByLibrary.simpleMessage("Override"),
|
"override": MessageLookupByLibrary.simpleMessage("Override"),
|
||||||
"overrideDesc": MessageLookupByLibrary.simpleMessage(
|
"overrideDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"Override Proxy related config"),
|
"Override Proxy related config"),
|
||||||
|
"overrideDns": MessageLookupByLibrary.simpleMessage("Override Dns"),
|
||||||
|
"overrideDnsDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
|
"Turning it on will override the DNS options in the profile"),
|
||||||
"password": MessageLookupByLibrary.simpleMessage("Password"),
|
"password": MessageLookupByLibrary.simpleMessage("Password"),
|
||||||
"passwordTip":
|
"passwordTip":
|
||||||
MessageLookupByLibrary.simpleMessage("Password cannot be empty"),
|
MessageLookupByLibrary.simpleMessage("Password cannot be empty"),
|
||||||
@@ -249,6 +291,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"pleaseUploadValidQrcode": MessageLookupByLibrary.simpleMessage(
|
"pleaseUploadValidQrcode": MessageLookupByLibrary.simpleMessage(
|
||||||
"Please upload a valid QR code"),
|
"Please upload a valid QR code"),
|
||||||
"port": MessageLookupByLibrary.simpleMessage("Port"),
|
"port": MessageLookupByLibrary.simpleMessage("Port"),
|
||||||
|
"preferH3Desc": MessageLookupByLibrary.simpleMessage(
|
||||||
|
"Prioritize the use of DOH\'s http/3"),
|
||||||
"preview": MessageLookupByLibrary.simpleMessage("Preview"),
|
"preview": MessageLookupByLibrary.simpleMessage("Preview"),
|
||||||
"profile": MessageLookupByLibrary.simpleMessage("Profile"),
|
"profile": MessageLookupByLibrary.simpleMessage("Profile"),
|
||||||
"profileAutoUpdateIntervalInvalidValidationDesc":
|
"profileAutoUpdateIntervalInvalidValidationDesc":
|
||||||
@@ -266,14 +310,22 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"profileUrlNullValidationDesc": MessageLookupByLibrary.simpleMessage(
|
"profileUrlNullValidationDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"Please input the profile URL"),
|
"Please input the profile URL"),
|
||||||
"profiles": MessageLookupByLibrary.simpleMessage("Profiles"),
|
"profiles": MessageLookupByLibrary.simpleMessage("Profiles"),
|
||||||
|
"profilesSort": MessageLookupByLibrary.simpleMessage("Profiles sort"),
|
||||||
"project": MessageLookupByLibrary.simpleMessage("Project"),
|
"project": MessageLookupByLibrary.simpleMessage("Project"),
|
||||||
|
"providers": MessageLookupByLibrary.simpleMessage("Providers"),
|
||||||
"proxies": MessageLookupByLibrary.simpleMessage("Proxies"),
|
"proxies": MessageLookupByLibrary.simpleMessage("Proxies"),
|
||||||
"proxiesSetting":
|
"proxiesSetting":
|
||||||
MessageLookupByLibrary.simpleMessage("Proxies setting"),
|
MessageLookupByLibrary.simpleMessage("Proxies setting"),
|
||||||
"proxyGroup": MessageLookupByLibrary.simpleMessage("Proxy group"),
|
"proxyGroup": MessageLookupByLibrary.simpleMessage("Proxy group"),
|
||||||
|
"proxyNameserver":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Proxy nameserver"),
|
||||||
|
"proxyNameserverDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
|
"Domain for resolving proxy nodes"),
|
||||||
"proxyPort": MessageLookupByLibrary.simpleMessage("ProxyPort"),
|
"proxyPort": MessageLookupByLibrary.simpleMessage("ProxyPort"),
|
||||||
"proxyPortDesc": MessageLookupByLibrary.simpleMessage(
|
"proxyPortDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"Set the Clash listening port"),
|
"Set the Clash listening port"),
|
||||||
|
"proxyProviders":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Proxy providers"),
|
||||||
"prueBlackMode":
|
"prueBlackMode":
|
||||||
MessageLookupByLibrary.simpleMessage("Prue black mode"),
|
MessageLookupByLibrary.simpleMessage("Prue black mode"),
|
||||||
"qrcode": MessageLookupByLibrary.simpleMessage("QR code"),
|
"qrcode": MessageLookupByLibrary.simpleMessage("QR code"),
|
||||||
@@ -297,7 +349,11 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"resources": MessageLookupByLibrary.simpleMessage("Resources"),
|
"resources": MessageLookupByLibrary.simpleMessage("Resources"),
|
||||||
"resourcesDesc": MessageLookupByLibrary.simpleMessage(
|
"resourcesDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
"External resource related info"),
|
"External resource related info"),
|
||||||
|
"respectRules": MessageLookupByLibrary.simpleMessage("Respect rules"),
|
||||||
|
"respectRulesDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
|
"DNS connection following rules, need to configure proxy-server-nameserver"),
|
||||||
"rule": MessageLookupByLibrary.simpleMessage("Rule"),
|
"rule": MessageLookupByLibrary.simpleMessage("Rule"),
|
||||||
|
"ruleProviders": MessageLookupByLibrary.simpleMessage("Rule providers"),
|
||||||
"save": MessageLookupByLibrary.simpleMessage("Save"),
|
"save": MessageLookupByLibrary.simpleMessage("Save"),
|
||||||
"search": MessageLookupByLibrary.simpleMessage("Search"),
|
"search": MessageLookupByLibrary.simpleMessage("Search"),
|
||||||
"seconds": MessageLookupByLibrary.simpleMessage("Seconds"),
|
"seconds": MessageLookupByLibrary.simpleMessage("Seconds"),
|
||||||
@@ -312,12 +368,18 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"size": MessageLookupByLibrary.simpleMessage("Size"),
|
"size": MessageLookupByLibrary.simpleMessage("Size"),
|
||||||
"sort": MessageLookupByLibrary.simpleMessage("Sort"),
|
"sort": MessageLookupByLibrary.simpleMessage("Sort"),
|
||||||
"source": MessageLookupByLibrary.simpleMessage("Source"),
|
"source": MessageLookupByLibrary.simpleMessage("Source"),
|
||||||
|
"standard": MessageLookupByLibrary.simpleMessage("Standard"),
|
||||||
|
"start": MessageLookupByLibrary.simpleMessage("Start"),
|
||||||
"startVpn": MessageLookupByLibrary.simpleMessage("Staring VPN..."),
|
"startVpn": MessageLookupByLibrary.simpleMessage("Staring VPN..."),
|
||||||
|
"status": MessageLookupByLibrary.simpleMessage("Status"),
|
||||||
|
"statusDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
|
"System DNS will be used when turned off"),
|
||||||
|
"stop": MessageLookupByLibrary.simpleMessage("Stop"),
|
||||||
"stopVpn": MessageLookupByLibrary.simpleMessage("Stopping VPN..."),
|
"stopVpn": MessageLookupByLibrary.simpleMessage("Stopping VPN..."),
|
||||||
"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"),
|
||||||
@@ -334,11 +396,12 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"Set dark mode,adjust the color"),
|
"Set dark mode,adjust the color"),
|
||||||
"themeMode": MessageLookupByLibrary.simpleMessage("Theme mode"),
|
"themeMode": MessageLookupByLibrary.simpleMessage("Theme mode"),
|
||||||
"threeColumns": MessageLookupByLibrary.simpleMessage("Three columns"),
|
"threeColumns": MessageLookupByLibrary.simpleMessage("Three columns"),
|
||||||
|
"tight": MessageLookupByLibrary.simpleMessage("Tight"),
|
||||||
"time": MessageLookupByLibrary.simpleMessage("Time"),
|
"time": MessageLookupByLibrary.simpleMessage("Time"),
|
||||||
"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"),
|
||||||
@@ -354,7 +417,19 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"url": MessageLookupByLibrary.simpleMessage("URL"),
|
"url": MessageLookupByLibrary.simpleMessage("URL"),
|
||||||
"urlDesc":
|
"urlDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("Obtain profile through URL"),
|
MessageLookupByLibrary.simpleMessage("Obtain profile through URL"),
|
||||||
|
"useHosts": MessageLookupByLibrary.simpleMessage("Use hosts"),
|
||||||
|
"useSystemHosts":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Use system hosts"),
|
||||||
|
"value": MessageLookupByLibrary.simpleMessage("Value"),
|
||||||
|
"valueNotEmpty":
|
||||||
|
MessageLookupByLibrary.simpleMessage("The value cannot be empty"),
|
||||||
"view": MessageLookupByLibrary.simpleMessage("View"),
|
"view": MessageLookupByLibrary.simpleMessage("View"),
|
||||||
|
"vpnDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("Modify VPN related settings"),
|
||||||
|
"vpnEnableDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
|
"Auto routes all system traffic through VpnService"),
|
||||||
|
"vpnTip": MessageLookupByLibrary.simpleMessage(
|
||||||
|
"Changes take effect after restarting the VPN"),
|
||||||
"webDAVConfiguration":
|
"webDAVConfiguration":
|
||||||
MessageLookupByLibrary.simpleMessage("WebDAV configuration"),
|
MessageLookupByLibrary.simpleMessage("WebDAV configuration"),
|
||||||
"whitelistMode": MessageLookupByLibrary.simpleMessage("Whitelist mode"),
|
"whitelistMode": MessageLookupByLibrary.simpleMessage("Whitelist mode"),
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"allowLanDesc": MessageLookupByLibrary.simpleMessage("允许通过局域网访问代理"),
|
"allowLanDesc": MessageLookupByLibrary.simpleMessage("允许通过局域网访问代理"),
|
||||||
"app": MessageLookupByLibrary.simpleMessage("应用"),
|
"app": MessageLookupByLibrary.simpleMessage("应用"),
|
||||||
"appAccessControl": MessageLookupByLibrary.simpleMessage("应用访问控制"),
|
"appAccessControl": MessageLookupByLibrary.simpleMessage("应用访问控制"),
|
||||||
|
"appDesc": MessageLookupByLibrary.simpleMessage("处理应用相关设置"),
|
||||||
"application": MessageLookupByLibrary.simpleMessage("应用程序"),
|
"application": MessageLookupByLibrary.simpleMessage("应用程序"),
|
||||||
"applicationDesc": MessageLookupByLibrary.simpleMessage("修改应用程序相关设置"),
|
"applicationDesc": MessageLookupByLibrary.simpleMessage("修改应用程序相关设置"),
|
||||||
"auto": MessageLookupByLibrary.simpleMessage("自动"),
|
"auto": MessageLookupByLibrary.simpleMessage("自动"),
|
||||||
@@ -94,6 +95,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"dark": MessageLookupByLibrary.simpleMessage("深色"),
|
"dark": MessageLookupByLibrary.simpleMessage("深色"),
|
||||||
"dashboard": MessageLookupByLibrary.simpleMessage("仪表盘"),
|
"dashboard": MessageLookupByLibrary.simpleMessage("仪表盘"),
|
||||||
"days": MessageLookupByLibrary.simpleMessage("天"),
|
"days": MessageLookupByLibrary.simpleMessage("天"),
|
||||||
|
"defaultNameserver": MessageLookupByLibrary.simpleMessage("默认域名服务器"),
|
||||||
|
"defaultNameserverDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("用于解析DNS服务器"),
|
||||||
"defaultSort": MessageLookupByLibrary.simpleMessage("按默认排序"),
|
"defaultSort": MessageLookupByLibrary.simpleMessage("按默认排序"),
|
||||||
"defaultText": MessageLookupByLibrary.simpleMessage("默认"),
|
"defaultText": MessageLookupByLibrary.simpleMessage("默认"),
|
||||||
"delay": MessageLookupByLibrary.simpleMessage("延迟"),
|
"delay": MessageLookupByLibrary.simpleMessage("延迟"),
|
||||||
@@ -105,7 +109,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"direct": MessageLookupByLibrary.simpleMessage("直连"),
|
"direct": MessageLookupByLibrary.simpleMessage("直连"),
|
||||||
"discoverNewVersion": MessageLookupByLibrary.simpleMessage("发现新版本"),
|
"discoverNewVersion": MessageLookupByLibrary.simpleMessage("发现新版本"),
|
||||||
"discovery": MessageLookupByLibrary.simpleMessage("发现新版本"),
|
"discovery": MessageLookupByLibrary.simpleMessage("发现新版本"),
|
||||||
|
"dnsDesc": MessageLookupByLibrary.simpleMessage("更新DNS相关设置"),
|
||||||
|
"dnsMode": MessageLookupByLibrary.simpleMessage("DNS模式"),
|
||||||
"doYouWantToPass": MessageLookupByLibrary.simpleMessage("是否要通过"),
|
"doYouWantToPass": MessageLookupByLibrary.simpleMessage("是否要通过"),
|
||||||
|
"domain": MessageLookupByLibrary.simpleMessage("域名"),
|
||||||
"download": MessageLookupByLibrary.simpleMessage("下载"),
|
"download": MessageLookupByLibrary.simpleMessage("下载"),
|
||||||
"edit": MessageLookupByLibrary.simpleMessage("编辑"),
|
"edit": MessageLookupByLibrary.simpleMessage("编辑"),
|
||||||
"en": MessageLookupByLibrary.simpleMessage("英语"),
|
"en": MessageLookupByLibrary.simpleMessage("英语"),
|
||||||
@@ -121,6 +128,11 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
MessageLookupByLibrary.simpleMessage("开启后将可以通过9090端口控制Clash内核"),
|
MessageLookupByLibrary.simpleMessage("开启后将可以通过9090端口控制Clash内核"),
|
||||||
"externalLink": MessageLookupByLibrary.simpleMessage("外部链接"),
|
"externalLink": MessageLookupByLibrary.simpleMessage("外部链接"),
|
||||||
"externalResources": MessageLookupByLibrary.simpleMessage("外部资源"),
|
"externalResources": MessageLookupByLibrary.simpleMessage("外部资源"),
|
||||||
|
"fakeipFilter": MessageLookupByLibrary.simpleMessage("Fakeip过滤"),
|
||||||
|
"fakeipRange": MessageLookupByLibrary.simpleMessage("Fakeip范围"),
|
||||||
|
"fallback": MessageLookupByLibrary.simpleMessage("Fallback"),
|
||||||
|
"fallbackDesc": MessageLookupByLibrary.simpleMessage("一般情况下使用境外DNS"),
|
||||||
|
"fallbackFilter": MessageLookupByLibrary.simpleMessage("Fallback过滤"),
|
||||||
"file": MessageLookupByLibrary.simpleMessage("文件"),
|
"file": MessageLookupByLibrary.simpleMessage("文件"),
|
||||||
"fileDesc": MessageLookupByLibrary.simpleMessage("直接上传配置文件"),
|
"fileDesc": MessageLookupByLibrary.simpleMessage("直接上传配置文件"),
|
||||||
"filterSystemApp": MessageLookupByLibrary.simpleMessage("过滤系统应用"),
|
"filterSystemApp": MessageLookupByLibrary.simpleMessage("过滤系统应用"),
|
||||||
@@ -129,24 +141,31 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
MessageLookupByLibrary.simpleMessage("开启后存在闪退风险"),
|
MessageLookupByLibrary.simpleMessage("开启后存在闪退风险"),
|
||||||
"fourColumns": MessageLookupByLibrary.simpleMessage("四列"),
|
"fourColumns": MessageLookupByLibrary.simpleMessage("四列"),
|
||||||
"general": MessageLookupByLibrary.simpleMessage("基础"),
|
"general": MessageLookupByLibrary.simpleMessage("基础"),
|
||||||
|
"generalDesc": MessageLookupByLibrary.simpleMessage("覆写基础设置"),
|
||||||
"geoData": MessageLookupByLibrary.simpleMessage("地理数据"),
|
"geoData": MessageLookupByLibrary.simpleMessage("地理数据"),
|
||||||
"geodataLoader": MessageLookupByLibrary.simpleMessage("Geo低内存模式"),
|
"geodataLoader": MessageLookupByLibrary.simpleMessage("Geo低内存模式"),
|
||||||
"geodataLoaderDesc":
|
"geodataLoaderDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("开启将使用Geo低内存加载器"),
|
MessageLookupByLibrary.simpleMessage("开启将使用Geo低内存加载器"),
|
||||||
|
"geoipCode": MessageLookupByLibrary.simpleMessage("Geoip代码"),
|
||||||
"global": MessageLookupByLibrary.simpleMessage("全局"),
|
"global": MessageLookupByLibrary.simpleMessage("全局"),
|
||||||
"go": MessageLookupByLibrary.simpleMessage("前往"),
|
"go": MessageLookupByLibrary.simpleMessage("前往"),
|
||||||
"goDownload": MessageLookupByLibrary.simpleMessage("前往下载"),
|
"goDownload": MessageLookupByLibrary.simpleMessage("前往下载"),
|
||||||
|
"hostsDesc": MessageLookupByLibrary.simpleMessage("追加Hosts"),
|
||||||
"hours": MessageLookupByLibrary.simpleMessage("小时"),
|
"hours": MessageLookupByLibrary.simpleMessage("小时"),
|
||||||
"importFromURL": MessageLookupByLibrary.simpleMessage("从URL导入"),
|
"importFromURL": MessageLookupByLibrary.simpleMessage("从URL导入"),
|
||||||
"infiniteTime": MessageLookupByLibrary.simpleMessage("长期有效"),
|
"infiniteTime": MessageLookupByLibrary.simpleMessage("长期有效"),
|
||||||
"init": MessageLookupByLibrary.simpleMessage("初始化"),
|
"init": MessageLookupByLibrary.simpleMessage("初始化"),
|
||||||
"intelligentSelected": MessageLookupByLibrary.simpleMessage("智能选择"),
|
"intelligentSelected": MessageLookupByLibrary.simpleMessage("智能选择"),
|
||||||
"intranetIP": MessageLookupByLibrary.simpleMessage("内网 IP"),
|
"intranetIP": MessageLookupByLibrary.simpleMessage("内网 IP"),
|
||||||
|
"ipcidr": MessageLookupByLibrary.simpleMessage("IP/掩码"),
|
||||||
"ipv6Desc": MessageLookupByLibrary.simpleMessage("开启后将可以接收IPv6流量"),
|
"ipv6Desc": MessageLookupByLibrary.simpleMessage("开启后将可以接收IPv6流量"),
|
||||||
"just": MessageLookupByLibrary.simpleMessage("刚刚"),
|
"just": MessageLookupByLibrary.simpleMessage("刚刚"),
|
||||||
"keepAliveIntervalDesc":
|
"keepAliveIntervalDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("TCP保持活动间隔"),
|
MessageLookupByLibrary.simpleMessage("TCP保持活动间隔"),
|
||||||
|
"key": MessageLookupByLibrary.simpleMessage("键"),
|
||||||
|
"keyNotEmpty": MessageLookupByLibrary.simpleMessage("键不能为空"),
|
||||||
"language": MessageLookupByLibrary.simpleMessage("语言"),
|
"language": MessageLookupByLibrary.simpleMessage("语言"),
|
||||||
|
"layout": MessageLookupByLibrary.simpleMessage("布局"),
|
||||||
"light": MessageLookupByLibrary.simpleMessage("浅色"),
|
"light": MessageLookupByLibrary.simpleMessage("浅色"),
|
||||||
"list": MessageLookupByLibrary.simpleMessage("列表"),
|
"list": MessageLookupByLibrary.simpleMessage("列表"),
|
||||||
"local": MessageLookupByLibrary.simpleMessage("本地"),
|
"local": MessageLookupByLibrary.simpleMessage("本地"),
|
||||||
@@ -157,6 +176,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"logcatDesc": MessageLookupByLibrary.simpleMessage("禁用将会隐藏日志入口"),
|
"logcatDesc": MessageLookupByLibrary.simpleMessage("禁用将会隐藏日志入口"),
|
||||||
"logs": MessageLookupByLibrary.simpleMessage("日志"),
|
"logs": MessageLookupByLibrary.simpleMessage("日志"),
|
||||||
"logsDesc": MessageLookupByLibrary.simpleMessage("日志捕获记录"),
|
"logsDesc": MessageLookupByLibrary.simpleMessage("日志捕获记录"),
|
||||||
|
"loopback": MessageLookupByLibrary.simpleMessage("回环解锁工具"),
|
||||||
|
"loopbackDesc": MessageLookupByLibrary.simpleMessage("用于UWP回环解锁"),
|
||||||
|
"loose": MessageLookupByLibrary.simpleMessage("紧凑"),
|
||||||
"min": MessageLookupByLibrary.simpleMessage("最小"),
|
"min": MessageLookupByLibrary.simpleMessage("最小"),
|
||||||
"minimizeOnExit": MessageLookupByLibrary.simpleMessage("退出时最小化"),
|
"minimizeOnExit": MessageLookupByLibrary.simpleMessage("退出时最小化"),
|
||||||
"minimizeOnExitDesc":
|
"minimizeOnExitDesc":
|
||||||
@@ -167,6 +189,11 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"more": MessageLookupByLibrary.simpleMessage("更多"),
|
"more": MessageLookupByLibrary.simpleMessage("更多"),
|
||||||
"name": MessageLookupByLibrary.simpleMessage("名称"),
|
"name": MessageLookupByLibrary.simpleMessage("名称"),
|
||||||
"nameSort": MessageLookupByLibrary.simpleMessage("按名称排序"),
|
"nameSort": MessageLookupByLibrary.simpleMessage("按名称排序"),
|
||||||
|
"nameserver": MessageLookupByLibrary.simpleMessage("域名服务器"),
|
||||||
|
"nameserverDesc": MessageLookupByLibrary.simpleMessage("用于解析域名"),
|
||||||
|
"nameserverPolicy": MessageLookupByLibrary.simpleMessage("域名服务器策略"),
|
||||||
|
"nameserverPolicyDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("指定对应域名服务器策略"),
|
||||||
"networkDetection": MessageLookupByLibrary.simpleMessage("网络检测"),
|
"networkDetection": MessageLookupByLibrary.simpleMessage("网络检测"),
|
||||||
"networkSpeed": MessageLookupByLibrary.simpleMessage("网络速度"),
|
"networkSpeed": MessageLookupByLibrary.simpleMessage("网络速度"),
|
||||||
"noInfo": MessageLookupByLibrary.simpleMessage("暂无信息"),
|
"noInfo": MessageLookupByLibrary.simpleMessage("暂无信息"),
|
||||||
@@ -186,11 +213,15 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"onlyStatisticsProxy": MessageLookupByLibrary.simpleMessage("仅统计代理"),
|
"onlyStatisticsProxy": MessageLookupByLibrary.simpleMessage("仅统计代理"),
|
||||||
"onlyStatisticsProxyDesc":
|
"onlyStatisticsProxyDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("开启后,将只统计代理流量"),
|
MessageLookupByLibrary.simpleMessage("开启后,将只统计代理流量"),
|
||||||
|
"options": MessageLookupByLibrary.simpleMessage("选项"),
|
||||||
"other": MessageLookupByLibrary.simpleMessage("其他"),
|
"other": MessageLookupByLibrary.simpleMessage("其他"),
|
||||||
"otherContributors": MessageLookupByLibrary.simpleMessage("其他贡献者"),
|
"otherContributors": MessageLookupByLibrary.simpleMessage("其他贡献者"),
|
||||||
"outboundMode": MessageLookupByLibrary.simpleMessage("出站模式"),
|
"outboundMode": MessageLookupByLibrary.simpleMessage("出站模式"),
|
||||||
"override": MessageLookupByLibrary.simpleMessage("覆写"),
|
"override": MessageLookupByLibrary.simpleMessage("覆写"),
|
||||||
"overrideDesc": MessageLookupByLibrary.simpleMessage("覆写代理相关配置"),
|
"overrideDesc": MessageLookupByLibrary.simpleMessage("覆写代理相关配置"),
|
||||||
|
"overrideDns": MessageLookupByLibrary.simpleMessage("覆写DNS"),
|
||||||
|
"overrideDnsDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("开启后将覆盖配置中的DNS选项"),
|
||||||
"password": MessageLookupByLibrary.simpleMessage("密码"),
|
"password": MessageLookupByLibrary.simpleMessage("密码"),
|
||||||
"passwordTip": MessageLookupByLibrary.simpleMessage("密码不能为空"),
|
"passwordTip": MessageLookupByLibrary.simpleMessage("密码不能为空"),
|
||||||
"paste": MessageLookupByLibrary.simpleMessage("粘贴"),
|
"paste": MessageLookupByLibrary.simpleMessage("粘贴"),
|
||||||
@@ -199,6 +230,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"pleaseUploadValidQrcode":
|
"pleaseUploadValidQrcode":
|
||||||
MessageLookupByLibrary.simpleMessage("请上传有效的二维码"),
|
MessageLookupByLibrary.simpleMessage("请上传有效的二维码"),
|
||||||
"port": MessageLookupByLibrary.simpleMessage("端口"),
|
"port": MessageLookupByLibrary.simpleMessage("端口"),
|
||||||
|
"preferH3Desc": MessageLookupByLibrary.simpleMessage("优先使用DOH的http/3"),
|
||||||
"preview": MessageLookupByLibrary.simpleMessage("预览"),
|
"preview": MessageLookupByLibrary.simpleMessage("预览"),
|
||||||
"profile": MessageLookupByLibrary.simpleMessage("配置"),
|
"profile": MessageLookupByLibrary.simpleMessage("配置"),
|
||||||
"profileAutoUpdateIntervalInvalidValidationDesc":
|
"profileAutoUpdateIntervalInvalidValidationDesc":
|
||||||
@@ -214,12 +246,18 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"profileUrlNullValidationDesc":
|
"profileUrlNullValidationDesc":
|
||||||
MessageLookupByLibrary.simpleMessage("请输入配置URL"),
|
MessageLookupByLibrary.simpleMessage("请输入配置URL"),
|
||||||
"profiles": MessageLookupByLibrary.simpleMessage("配置"),
|
"profiles": MessageLookupByLibrary.simpleMessage("配置"),
|
||||||
|
"profilesSort": MessageLookupByLibrary.simpleMessage("配置排序"),
|
||||||
"project": MessageLookupByLibrary.simpleMessage("项目"),
|
"project": MessageLookupByLibrary.simpleMessage("项目"),
|
||||||
|
"providers": MessageLookupByLibrary.simpleMessage("提供者"),
|
||||||
"proxies": MessageLookupByLibrary.simpleMessage("代理"),
|
"proxies": MessageLookupByLibrary.simpleMessage("代理"),
|
||||||
"proxiesSetting": MessageLookupByLibrary.simpleMessage("代理设置"),
|
"proxiesSetting": MessageLookupByLibrary.simpleMessage("代理设置"),
|
||||||
"proxyGroup": MessageLookupByLibrary.simpleMessage("代理组"),
|
"proxyGroup": MessageLookupByLibrary.simpleMessage("代理组"),
|
||||||
|
"proxyNameserver": MessageLookupByLibrary.simpleMessage("代理域名服务器"),
|
||||||
|
"proxyNameserverDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("用于解析代理节点的域名"),
|
||||||
"proxyPort": MessageLookupByLibrary.simpleMessage("代理端口"),
|
"proxyPort": MessageLookupByLibrary.simpleMessage("代理端口"),
|
||||||
"proxyPortDesc": MessageLookupByLibrary.simpleMessage("设置Clash监听端口"),
|
"proxyPortDesc": MessageLookupByLibrary.simpleMessage("设置Clash监听端口"),
|
||||||
|
"proxyProviders": MessageLookupByLibrary.simpleMessage("代理提供者"),
|
||||||
"prueBlackMode": MessageLookupByLibrary.simpleMessage("纯黑模式"),
|
"prueBlackMode": MessageLookupByLibrary.simpleMessage("纯黑模式"),
|
||||||
"qrcode": MessageLookupByLibrary.simpleMessage("二维码"),
|
"qrcode": MessageLookupByLibrary.simpleMessage("二维码"),
|
||||||
"qrcodeDesc": MessageLookupByLibrary.simpleMessage("扫描二维码获取配置文件"),
|
"qrcodeDesc": MessageLookupByLibrary.simpleMessage("扫描二维码获取配置文件"),
|
||||||
@@ -235,7 +273,11 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"requestsDesc": MessageLookupByLibrary.simpleMessage("查看最近请求记录"),
|
"requestsDesc": MessageLookupByLibrary.simpleMessage("查看最近请求记录"),
|
||||||
"resources": MessageLookupByLibrary.simpleMessage("资源"),
|
"resources": MessageLookupByLibrary.simpleMessage("资源"),
|
||||||
"resourcesDesc": MessageLookupByLibrary.simpleMessage("外部资源相关信息"),
|
"resourcesDesc": MessageLookupByLibrary.simpleMessage("外部资源相关信息"),
|
||||||
|
"respectRules": MessageLookupByLibrary.simpleMessage("遵守规则"),
|
||||||
|
"respectRulesDesc": MessageLookupByLibrary.simpleMessage(
|
||||||
|
"DNS连接跟随rules,需配置proxy-server-nameserver"),
|
||||||
"rule": MessageLookupByLibrary.simpleMessage("规则"),
|
"rule": MessageLookupByLibrary.simpleMessage("规则"),
|
||||||
|
"ruleProviders": MessageLookupByLibrary.simpleMessage("规则提供者"),
|
||||||
"save": MessageLookupByLibrary.simpleMessage("保存"),
|
"save": MessageLookupByLibrary.simpleMessage("保存"),
|
||||||
"search": MessageLookupByLibrary.simpleMessage("搜索"),
|
"search": MessageLookupByLibrary.simpleMessage("搜索"),
|
||||||
"seconds": MessageLookupByLibrary.simpleMessage("秒"),
|
"seconds": MessageLookupByLibrary.simpleMessage("秒"),
|
||||||
@@ -249,7 +291,12 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"size": MessageLookupByLibrary.simpleMessage("尺寸"),
|
"size": MessageLookupByLibrary.simpleMessage("尺寸"),
|
||||||
"sort": MessageLookupByLibrary.simpleMessage("排序"),
|
"sort": MessageLookupByLibrary.simpleMessage("排序"),
|
||||||
"source": MessageLookupByLibrary.simpleMessage("来源"),
|
"source": MessageLookupByLibrary.simpleMessage("来源"),
|
||||||
|
"standard": MessageLookupByLibrary.simpleMessage("标准"),
|
||||||
|
"start": MessageLookupByLibrary.simpleMessage("启动"),
|
||||||
"startVpn": MessageLookupByLibrary.simpleMessage("正在启动VPN..."),
|
"startVpn": MessageLookupByLibrary.simpleMessage("正在启动VPN..."),
|
||||||
|
"status": MessageLookupByLibrary.simpleMessage("状态"),
|
||||||
|
"statusDesc": MessageLookupByLibrary.simpleMessage("关闭后将使用系统DNS"),
|
||||||
|
"stop": MessageLookupByLibrary.simpleMessage("暂停"),
|
||||||
"stopVpn": MessageLookupByLibrary.simpleMessage("正在停止VPN..."),
|
"stopVpn": MessageLookupByLibrary.simpleMessage("正在停止VPN..."),
|
||||||
"style": MessageLookupByLibrary.simpleMessage("风格"),
|
"style": MessageLookupByLibrary.simpleMessage("风格"),
|
||||||
"submit": MessageLookupByLibrary.simpleMessage("提交"),
|
"submit": MessageLookupByLibrary.simpleMessage("提交"),
|
||||||
@@ -269,11 +316,12 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"themeDesc": MessageLookupByLibrary.simpleMessage("设置深色模式,调整色彩"),
|
"themeDesc": MessageLookupByLibrary.simpleMessage("设置深色模式,调整色彩"),
|
||||||
"themeMode": MessageLookupByLibrary.simpleMessage("主题模式"),
|
"themeMode": MessageLookupByLibrary.simpleMessage("主题模式"),
|
||||||
"threeColumns": MessageLookupByLibrary.simpleMessage("三列"),
|
"threeColumns": MessageLookupByLibrary.simpleMessage("三列"),
|
||||||
|
"tight": MessageLookupByLibrary.simpleMessage("宽松"),
|
||||||
"time": MessageLookupByLibrary.simpleMessage("时间"),
|
"time": MessageLookupByLibrary.simpleMessage("时间"),
|
||||||
"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":
|
||||||
@@ -285,7 +333,15 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"upload": MessageLookupByLibrary.simpleMessage("上传"),
|
"upload": MessageLookupByLibrary.simpleMessage("上传"),
|
||||||
"url": MessageLookupByLibrary.simpleMessage("URL"),
|
"url": MessageLookupByLibrary.simpleMessage("URL"),
|
||||||
"urlDesc": MessageLookupByLibrary.simpleMessage("通过URL获取配置文件"),
|
"urlDesc": MessageLookupByLibrary.simpleMessage("通过URL获取配置文件"),
|
||||||
|
"useHosts": MessageLookupByLibrary.simpleMessage("使用Hosts"),
|
||||||
|
"useSystemHosts": MessageLookupByLibrary.simpleMessage("使用系统Hosts"),
|
||||||
|
"value": MessageLookupByLibrary.simpleMessage("值"),
|
||||||
|
"valueNotEmpty": MessageLookupByLibrary.simpleMessage("值不能为空"),
|
||||||
"view": MessageLookupByLibrary.simpleMessage("查看"),
|
"view": MessageLookupByLibrary.simpleMessage("查看"),
|
||||||
|
"vpnDesc": MessageLookupByLibrary.simpleMessage("修改VPN相关设置"),
|
||||||
|
"vpnEnableDesc":
|
||||||
|
MessageLookupByLibrary.simpleMessage("通过VpnService自动路由系统所有流量"),
|
||||||
|
"vpnTip": MessageLookupByLibrary.simpleMessage("重启VPN后改变生效"),
|
||||||
"webDAVConfiguration": MessageLookupByLibrary.simpleMessage("WebDAV配置"),
|
"webDAVConfiguration": MessageLookupByLibrary.simpleMessage("WebDAV配置"),
|
||||||
"whitelistMode": MessageLookupByLibrary.simpleMessage("白名单模式"),
|
"whitelistMode": MessageLookupByLibrary.simpleMessage("白名单模式"),
|
||||||
"years": MessageLookupByLibrary.simpleMessage("年"),
|
"years": MessageLookupByLibrary.simpleMessage("年"),
|
||||||
|
|||||||
@@ -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: [],
|
||||||
@@ -2429,6 +2429,506 @@ class AppLocalizations {
|
|||||||
args: [],
|
args: [],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `Layout`
|
||||||
|
String get layout {
|
||||||
|
return Intl.message(
|
||||||
|
'Layout',
|
||||||
|
name: 'layout',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Tight`
|
||||||
|
String get tight {
|
||||||
|
return Intl.message(
|
||||||
|
'Tight',
|
||||||
|
name: 'tight',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Standard`
|
||||||
|
String get standard {
|
||||||
|
return Intl.message(
|
||||||
|
'Standard',
|
||||||
|
name: 'standard',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Loose`
|
||||||
|
String get loose {
|
||||||
|
return Intl.message(
|
||||||
|
'Loose',
|
||||||
|
name: 'loose',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Profiles sort`
|
||||||
|
String get profilesSort {
|
||||||
|
return Intl.message(
|
||||||
|
'Profiles sort',
|
||||||
|
name: 'profilesSort',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Start`
|
||||||
|
String get start {
|
||||||
|
return Intl.message(
|
||||||
|
'Start',
|
||||||
|
name: 'start',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Stop`
|
||||||
|
String get stop {
|
||||||
|
return Intl.message(
|
||||||
|
'Stop',
|
||||||
|
name: 'stop',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Processing app related settings`
|
||||||
|
String get appDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Processing app related settings',
|
||||||
|
name: 'appDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Modify VPN related settings`
|
||||||
|
String get vpnDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Modify VPN related settings',
|
||||||
|
name: 'vpnDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Overwrite general settings`
|
||||||
|
String get generalDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Overwrite general settings',
|
||||||
|
name: 'generalDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Update DNS related settings`
|
||||||
|
String get dnsDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Update DNS related settings',
|
||||||
|
name: 'dnsDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Key`
|
||||||
|
String get key {
|
||||||
|
return Intl.message(
|
||||||
|
'Key',
|
||||||
|
name: 'key',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Value`
|
||||||
|
String get value {
|
||||||
|
return Intl.message(
|
||||||
|
'Value',
|
||||||
|
name: 'value',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `The key cannot be empty`
|
||||||
|
String get keyNotEmpty {
|
||||||
|
return Intl.message(
|
||||||
|
'The key cannot be empty',
|
||||||
|
name: 'keyNotEmpty',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `The value cannot be empty`
|
||||||
|
String get valueNotEmpty {
|
||||||
|
return Intl.message(
|
||||||
|
'The value cannot be empty',
|
||||||
|
name: 'valueNotEmpty',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Add Hosts`
|
||||||
|
String get hostsDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Add Hosts',
|
||||||
|
name: 'hostsDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Changes take effect after restarting the VPN`
|
||||||
|
String get vpnTip {
|
||||||
|
return Intl.message(
|
||||||
|
'Changes take effect after restarting the VPN',
|
||||||
|
name: 'vpnTip',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Auto routes all system traffic through VpnService`
|
||||||
|
String get vpnEnableDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Auto routes all system traffic through VpnService',
|
||||||
|
name: 'vpnEnableDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Options`
|
||||||
|
String get options {
|
||||||
|
return Intl.message(
|
||||||
|
'Options',
|
||||||
|
name: 'options',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Loopback unlock tool`
|
||||||
|
String get loopback {
|
||||||
|
return Intl.message(
|
||||||
|
'Loopback unlock tool',
|
||||||
|
name: 'loopback',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Used for UWP loopback unlocking`
|
||||||
|
String get loopbackDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Used for UWP loopback unlocking',
|
||||||
|
name: 'loopbackDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Providers`
|
||||||
|
String get providers {
|
||||||
|
return Intl.message(
|
||||||
|
'Providers',
|
||||||
|
name: 'providers',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Proxy providers`
|
||||||
|
String get proxyProviders {
|
||||||
|
return Intl.message(
|
||||||
|
'Proxy providers',
|
||||||
|
name: 'proxyProviders',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Rule providers`
|
||||||
|
String get ruleProviders {
|
||||||
|
return Intl.message(
|
||||||
|
'Rule providers',
|
||||||
|
name: 'ruleProviders',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Override Dns`
|
||||||
|
String get overrideDns {
|
||||||
|
return Intl.message(
|
||||||
|
'Override Dns',
|
||||||
|
name: 'overrideDns',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Turning it on will override the DNS options in the profile`
|
||||||
|
String get overrideDnsDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Turning it on will override the DNS options in the profile',
|
||||||
|
name: 'overrideDnsDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Status`
|
||||||
|
String get status {
|
||||||
|
return Intl.message(
|
||||||
|
'Status',
|
||||||
|
name: 'status',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `System DNS will be used when turned off`
|
||||||
|
String get statusDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'System DNS will be used when turned off',
|
||||||
|
name: 'statusDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Prioritize the use of DOH's http/3`
|
||||||
|
String get preferH3Desc {
|
||||||
|
return Intl.message(
|
||||||
|
'Prioritize the use of DOH\'s http/3',
|
||||||
|
name: 'preferH3Desc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Respect rules`
|
||||||
|
String get respectRules {
|
||||||
|
return Intl.message(
|
||||||
|
'Respect rules',
|
||||||
|
name: 'respectRules',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `DNS connection following rules, need to configure proxy-server-nameserver`
|
||||||
|
String get respectRulesDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'DNS connection following rules, need to configure proxy-server-nameserver',
|
||||||
|
name: 'respectRulesDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `DNS mode`
|
||||||
|
String get dnsMode {
|
||||||
|
return Intl.message(
|
||||||
|
'DNS mode',
|
||||||
|
name: 'dnsMode',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Fakeip range`
|
||||||
|
String get fakeipRange {
|
||||||
|
return Intl.message(
|
||||||
|
'Fakeip range',
|
||||||
|
name: 'fakeipRange',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Fakeip filter`
|
||||||
|
String get fakeipFilter {
|
||||||
|
return Intl.message(
|
||||||
|
'Fakeip filter',
|
||||||
|
name: 'fakeipFilter',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Default nameserver`
|
||||||
|
String get defaultNameserver {
|
||||||
|
return Intl.message(
|
||||||
|
'Default nameserver',
|
||||||
|
name: 'defaultNameserver',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `For resolving DNS server`
|
||||||
|
String get defaultNameserverDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'For resolving DNS server',
|
||||||
|
name: 'defaultNameserverDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Nameserver`
|
||||||
|
String get nameserver {
|
||||||
|
return Intl.message(
|
||||||
|
'Nameserver',
|
||||||
|
name: 'nameserver',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `For resolving domain`
|
||||||
|
String get nameserverDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'For resolving domain',
|
||||||
|
name: 'nameserverDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Use hosts`
|
||||||
|
String get useHosts {
|
||||||
|
return Intl.message(
|
||||||
|
'Use hosts',
|
||||||
|
name: 'useHosts',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Use system hosts`
|
||||||
|
String get useSystemHosts {
|
||||||
|
return Intl.message(
|
||||||
|
'Use system hosts',
|
||||||
|
name: 'useSystemHosts',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Nameserver policy`
|
||||||
|
String get nameserverPolicy {
|
||||||
|
return Intl.message(
|
||||||
|
'Nameserver policy',
|
||||||
|
name: 'nameserverPolicy',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Specify the corresponding nameserver policy`
|
||||||
|
String get nameserverPolicyDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Specify the corresponding nameserver policy',
|
||||||
|
name: 'nameserverPolicyDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Proxy nameserver`
|
||||||
|
String get proxyNameserver {
|
||||||
|
return Intl.message(
|
||||||
|
'Proxy nameserver',
|
||||||
|
name: 'proxyNameserver',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Domain for resolving proxy nodes`
|
||||||
|
String get proxyNameserverDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Domain for resolving proxy nodes',
|
||||||
|
name: 'proxyNameserverDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Fallback`
|
||||||
|
String get fallback {
|
||||||
|
return Intl.message(
|
||||||
|
'Fallback',
|
||||||
|
name: 'fallback',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Generally use offshore DNS`
|
||||||
|
String get fallbackDesc {
|
||||||
|
return Intl.message(
|
||||||
|
'Generally use offshore DNS',
|
||||||
|
name: 'fallbackDesc',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Fallback filter`
|
||||||
|
String get fallbackFilter {
|
||||||
|
return Intl.message(
|
||||||
|
'Fallback filter',
|
||||||
|
name: 'fallbackFilter',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Geoip code`
|
||||||
|
String get geoipCode {
|
||||||
|
return Intl.message(
|
||||||
|
'Geoip code',
|
||||||
|
name: 'geoipCode',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Ipcidr`
|
||||||
|
String get ipcidr {
|
||||||
|
return Intl.message(
|
||||||
|
'Ipcidr',
|
||||||
|
name: 'ipcidr',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Domain`
|
||||||
|
String get domain {
|
||||||
|
return Intl.message(
|
||||||
|
'Domain',
|
||||||
|
name: 'domain',
|
||||||
|
desc: '',
|
||||||
|
args: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppLocalizationDelegate extends LocalizationsDelegate<AppLocalizations> {
|
class AppLocalizationDelegate extends LocalizationsDelegate<AppLocalizations> {
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ import 'dart:async';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:fl_clash/clash/clash.dart';
|
import 'package:fl_clash/clash/clash.dart';
|
||||||
|
import 'package:fl_clash/common/http.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';
|
||||||
@@ -18,6 +19,7 @@ Future<void> main() async {
|
|||||||
clashCore.initMessage();
|
clashCore.initMessage();
|
||||||
globalState.packageInfo = await PackageInfo.fromPlatform();
|
globalState.packageInfo = await PackageInfo.fromPlatform();
|
||||||
final config = await preferences.getConfig() ?? Config();
|
final config = await preferences.getConfig() ?? Config();
|
||||||
|
globalState.autoRun = config.autoRun;
|
||||||
final clashConfig = await preferences.getClashConfig() ?? ClashConfig();
|
final clashConfig = await preferences.getClashConfig() ?? ClashConfig();
|
||||||
await android?.init();
|
await android?.init();
|
||||||
await window?.init(config.windowProps);
|
await window?.init(config.windowProps);
|
||||||
@@ -35,6 +37,7 @@ Future<void> main() async {
|
|||||||
config: config,
|
config: config,
|
||||||
clashConfig: clashConfig,
|
clashConfig: clashConfig,
|
||||||
);
|
);
|
||||||
|
HttpOverrides.global = FlClashHttpOverrides();
|
||||||
runAppWithPreferences(
|
runAppWithPreferences(
|
||||||
const Application(),
|
const Application(),
|
||||||
appState: appState,
|
appState: appState,
|
||||||
@@ -61,14 +64,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 +79,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 +103,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 +112,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);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -26,89 +26,91 @@ class Tun with _$Tun {
|
|||||||
factory Tun.fromJson(Map<String, Object?> json) => _$TunFromJson(json);
|
factory Tun.fromJson(Map<String, Object?> json) => _$TunFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonSerializable()
|
@freezed
|
||||||
class Dns {
|
class FallbackFilter with _$FallbackFilter {
|
||||||
bool enable;
|
const factory FallbackFilter({
|
||||||
bool ipv6;
|
@Default(true) bool geoip,
|
||||||
@JsonKey(name: "default-nameserver")
|
@Default("CN") @JsonKey(name: "geoip-code") String geoipCode,
|
||||||
List<String> defaultNameserver;
|
@Default(["gfw"]) List<String> geosite,
|
||||||
@JsonKey(name: "enhanced-mode")
|
@Default(["240.0.0.0/4"]) List<String> ipcidr,
|
||||||
String enhancedMode;
|
@Default([
|
||||||
@JsonKey(name: "fake-ip-range")
|
"+.google.com",
|
||||||
String fakeIpRange;
|
"+.facebook.com",
|
||||||
@JsonKey(name: "use-hosts")
|
"+.youtube.com",
|
||||||
bool useHosts;
|
])
|
||||||
List<String> nameserver;
|
List<String> domain,
|
||||||
List<String> fallback;
|
}) = _FallbackFilter;
|
||||||
@JsonKey(name: "fake-ip-filter")
|
|
||||||
List<String> fakeIpFilter;
|
|
||||||
|
|
||||||
Dns()
|
factory FallbackFilter.fromJson(Map<String, Object?> json) =>
|
||||||
: enable = true,
|
_$FallbackFilterFromJson(json);
|
||||||
ipv6 = false,
|
}
|
||||||
defaultNameserver = [
|
|
||||||
"223.5.5.5",
|
|
||||||
"119.29.29.29",
|
|
||||||
"8.8.4.4",
|
|
||||||
"1.0.0.1",
|
|
||||||
],
|
|
||||||
enhancedMode = "fake-ip",
|
|
||||||
fakeIpRange = "198.18.0.1/16",
|
|
||||||
useHosts = true,
|
|
||||||
nameserver = [
|
|
||||||
"8.8.8.8",
|
|
||||||
"114.114.114.114",
|
|
||||||
"https://doh.pub/dns-query",
|
|
||||||
"https://dns.alidns.com/dns-query",
|
|
||||||
],
|
|
||||||
fallback = [
|
|
||||||
'https://doh.dns.sb/dns-query',
|
|
||||||
'https://dns.cloudflare.com/dns-query',
|
|
||||||
'https://dns.twnic.tw/dns-query',
|
|
||||||
'tls://8.8.4.4:853',
|
|
||||||
],
|
|
||||||
fakeIpFilter = [
|
|
||||||
// Stun Services
|
|
||||||
"+.stun.*.*",
|
|
||||||
"+.stun.*.*.*",
|
|
||||||
"+.stun.*.*.*.*",
|
|
||||||
"+.stun.*.*.*.*.*",
|
|
||||||
|
|
||||||
// Google Voices
|
@freezed
|
||||||
"lens.l.google.com",
|
class Dns with _$Dns {
|
||||||
|
const factory Dns({
|
||||||
|
@Default(true) bool enable,
|
||||||
|
@Default(false) @JsonKey(name: "prefer-h3") bool preferH3,
|
||||||
|
@Default(true) @JsonKey(name: "use-hosts") bool useHosts,
|
||||||
|
@Default(true) @JsonKey(name: "use-system-hosts") bool useSystemHosts,
|
||||||
|
@Default(true) @JsonKey(name: "respect-rules") bool respectRules,
|
||||||
|
@Default(false) bool ipv6,
|
||||||
|
@Default(["223.5.5.5"])
|
||||||
|
@JsonKey(name: "default-nameserver")
|
||||||
|
List<String> defaultNameserver,
|
||||||
|
@Default(DnsMode.fakeIp)
|
||||||
|
@JsonKey(name: "enhanced-mode")
|
||||||
|
DnsMode enhancedMode,
|
||||||
|
@Default("198.18.0.1/16")
|
||||||
|
@JsonKey(name: "fake-ip-range")
|
||||||
|
String fakeIpRange,
|
||||||
|
@Default([
|
||||||
|
"*.lan",
|
||||||
|
"localhost.ptlogin2.qq.com",
|
||||||
|
])
|
||||||
|
@JsonKey(name: "fake-ip-filter")
|
||||||
|
List<String> fakeIpFilter,
|
||||||
|
@Default({
|
||||||
|
"www.baidu.com": "114.114.114.114",
|
||||||
|
"+.internal.crop.com": "10.0.0.1",
|
||||||
|
"geosite:cn": "https://doh.pub/dns-query"
|
||||||
|
})
|
||||||
|
@JsonKey(name: "nameserver-policy")
|
||||||
|
Map<String, String> nameserverPolicy,
|
||||||
|
@Default([
|
||||||
|
"https://doh.pub/dns-query",
|
||||||
|
"https://dns.alidns.com/dns-query",
|
||||||
|
])
|
||||||
|
List<String> nameserver,
|
||||||
|
@Default([
|
||||||
|
"tls://8.8.4.4",
|
||||||
|
"tls://1.1.1.1",
|
||||||
|
])
|
||||||
|
List<String> fallback,
|
||||||
|
@Default([
|
||||||
|
"https://doh.pub/dns-query",
|
||||||
|
])
|
||||||
|
@JsonKey(name: "proxy-server-nameserver")
|
||||||
|
List<String> proxyServerNameserver,
|
||||||
|
@Default(FallbackFilter())
|
||||||
|
@JsonKey(name: "fallback-filter")
|
||||||
|
FallbackFilter fallbackFilter,
|
||||||
|
}) = _Dns;
|
||||||
|
|
||||||
// Nintendo Switch STUN
|
factory Dns.fromJson(Map<String, Object?> json) => _$DnsFromJson(json);
|
||||||
"*.n.n.srv.nintendo.net",
|
|
||||||
|
|
||||||
// PlayStation STUN
|
factory Dns.safeDnsFromJson(Map<String, Object?> json) {
|
||||||
"+.stun.playstation.net",
|
try {
|
||||||
|
return Dns.fromJson(json);
|
||||||
// XBox
|
} catch (_) {
|
||||||
"xbox.*.*.microsoft.com",
|
return const Dns();
|
||||||
"*.*.xboxlive.com",
|
}
|
||||||
|
|
||||||
// Microsoft Captive Portal
|
|
||||||
"*.msftncsi.com",
|
|
||||||
"*.msftconnecttest.com",
|
|
||||||
|
|
||||||
// Bilibili CDN
|
|
||||||
"*.mcdn.bilivideo.cn",
|
|
||||||
|
|
||||||
// Windows Default LAN WorkGroup
|
|
||||||
"WORKGROUP",
|
|
||||||
];
|
|
||||||
|
|
||||||
factory Dns.fromJson(Map<String, dynamic> json) {
|
|
||||||
return _$DnsFromJson(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return _$DnsToJson(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef GeoXMap = Map<String, String>;
|
typedef GeoXMap = Map<String, String>;
|
||||||
|
|
||||||
|
typedef HostsMap = Map<String, String>;
|
||||||
|
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class ClashConfig extends ChangeNotifier {
|
class ClashConfig extends ChangeNotifier {
|
||||||
int _mixedPort;
|
int _mixedPort;
|
||||||
@@ -127,6 +129,7 @@ class ClashConfig extends ChangeNotifier {
|
|||||||
GeoXMap _geoXUrl;
|
GeoXMap _geoXUrl;
|
||||||
List<String> _rules;
|
List<String> _rules;
|
||||||
String? _globalRealUa;
|
String? _globalRealUa;
|
||||||
|
HostsMap _hosts;
|
||||||
|
|
||||||
ClashConfig()
|
ClashConfig()
|
||||||
: _mixedPort = 7890,
|
: _mixedPort = 7890,
|
||||||
@@ -141,9 +144,10 @@ class ClashConfig extends ChangeNotifier {
|
|||||||
_geodataLoader = geodataLoaderMemconservative,
|
_geodataLoader = geodataLoaderMemconservative,
|
||||||
_externalController = '',
|
_externalController = '',
|
||||||
_keepAliveInterval = 30,
|
_keepAliveInterval = 30,
|
||||||
_dns = Dns(),
|
_dns = const Dns(),
|
||||||
_geoXUrl = defaultGeoXMap,
|
_geoXUrl = defaultGeoXMap,
|
||||||
_rules = [];
|
_rules = [],
|
||||||
|
_hosts = {};
|
||||||
|
|
||||||
@JsonKey(name: "mixed-port", defaultValue: 7890)
|
@JsonKey(name: "mixed-port", defaultValue: 7890)
|
||||||
int get mixedPort => _mixedPort;
|
int get mixedPort => _mixedPort;
|
||||||
@@ -269,6 +273,7 @@ class ClashConfig extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonKey(fromJson: Dns.safeDnsFromJson)
|
||||||
Dns get dns => _dns;
|
Dns get dns => _dns;
|
||||||
|
|
||||||
set dns(Dns value) {
|
set dns(Dns value) {
|
||||||
@@ -316,10 +321,21 @@ class ClashConfig extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonKey(defaultValue: {})
|
||||||
|
HostsMap get hosts => _hosts;
|
||||||
|
|
||||||
|
set hosts(HostsMap value) {
|
||||||
|
if (!const MapEquality<String, String>().equals(value, _hosts)) {
|
||||||
|
_hosts = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
update([ClashConfig? clashConfig]) {
|
update([ClashConfig? clashConfig]) {
|
||||||
if (clashConfig != null) {
|
if (clashConfig != null) {
|
||||||
_mixedPort = clashConfig._mixedPort;
|
_mixedPort = clashConfig._mixedPort;
|
||||||
_allowLan = clashConfig._allowLan;
|
_allowLan = clashConfig._allowLan;
|
||||||
|
_hosts = clashConfig._hosts;
|
||||||
_mode = clashConfig._mode;
|
_mode = clashConfig._mode;
|
||||||
_logLevel = clashConfig._logLevel;
|
_logLevel = clashConfig._logLevel;
|
||||||
_tun = clashConfig._tun;
|
_tun = clashConfig._tun;
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ class AccessControl with _$AccessControl {
|
|||||||
|
|
||||||
extension AccessControlExt on AccessControl {
|
extension AccessControlExt on AccessControl {
|
||||||
List<String> get currentList => switch (mode) {
|
List<String> get currentList => switch (mode) {
|
||||||
AccessControlMode.acceptSelected => acceptList,
|
AccessControlMode.acceptSelected => acceptList,
|
||||||
AccessControlMode.rejectSelected => rejectList,
|
AccessControlMode.rejectSelected => rejectList,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
@@ -38,13 +38,26 @@ 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,
|
||||||
required bool onlyProxy,
|
required bool onlyProxy,
|
||||||
}) = _CoreState;
|
}) = _CoreState;
|
||||||
|
|
||||||
factory CoreState.fromJson(Map<String, Object?> json) => _$CoreStateFromJson(json);
|
factory CoreState.fromJson(Map<String, Object?> json) =>
|
||||||
|
_$CoreStateFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class VPNState with _$VPNState {
|
||||||
|
const factory VPNState({
|
||||||
|
required AccessControl? accessControl,
|
||||||
|
required VpnProps vpnProps,
|
||||||
|
}) = _VPNState;
|
||||||
|
|
||||||
|
factory VPNState.fromJson(Map<String, Object?> json) =>
|
||||||
|
_$VPNStateFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
@@ -57,10 +70,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 {
|
||||||
@@ -80,18 +113,20 @@ 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;
|
||||||
ProxiesType _proxiesType;
|
ProxiesType _proxiesType;
|
||||||
ProxyCardType _proxyCardType;
|
ProxyCardType _proxyCardType;
|
||||||
int _proxiesColumns;
|
ProxiesLayout _proxiesLayout;
|
||||||
String _testUrl;
|
String _testUrl;
|
||||||
WindowProps _windowProps;
|
WindowProps _windowProps;
|
||||||
bool _onlyProxy;
|
bool _onlyProxy;
|
||||||
bool _prueBlack;
|
bool _prueBlack;
|
||||||
|
VpnProps _vpnProps;
|
||||||
|
DesktopProps _desktopProps;
|
||||||
|
bool _showLabel;
|
||||||
|
bool _overrideDns;
|
||||||
|
|
||||||
Config()
|
Config()
|
||||||
: _profiles = [],
|
: _profiles = [],
|
||||||
@@ -107,18 +142,20 @@ 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,
|
||||||
_proxiesColumns = 2,
|
|
||||||
_prueBlack = false,
|
_prueBlack = false,
|
||||||
_onlyProxy = false;
|
_onlyProxy = false,
|
||||||
|
_proxiesLayout = ProxiesLayout.standard,
|
||||||
|
_vpnProps = const VpnProps(),
|
||||||
|
_desktopProps = const DesktopProps(),
|
||||||
|
_showLabel = false,
|
||||||
|
_overrideDns = false;
|
||||||
|
|
||||||
deleteProfileById(String id) {
|
deleteProfileById(String id) {
|
||||||
_profiles = profiles.where((element) => element.id != id).toList();
|
_profiles = profiles.where((element) => element.id != id).toList();
|
||||||
@@ -320,6 +357,16 @@ class Config extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonKey(defaultValue: ProxiesLayout.standard)
|
||||||
|
ProxiesLayout get proxiesLayout => _proxiesLayout;
|
||||||
|
|
||||||
|
set proxiesLayout(ProxiesLayout value) {
|
||||||
|
if (_proxiesLayout != value) {
|
||||||
|
_proxiesLayout = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@JsonKey(defaultValue: true)
|
@JsonKey(defaultValue: true)
|
||||||
bool get isMinimizeOnExit => _isMinimizeOnExit;
|
bool get isMinimizeOnExit => _isMinimizeOnExit;
|
||||||
|
|
||||||
@@ -398,30 +445,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;
|
||||||
@@ -481,16 +504,6 @@ class Config extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(defaultValue: 2)
|
|
||||||
int get proxiesColumns => _proxiesColumns;
|
|
||||||
|
|
||||||
set proxiesColumns(int value) {
|
|
||||||
if (_proxiesColumns != value) {
|
|
||||||
_proxiesColumns = value;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonKey(name: "test-url", defaultValue: defaultTestUrl)
|
@JsonKey(name: "test-url", defaultValue: defaultTestUrl)
|
||||||
String get testUrl => _testUrl;
|
String get testUrl => _testUrl;
|
||||||
|
|
||||||
@@ -520,6 +533,44 @@ 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(defaultValue: false)
|
||||||
|
bool get showLabel => _showLabel;
|
||||||
|
|
||||||
|
set showLabel(bool value) {
|
||||||
|
if (_showLabel != value) {
|
||||||
|
_showLabel = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(defaultValue: false)
|
||||||
|
bool get overrideDns => _overrideDns;
|
||||||
|
|
||||||
|
set overrideDns(bool value) {
|
||||||
|
if (_overrideDns != value) {
|
||||||
|
_overrideDns = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
update([
|
update([
|
||||||
Config? config,
|
Config? config,
|
||||||
RecoveryOption recoveryOptions = RecoveryOption.all,
|
RecoveryOption recoveryOptions = RecoveryOption.all,
|
||||||
@@ -544,7 +595,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;
|
||||||
@@ -556,6 +606,9 @@ 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;
|
||||||
|
_overrideDns = config._overrideDns;
|
||||||
|
_desktopProps = config._desktopProps;
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class ConfigExtendedParams with _$ConfigExtendedParams {
|
|||||||
@JsonKey(name: "is-patch") required bool isPatch,
|
@JsonKey(name: "is-patch") required bool isPatch,
|
||||||
@JsonKey(name: "is-compatible") required bool isCompatible,
|
@JsonKey(name: "is-compatible") required bool isCompatible,
|
||||||
@JsonKey(name: "selected-map") required SelectedMap selectedMap,
|
@JsonKey(name: "selected-map") required SelectedMap selectedMap,
|
||||||
|
@JsonKey(name: "override-dns") required bool overrideDns,
|
||||||
@JsonKey(name: "test-url") required String testUrl,
|
@JsonKey(name: "test-url") required String testUrl,
|
||||||
}) = _ConfigExtendedParams;
|
}) = _ConfigExtendedParams;
|
||||||
|
|
||||||
|
|||||||
@@ -220,3 +220,818 @@ abstract class _Tun implements Tun {
|
|||||||
_$$TunImplCopyWith<_$TunImpl> get copyWith =>
|
_$$TunImplCopyWith<_$TunImpl> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FallbackFilter _$FallbackFilterFromJson(Map<String, dynamic> json) {
|
||||||
|
return _FallbackFilter.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$FallbackFilter {
|
||||||
|
bool get geoip => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "geoip-code")
|
||||||
|
String get geoipCode => throw _privateConstructorUsedError;
|
||||||
|
List<String> get geosite => throw _privateConstructorUsedError;
|
||||||
|
List<String> get ipcidr => throw _privateConstructorUsedError;
|
||||||
|
List<String> get domain => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$FallbackFilterCopyWith<FallbackFilter> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $FallbackFilterCopyWith<$Res> {
|
||||||
|
factory $FallbackFilterCopyWith(
|
||||||
|
FallbackFilter value, $Res Function(FallbackFilter) then) =
|
||||||
|
_$FallbackFilterCopyWithImpl<$Res, FallbackFilter>;
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{bool geoip,
|
||||||
|
@JsonKey(name: "geoip-code") String geoipCode,
|
||||||
|
List<String> geosite,
|
||||||
|
List<String> ipcidr,
|
||||||
|
List<String> domain});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$FallbackFilterCopyWithImpl<$Res, $Val extends FallbackFilter>
|
||||||
|
implements $FallbackFilterCopyWith<$Res> {
|
||||||
|
_$FallbackFilterCopyWithImpl(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? geoip = null,
|
||||||
|
Object? geoipCode = null,
|
||||||
|
Object? geosite = null,
|
||||||
|
Object? ipcidr = null,
|
||||||
|
Object? domain = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
geoip: null == geoip
|
||||||
|
? _value.geoip
|
||||||
|
: geoip // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
geoipCode: null == geoipCode
|
||||||
|
? _value.geoipCode
|
||||||
|
: geoipCode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
geosite: null == geosite
|
||||||
|
? _value.geosite
|
||||||
|
: geosite // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
ipcidr: null == ipcidr
|
||||||
|
? _value.ipcidr
|
||||||
|
: ipcidr // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
domain: null == domain
|
||||||
|
? _value.domain
|
||||||
|
: domain // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$FallbackFilterImplCopyWith<$Res>
|
||||||
|
implements $FallbackFilterCopyWith<$Res> {
|
||||||
|
factory _$$FallbackFilterImplCopyWith(_$FallbackFilterImpl value,
|
||||||
|
$Res Function(_$FallbackFilterImpl) then) =
|
||||||
|
__$$FallbackFilterImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{bool geoip,
|
||||||
|
@JsonKey(name: "geoip-code") String geoipCode,
|
||||||
|
List<String> geosite,
|
||||||
|
List<String> ipcidr,
|
||||||
|
List<String> domain});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$FallbackFilterImplCopyWithImpl<$Res>
|
||||||
|
extends _$FallbackFilterCopyWithImpl<$Res, _$FallbackFilterImpl>
|
||||||
|
implements _$$FallbackFilterImplCopyWith<$Res> {
|
||||||
|
__$$FallbackFilterImplCopyWithImpl(
|
||||||
|
_$FallbackFilterImpl _value, $Res Function(_$FallbackFilterImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? geoip = null,
|
||||||
|
Object? geoipCode = null,
|
||||||
|
Object? geosite = null,
|
||||||
|
Object? ipcidr = null,
|
||||||
|
Object? domain = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$FallbackFilterImpl(
|
||||||
|
geoip: null == geoip
|
||||||
|
? _value.geoip
|
||||||
|
: geoip // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
geoipCode: null == geoipCode
|
||||||
|
? _value.geoipCode
|
||||||
|
: geoipCode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
geosite: null == geosite
|
||||||
|
? _value._geosite
|
||||||
|
: geosite // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
ipcidr: null == ipcidr
|
||||||
|
? _value._ipcidr
|
||||||
|
: ipcidr // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
domain: null == domain
|
||||||
|
? _value._domain
|
||||||
|
: domain // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$FallbackFilterImpl implements _FallbackFilter {
|
||||||
|
const _$FallbackFilterImpl(
|
||||||
|
{this.geoip = true,
|
||||||
|
@JsonKey(name: "geoip-code") this.geoipCode = "CN",
|
||||||
|
final List<String> geosite = const ["gfw"],
|
||||||
|
final List<String> ipcidr = const ["240.0.0.0/4"],
|
||||||
|
final List<String> domain = const [
|
||||||
|
"+.google.com",
|
||||||
|
"+.facebook.com",
|
||||||
|
"+.youtube.com"
|
||||||
|
]})
|
||||||
|
: _geosite = geosite,
|
||||||
|
_ipcidr = ipcidr,
|
||||||
|
_domain = domain;
|
||||||
|
|
||||||
|
factory _$FallbackFilterImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$FallbackFilterImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool geoip;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "geoip-code")
|
||||||
|
final String geoipCode;
|
||||||
|
final List<String> _geosite;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
List<String> get geosite {
|
||||||
|
if (_geosite is EqualUnmodifiableListView) return _geosite;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_geosite);
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<String> _ipcidr;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
List<String> get ipcidr {
|
||||||
|
if (_ipcidr is EqualUnmodifiableListView) return _ipcidr;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_ipcidr);
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<String> _domain;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
List<String> get domain {
|
||||||
|
if (_domain is EqualUnmodifiableListView) return _domain;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'FallbackFilter(geoip: $geoip, geoipCode: $geoipCode, geosite: $geosite, ipcidr: $ipcidr, domain: $domain)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$FallbackFilterImpl &&
|
||||||
|
(identical(other.geoip, geoip) || other.geoip == geoip) &&
|
||||||
|
(identical(other.geoipCode, geoipCode) ||
|
||||||
|
other.geoipCode == geoipCode) &&
|
||||||
|
const DeepCollectionEquality().equals(other._geosite, _geosite) &&
|
||||||
|
const DeepCollectionEquality().equals(other._ipcidr, _ipcidr) &&
|
||||||
|
const DeepCollectionEquality().equals(other._domain, _domain));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(
|
||||||
|
runtimeType,
|
||||||
|
geoip,
|
||||||
|
geoipCode,
|
||||||
|
const DeepCollectionEquality().hash(_geosite),
|
||||||
|
const DeepCollectionEquality().hash(_ipcidr),
|
||||||
|
const DeepCollectionEquality().hash(_domain));
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$FallbackFilterImplCopyWith<_$FallbackFilterImpl> get copyWith =>
|
||||||
|
__$$FallbackFilterImplCopyWithImpl<_$FallbackFilterImpl>(
|
||||||
|
this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$FallbackFilterImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _FallbackFilter implements FallbackFilter {
|
||||||
|
const factory _FallbackFilter(
|
||||||
|
{final bool geoip,
|
||||||
|
@JsonKey(name: "geoip-code") final String geoipCode,
|
||||||
|
final List<String> geosite,
|
||||||
|
final List<String> ipcidr,
|
||||||
|
final List<String> domain}) = _$FallbackFilterImpl;
|
||||||
|
|
||||||
|
factory _FallbackFilter.fromJson(Map<String, dynamic> json) =
|
||||||
|
_$FallbackFilterImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get geoip;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "geoip-code")
|
||||||
|
String get geoipCode;
|
||||||
|
@override
|
||||||
|
List<String> get geosite;
|
||||||
|
@override
|
||||||
|
List<String> get ipcidr;
|
||||||
|
@override
|
||||||
|
List<String> get domain;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$FallbackFilterImplCopyWith<_$FallbackFilterImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dns _$DnsFromJson(Map<String, dynamic> json) {
|
||||||
|
return _Dns.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$Dns {
|
||||||
|
bool get enable => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "prefer-h3")
|
||||||
|
bool get preferH3 => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "use-hosts")
|
||||||
|
bool get useHosts => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "use-system-hosts")
|
||||||
|
bool get useSystemHosts => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "respect-rules")
|
||||||
|
bool get respectRules => throw _privateConstructorUsedError;
|
||||||
|
bool get ipv6 => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "default-nameserver")
|
||||||
|
List<String> get defaultNameserver => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "enhanced-mode")
|
||||||
|
DnsMode get enhancedMode => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "fake-ip-range")
|
||||||
|
String get fakeIpRange => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "fake-ip-filter")
|
||||||
|
List<String> get fakeIpFilter => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "nameserver-policy")
|
||||||
|
Map<String, String> get nameserverPolicy =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
List<String> get nameserver => throw _privateConstructorUsedError;
|
||||||
|
List<String> get fallback => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "proxy-server-nameserver")
|
||||||
|
List<String> get proxyServerNameserver => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "fallback-filter")
|
||||||
|
FallbackFilter get fallbackFilter => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$DnsCopyWith<Dns> get copyWith => throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $DnsCopyWith<$Res> {
|
||||||
|
factory $DnsCopyWith(Dns value, $Res Function(Dns) then) =
|
||||||
|
_$DnsCopyWithImpl<$Res, Dns>;
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{bool enable,
|
||||||
|
@JsonKey(name: "prefer-h3") bool preferH3,
|
||||||
|
@JsonKey(name: "use-hosts") bool useHosts,
|
||||||
|
@JsonKey(name: "use-system-hosts") bool useSystemHosts,
|
||||||
|
@JsonKey(name: "respect-rules") bool respectRules,
|
||||||
|
bool ipv6,
|
||||||
|
@JsonKey(name: "default-nameserver") List<String> defaultNameserver,
|
||||||
|
@JsonKey(name: "enhanced-mode") DnsMode enhancedMode,
|
||||||
|
@JsonKey(name: "fake-ip-range") String fakeIpRange,
|
||||||
|
@JsonKey(name: "fake-ip-filter") List<String> fakeIpFilter,
|
||||||
|
@JsonKey(name: "nameserver-policy") Map<String, String> nameserverPolicy,
|
||||||
|
List<String> nameserver,
|
||||||
|
List<String> fallback,
|
||||||
|
@JsonKey(name: "proxy-server-nameserver")
|
||||||
|
List<String> proxyServerNameserver,
|
||||||
|
@JsonKey(name: "fallback-filter") FallbackFilter fallbackFilter});
|
||||||
|
|
||||||
|
$FallbackFilterCopyWith<$Res> get fallbackFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$DnsCopyWithImpl<$Res, $Val extends Dns> implements $DnsCopyWith<$Res> {
|
||||||
|
_$DnsCopyWithImpl(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? preferH3 = null,
|
||||||
|
Object? useHosts = null,
|
||||||
|
Object? useSystemHosts = null,
|
||||||
|
Object? respectRules = null,
|
||||||
|
Object? ipv6 = null,
|
||||||
|
Object? defaultNameserver = null,
|
||||||
|
Object? enhancedMode = null,
|
||||||
|
Object? fakeIpRange = null,
|
||||||
|
Object? fakeIpFilter = null,
|
||||||
|
Object? nameserverPolicy = null,
|
||||||
|
Object? nameserver = null,
|
||||||
|
Object? fallback = null,
|
||||||
|
Object? proxyServerNameserver = null,
|
||||||
|
Object? fallbackFilter = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
enable: null == enable
|
||||||
|
? _value.enable
|
||||||
|
: enable // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
preferH3: null == preferH3
|
||||||
|
? _value.preferH3
|
||||||
|
: preferH3 // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
useHosts: null == useHosts
|
||||||
|
? _value.useHosts
|
||||||
|
: useHosts // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
useSystemHosts: null == useSystemHosts
|
||||||
|
? _value.useSystemHosts
|
||||||
|
: useSystemHosts // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
respectRules: null == respectRules
|
||||||
|
? _value.respectRules
|
||||||
|
: respectRules // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
ipv6: null == ipv6
|
||||||
|
? _value.ipv6
|
||||||
|
: ipv6 // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
defaultNameserver: null == defaultNameserver
|
||||||
|
? _value.defaultNameserver
|
||||||
|
: defaultNameserver // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
enhancedMode: null == enhancedMode
|
||||||
|
? _value.enhancedMode
|
||||||
|
: enhancedMode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as DnsMode,
|
||||||
|
fakeIpRange: null == fakeIpRange
|
||||||
|
? _value.fakeIpRange
|
||||||
|
: fakeIpRange // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
fakeIpFilter: null == fakeIpFilter
|
||||||
|
? _value.fakeIpFilter
|
||||||
|
: fakeIpFilter // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
nameserverPolicy: null == nameserverPolicy
|
||||||
|
? _value.nameserverPolicy
|
||||||
|
: nameserverPolicy // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Map<String, String>,
|
||||||
|
nameserver: null == nameserver
|
||||||
|
? _value.nameserver
|
||||||
|
: nameserver // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
fallback: null == fallback
|
||||||
|
? _value.fallback
|
||||||
|
: fallback // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
proxyServerNameserver: null == proxyServerNameserver
|
||||||
|
? _value.proxyServerNameserver
|
||||||
|
: proxyServerNameserver // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
fallbackFilter: null == fallbackFilter
|
||||||
|
? _value.fallbackFilter
|
||||||
|
: fallbackFilter // ignore: cast_nullable_to_non_nullable
|
||||||
|
as FallbackFilter,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
$FallbackFilterCopyWith<$Res> get fallbackFilter {
|
||||||
|
return $FallbackFilterCopyWith<$Res>(_value.fallbackFilter, (value) {
|
||||||
|
return _then(_value.copyWith(fallbackFilter: value) as $Val);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$DnsImplCopyWith<$Res> implements $DnsCopyWith<$Res> {
|
||||||
|
factory _$$DnsImplCopyWith(_$DnsImpl value, $Res Function(_$DnsImpl) then) =
|
||||||
|
__$$DnsImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{bool enable,
|
||||||
|
@JsonKey(name: "prefer-h3") bool preferH3,
|
||||||
|
@JsonKey(name: "use-hosts") bool useHosts,
|
||||||
|
@JsonKey(name: "use-system-hosts") bool useSystemHosts,
|
||||||
|
@JsonKey(name: "respect-rules") bool respectRules,
|
||||||
|
bool ipv6,
|
||||||
|
@JsonKey(name: "default-nameserver") List<String> defaultNameserver,
|
||||||
|
@JsonKey(name: "enhanced-mode") DnsMode enhancedMode,
|
||||||
|
@JsonKey(name: "fake-ip-range") String fakeIpRange,
|
||||||
|
@JsonKey(name: "fake-ip-filter") List<String> fakeIpFilter,
|
||||||
|
@JsonKey(name: "nameserver-policy") Map<String, String> nameserverPolicy,
|
||||||
|
List<String> nameserver,
|
||||||
|
List<String> fallback,
|
||||||
|
@JsonKey(name: "proxy-server-nameserver")
|
||||||
|
List<String> proxyServerNameserver,
|
||||||
|
@JsonKey(name: "fallback-filter") FallbackFilter fallbackFilter});
|
||||||
|
|
||||||
|
@override
|
||||||
|
$FallbackFilterCopyWith<$Res> get fallbackFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$DnsImplCopyWithImpl<$Res> extends _$DnsCopyWithImpl<$Res, _$DnsImpl>
|
||||||
|
implements _$$DnsImplCopyWith<$Res> {
|
||||||
|
__$$DnsImplCopyWithImpl(_$DnsImpl _value, $Res Function(_$DnsImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? enable = null,
|
||||||
|
Object? preferH3 = null,
|
||||||
|
Object? useHosts = null,
|
||||||
|
Object? useSystemHosts = null,
|
||||||
|
Object? respectRules = null,
|
||||||
|
Object? ipv6 = null,
|
||||||
|
Object? defaultNameserver = null,
|
||||||
|
Object? enhancedMode = null,
|
||||||
|
Object? fakeIpRange = null,
|
||||||
|
Object? fakeIpFilter = null,
|
||||||
|
Object? nameserverPolicy = null,
|
||||||
|
Object? nameserver = null,
|
||||||
|
Object? fallback = null,
|
||||||
|
Object? proxyServerNameserver = null,
|
||||||
|
Object? fallbackFilter = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$DnsImpl(
|
||||||
|
enable: null == enable
|
||||||
|
? _value.enable
|
||||||
|
: enable // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
preferH3: null == preferH3
|
||||||
|
? _value.preferH3
|
||||||
|
: preferH3 // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
useHosts: null == useHosts
|
||||||
|
? _value.useHosts
|
||||||
|
: useHosts // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
useSystemHosts: null == useSystemHosts
|
||||||
|
? _value.useSystemHosts
|
||||||
|
: useSystemHosts // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
respectRules: null == respectRules
|
||||||
|
? _value.respectRules
|
||||||
|
: respectRules // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
ipv6: null == ipv6
|
||||||
|
? _value.ipv6
|
||||||
|
: ipv6 // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
defaultNameserver: null == defaultNameserver
|
||||||
|
? _value._defaultNameserver
|
||||||
|
: defaultNameserver // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
enhancedMode: null == enhancedMode
|
||||||
|
? _value.enhancedMode
|
||||||
|
: enhancedMode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as DnsMode,
|
||||||
|
fakeIpRange: null == fakeIpRange
|
||||||
|
? _value.fakeIpRange
|
||||||
|
: fakeIpRange // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
fakeIpFilter: null == fakeIpFilter
|
||||||
|
? _value._fakeIpFilter
|
||||||
|
: fakeIpFilter // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
nameserverPolicy: null == nameserverPolicy
|
||||||
|
? _value._nameserverPolicy
|
||||||
|
: nameserverPolicy // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Map<String, String>,
|
||||||
|
nameserver: null == nameserver
|
||||||
|
? _value._nameserver
|
||||||
|
: nameserver // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
fallback: null == fallback
|
||||||
|
? _value._fallback
|
||||||
|
: fallback // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
proxyServerNameserver: null == proxyServerNameserver
|
||||||
|
? _value._proxyServerNameserver
|
||||||
|
: proxyServerNameserver // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<String>,
|
||||||
|
fallbackFilter: null == fallbackFilter
|
||||||
|
? _value.fallbackFilter
|
||||||
|
: fallbackFilter // ignore: cast_nullable_to_non_nullable
|
||||||
|
as FallbackFilter,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$DnsImpl implements _Dns {
|
||||||
|
const _$DnsImpl(
|
||||||
|
{this.enable = true,
|
||||||
|
@JsonKey(name: "prefer-h3") this.preferH3 = false,
|
||||||
|
@JsonKey(name: "use-hosts") this.useHosts = true,
|
||||||
|
@JsonKey(name: "use-system-hosts") this.useSystemHosts = true,
|
||||||
|
@JsonKey(name: "respect-rules") this.respectRules = true,
|
||||||
|
this.ipv6 = false,
|
||||||
|
@JsonKey(name: "default-nameserver")
|
||||||
|
final List<String> defaultNameserver = const ["223.5.5.5"],
|
||||||
|
@JsonKey(name: "enhanced-mode") this.enhancedMode = DnsMode.fakeIp,
|
||||||
|
@JsonKey(name: "fake-ip-range") this.fakeIpRange = "198.18.0.1/16",
|
||||||
|
@JsonKey(name: "fake-ip-filter") final List<String> fakeIpFilter = const [
|
||||||
|
"*.lan",
|
||||||
|
"localhost.ptlogin2.qq.com"
|
||||||
|
],
|
||||||
|
@JsonKey(name: "nameserver-policy")
|
||||||
|
final Map<String, String> nameserverPolicy = const {
|
||||||
|
"www.baidu.com": "114.114.114.114",
|
||||||
|
"+.internal.crop.com": "10.0.0.1",
|
||||||
|
"geosite:cn": "https://doh.pub/dns-query"
|
||||||
|
},
|
||||||
|
final List<String> nameserver = const [
|
||||||
|
"https://doh.pub/dns-query",
|
||||||
|
"https://dns.alidns.com/dns-query"
|
||||||
|
],
|
||||||
|
final List<String> fallback = const ["tls://8.8.4.4", "tls://1.1.1.1"],
|
||||||
|
@JsonKey(name: "proxy-server-nameserver")
|
||||||
|
final List<String> proxyServerNameserver = const [
|
||||||
|
"https://doh.pub/dns-query"
|
||||||
|
],
|
||||||
|
@JsonKey(name: "fallback-filter")
|
||||||
|
this.fallbackFilter = const FallbackFilter()})
|
||||||
|
: _defaultNameserver = defaultNameserver,
|
||||||
|
_fakeIpFilter = fakeIpFilter,
|
||||||
|
_nameserverPolicy = nameserverPolicy,
|
||||||
|
_nameserver = nameserver,
|
||||||
|
_fallback = fallback,
|
||||||
|
_proxyServerNameserver = proxyServerNameserver;
|
||||||
|
|
||||||
|
factory _$DnsImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$DnsImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool enable;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "prefer-h3")
|
||||||
|
final bool preferH3;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "use-hosts")
|
||||||
|
final bool useHosts;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "use-system-hosts")
|
||||||
|
final bool useSystemHosts;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "respect-rules")
|
||||||
|
final bool respectRules;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool ipv6;
|
||||||
|
final List<String> _defaultNameserver;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "default-nameserver")
|
||||||
|
List<String> get defaultNameserver {
|
||||||
|
if (_defaultNameserver is EqualUnmodifiableListView)
|
||||||
|
return _defaultNameserver;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_defaultNameserver);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "enhanced-mode")
|
||||||
|
final DnsMode enhancedMode;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "fake-ip-range")
|
||||||
|
final String fakeIpRange;
|
||||||
|
final List<String> _fakeIpFilter;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "fake-ip-filter")
|
||||||
|
List<String> get fakeIpFilter {
|
||||||
|
if (_fakeIpFilter is EqualUnmodifiableListView) return _fakeIpFilter;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_fakeIpFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Map<String, String> _nameserverPolicy;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "nameserver-policy")
|
||||||
|
Map<String, String> get nameserverPolicy {
|
||||||
|
if (_nameserverPolicy is EqualUnmodifiableMapView) return _nameserverPolicy;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableMapView(_nameserverPolicy);
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<String> _nameserver;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
List<String> get nameserver {
|
||||||
|
if (_nameserver is EqualUnmodifiableListView) return _nameserver;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_nameserver);
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<String> _fallback;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
List<String> get fallback {
|
||||||
|
if (_fallback is EqualUnmodifiableListView) return _fallback;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_fallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<String> _proxyServerNameserver;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "proxy-server-nameserver")
|
||||||
|
List<String> get proxyServerNameserver {
|
||||||
|
if (_proxyServerNameserver is EqualUnmodifiableListView)
|
||||||
|
return _proxyServerNameserver;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_proxyServerNameserver);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "fallback-filter")
|
||||||
|
final FallbackFilter fallbackFilter;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Dns(enable: $enable, preferH3: $preferH3, useHosts: $useHosts, useSystemHosts: $useSystemHosts, respectRules: $respectRules, ipv6: $ipv6, defaultNameserver: $defaultNameserver, enhancedMode: $enhancedMode, fakeIpRange: $fakeIpRange, fakeIpFilter: $fakeIpFilter, nameserverPolicy: $nameserverPolicy, nameserver: $nameserver, fallback: $fallback, proxyServerNameserver: $proxyServerNameserver, fallbackFilter: $fallbackFilter)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$DnsImpl &&
|
||||||
|
(identical(other.enable, enable) || other.enable == enable) &&
|
||||||
|
(identical(other.preferH3, preferH3) ||
|
||||||
|
other.preferH3 == preferH3) &&
|
||||||
|
(identical(other.useHosts, useHosts) ||
|
||||||
|
other.useHosts == useHosts) &&
|
||||||
|
(identical(other.useSystemHosts, useSystemHosts) ||
|
||||||
|
other.useSystemHosts == useSystemHosts) &&
|
||||||
|
(identical(other.respectRules, respectRules) ||
|
||||||
|
other.respectRules == respectRules) &&
|
||||||
|
(identical(other.ipv6, ipv6) || other.ipv6 == ipv6) &&
|
||||||
|
const DeepCollectionEquality()
|
||||||
|
.equals(other._defaultNameserver, _defaultNameserver) &&
|
||||||
|
(identical(other.enhancedMode, enhancedMode) ||
|
||||||
|
other.enhancedMode == enhancedMode) &&
|
||||||
|
(identical(other.fakeIpRange, fakeIpRange) ||
|
||||||
|
other.fakeIpRange == fakeIpRange) &&
|
||||||
|
const DeepCollectionEquality()
|
||||||
|
.equals(other._fakeIpFilter, _fakeIpFilter) &&
|
||||||
|
const DeepCollectionEquality()
|
||||||
|
.equals(other._nameserverPolicy, _nameserverPolicy) &&
|
||||||
|
const DeepCollectionEquality()
|
||||||
|
.equals(other._nameserver, _nameserver) &&
|
||||||
|
const DeepCollectionEquality().equals(other._fallback, _fallback) &&
|
||||||
|
const DeepCollectionEquality()
|
||||||
|
.equals(other._proxyServerNameserver, _proxyServerNameserver) &&
|
||||||
|
(identical(other.fallbackFilter, fallbackFilter) ||
|
||||||
|
other.fallbackFilter == fallbackFilter));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(
|
||||||
|
runtimeType,
|
||||||
|
enable,
|
||||||
|
preferH3,
|
||||||
|
useHosts,
|
||||||
|
useSystemHosts,
|
||||||
|
respectRules,
|
||||||
|
ipv6,
|
||||||
|
const DeepCollectionEquality().hash(_defaultNameserver),
|
||||||
|
enhancedMode,
|
||||||
|
fakeIpRange,
|
||||||
|
const DeepCollectionEquality().hash(_fakeIpFilter),
|
||||||
|
const DeepCollectionEquality().hash(_nameserverPolicy),
|
||||||
|
const DeepCollectionEquality().hash(_nameserver),
|
||||||
|
const DeepCollectionEquality().hash(_fallback),
|
||||||
|
const DeepCollectionEquality().hash(_proxyServerNameserver),
|
||||||
|
fallbackFilter);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$DnsImplCopyWith<_$DnsImpl> get copyWith =>
|
||||||
|
__$$DnsImplCopyWithImpl<_$DnsImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$DnsImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _Dns implements Dns {
|
||||||
|
const factory _Dns(
|
||||||
|
{final bool enable,
|
||||||
|
@JsonKey(name: "prefer-h3") final bool preferH3,
|
||||||
|
@JsonKey(name: "use-hosts") final bool useHosts,
|
||||||
|
@JsonKey(name: "use-system-hosts") final bool useSystemHosts,
|
||||||
|
@JsonKey(name: "respect-rules") final bool respectRules,
|
||||||
|
final bool ipv6,
|
||||||
|
@JsonKey(name: "default-nameserver") final List<String> defaultNameserver,
|
||||||
|
@JsonKey(name: "enhanced-mode") final DnsMode enhancedMode,
|
||||||
|
@JsonKey(name: "fake-ip-range") final String fakeIpRange,
|
||||||
|
@JsonKey(name: "fake-ip-filter") final List<String> fakeIpFilter,
|
||||||
|
@JsonKey(name: "nameserver-policy")
|
||||||
|
final Map<String, String> nameserverPolicy,
|
||||||
|
final List<String> nameserver,
|
||||||
|
final List<String> fallback,
|
||||||
|
@JsonKey(name: "proxy-server-nameserver")
|
||||||
|
final List<String> proxyServerNameserver,
|
||||||
|
@JsonKey(name: "fallback-filter")
|
||||||
|
final FallbackFilter fallbackFilter}) = _$DnsImpl;
|
||||||
|
|
||||||
|
factory _Dns.fromJson(Map<String, dynamic> json) = _$DnsImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get enable;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "prefer-h3")
|
||||||
|
bool get preferH3;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "use-hosts")
|
||||||
|
bool get useHosts;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "use-system-hosts")
|
||||||
|
bool get useSystemHosts;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "respect-rules")
|
||||||
|
bool get respectRules;
|
||||||
|
@override
|
||||||
|
bool get ipv6;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "default-nameserver")
|
||||||
|
List<String> get defaultNameserver;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "enhanced-mode")
|
||||||
|
DnsMode get enhancedMode;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "fake-ip-range")
|
||||||
|
String get fakeIpRange;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "fake-ip-filter")
|
||||||
|
List<String> get fakeIpFilter;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "nameserver-policy")
|
||||||
|
Map<String, String> get nameserverPolicy;
|
||||||
|
@override
|
||||||
|
List<String> get nameserver;
|
||||||
|
@override
|
||||||
|
List<String> get fallback;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "proxy-server-nameserver")
|
||||||
|
List<String> get proxyServerNameserver;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "fallback-filter")
|
||||||
|
FallbackFilter get fallbackFilter;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$DnsImplCopyWith<_$DnsImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,35 +6,6 @@ part of '../clash_config.dart';
|
|||||||
// JsonSerializableGenerator
|
// JsonSerializableGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
Dns _$DnsFromJson(Map<String, dynamic> json) => Dns()
|
|
||||||
..enable = json['enable'] as bool
|
|
||||||
..ipv6 = json['ipv6'] as bool
|
|
||||||
..defaultNameserver = (json['default-nameserver'] as List<dynamic>)
|
|
||||||
.map((e) => e as String)
|
|
||||||
.toList()
|
|
||||||
..enhancedMode = json['enhanced-mode'] as String
|
|
||||||
..fakeIpRange = json['fake-ip-range'] as String
|
|
||||||
..useHosts = json['use-hosts'] as bool
|
|
||||||
..nameserver =
|
|
||||||
(json['nameserver'] as List<dynamic>).map((e) => e as String).toList()
|
|
||||||
..fallback =
|
|
||||||
(json['fallback'] as List<dynamic>).map((e) => e as String).toList()
|
|
||||||
..fakeIpFilter = (json['fake-ip-filter'] as List<dynamic>)
|
|
||||||
.map((e) => e as String)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
Map<String, dynamic> _$DnsToJson(Dns instance) => <String, dynamic>{
|
|
||||||
'enable': instance.enable,
|
|
||||||
'ipv6': instance.ipv6,
|
|
||||||
'default-nameserver': instance.defaultNameserver,
|
|
||||||
'enhanced-mode': instance.enhancedMode,
|
|
||||||
'fake-ip-range': instance.fakeIpRange,
|
|
||||||
'use-hosts': instance.useHosts,
|
|
||||||
'nameserver': instance.nameserver,
|
|
||||||
'fallback': instance.fallback,
|
|
||||||
'fake-ip-filter': instance.fakeIpFilter,
|
|
||||||
};
|
|
||||||
|
|
||||||
ClashConfig _$ClashConfigFromJson(Map<String, dynamic> json) => ClashConfig()
|
ClashConfig _$ClashConfigFromJson(Map<String, dynamic> json) => ClashConfig()
|
||||||
..mixedPort = (json['mixed-port'] as num?)?.toInt() ?? 7890
|
..mixedPort = (json['mixed-port'] as num?)?.toInt() ?? 7890
|
||||||
..mode = $enumDecodeNullable(_$ModeEnumMap, json['mode']) ?? Mode.rule
|
..mode = $enumDecodeNullable(_$ModeEnumMap, json['mode']) ?? Mode.rule
|
||||||
@@ -51,7 +22,7 @@ ClashConfig _$ClashConfigFromJson(Map<String, dynamic> json) => ClashConfig()
|
|||||||
..unifiedDelay = json['unified-delay'] as bool? ?? false
|
..unifiedDelay = json['unified-delay'] as bool? ?? false
|
||||||
..tcpConcurrent = json['tcp-concurrent'] as bool? ?? false
|
..tcpConcurrent = json['tcp-concurrent'] as bool? ?? false
|
||||||
..tun = Tun.fromJson(json['tun'] as Map<String, dynamic>)
|
..tun = Tun.fromJson(json['tun'] as Map<String, dynamic>)
|
||||||
..dns = Dns.fromJson(json['dns'] as Map<String, dynamic>)
|
..dns = Dns.safeDnsFromJson(json['dns'] as Map<String, Object?>)
|
||||||
..rules = (json['rules'] as List<dynamic>).map((e) => e as String).toList()
|
..rules = (json['rules'] as List<dynamic>).map((e) => e as String).toList()
|
||||||
..globalRealUa = json['global-real-ua'] as String?
|
..globalRealUa = json['global-real-ua'] as String?
|
||||||
..geoXUrl = (json['geox-url'] as Map<String, dynamic>?)?.map(
|
..geoXUrl = (json['geox-url'] as Map<String, dynamic>?)?.map(
|
||||||
@@ -66,7 +37,11 @@ ClashConfig _$ClashConfigFromJson(Map<String, dynamic> json) => ClashConfig()
|
|||||||
'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoIP.dat',
|
'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoIP.dat',
|
||||||
'geosite':
|
'geosite':
|
||||||
'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat'
|
'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat'
|
||||||
};
|
}
|
||||||
|
..hosts = (json['hosts'] as Map<String, dynamic>?)?.map(
|
||||||
|
(k, e) => MapEntry(k, e as String),
|
||||||
|
) ??
|
||||||
|
{};
|
||||||
|
|
||||||
Map<String, dynamic> _$ClashConfigToJson(ClashConfig instance) =>
|
Map<String, dynamic> _$ClashConfigToJson(ClashConfig instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
@@ -87,6 +62,7 @@ Map<String, dynamic> _$ClashConfigToJson(ClashConfig instance) =>
|
|||||||
'global-ua': instance.globalUa,
|
'global-ua': instance.globalUa,
|
||||||
'global-real-ua': instance.globalRealUa,
|
'global-real-ua': instance.globalRealUa,
|
||||||
'geox-url': instance.geoXUrl,
|
'geox-url': instance.geoXUrl,
|
||||||
|
'hosts': instance.hosts,
|
||||||
};
|
};
|
||||||
|
|
||||||
const _$ModeEnumMap = {
|
const _$ModeEnumMap = {
|
||||||
@@ -131,3 +107,105 @@ const _$TunStackEnumMap = {
|
|||||||
TunStack.system: 'system',
|
TunStack.system: 'system',
|
||||||
TunStack.mixed: 'mixed',
|
TunStack.mixed: 'mixed',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_$FallbackFilterImpl _$$FallbackFilterImplFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$FallbackFilterImpl(
|
||||||
|
geoip: json['geoip'] as bool? ?? true,
|
||||||
|
geoipCode: json['geoip-code'] as String? ?? "CN",
|
||||||
|
geosite: (json['geosite'] as List<dynamic>?)
|
||||||
|
?.map((e) => e as String)
|
||||||
|
.toList() ??
|
||||||
|
const ["gfw"],
|
||||||
|
ipcidr: (json['ipcidr'] as List<dynamic>?)
|
||||||
|
?.map((e) => e as String)
|
||||||
|
.toList() ??
|
||||||
|
const ["240.0.0.0/4"],
|
||||||
|
domain: (json['domain'] as List<dynamic>?)
|
||||||
|
?.map((e) => e as String)
|
||||||
|
.toList() ??
|
||||||
|
const ["+.google.com", "+.facebook.com", "+.youtube.com"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$FallbackFilterImplToJson(
|
||||||
|
_$FallbackFilterImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'geoip': instance.geoip,
|
||||||
|
'geoip-code': instance.geoipCode,
|
||||||
|
'geosite': instance.geosite,
|
||||||
|
'ipcidr': instance.ipcidr,
|
||||||
|
'domain': instance.domain,
|
||||||
|
};
|
||||||
|
|
||||||
|
_$DnsImpl _$$DnsImplFromJson(Map<String, dynamic> json) => _$DnsImpl(
|
||||||
|
enable: json['enable'] as bool? ?? true,
|
||||||
|
preferH3: json['prefer-h3'] as bool? ?? false,
|
||||||
|
useHosts: json['use-hosts'] as bool? ?? true,
|
||||||
|
useSystemHosts: json['use-system-hosts'] as bool? ?? true,
|
||||||
|
respectRules: json['respect-rules'] as bool? ?? true,
|
||||||
|
ipv6: json['ipv6'] as bool? ?? false,
|
||||||
|
defaultNameserver: (json['default-nameserver'] as List<dynamic>?)
|
||||||
|
?.map((e) => e as String)
|
||||||
|
.toList() ??
|
||||||
|
const ["223.5.5.5"],
|
||||||
|
enhancedMode:
|
||||||
|
$enumDecodeNullable(_$DnsModeEnumMap, json['enhanced-mode']) ??
|
||||||
|
DnsMode.fakeIp,
|
||||||
|
fakeIpRange: json['fake-ip-range'] as String? ?? "198.18.0.1/16",
|
||||||
|
fakeIpFilter: (json['fake-ip-filter'] as List<dynamic>?)
|
||||||
|
?.map((e) => e as String)
|
||||||
|
.toList() ??
|
||||||
|
const ["*.lan", "localhost.ptlogin2.qq.com"],
|
||||||
|
nameserverPolicy:
|
||||||
|
(json['nameserver-policy'] as Map<String, dynamic>?)?.map(
|
||||||
|
(k, e) => MapEntry(k, e as String),
|
||||||
|
) ??
|
||||||
|
const {
|
||||||
|
"www.baidu.com": "114.114.114.114",
|
||||||
|
"+.internal.crop.com": "10.0.0.1",
|
||||||
|
"geosite:cn": "https://doh.pub/dns-query"
|
||||||
|
},
|
||||||
|
nameserver: (json['nameserver'] as List<dynamic>?)
|
||||||
|
?.map((e) => e as String)
|
||||||
|
.toList() ??
|
||||||
|
const [
|
||||||
|
"https://doh.pub/dns-query",
|
||||||
|
"https://dns.alidns.com/dns-query"
|
||||||
|
],
|
||||||
|
fallback: (json['fallback'] as List<dynamic>?)
|
||||||
|
?.map((e) => e as String)
|
||||||
|
.toList() ??
|
||||||
|
const ["tls://8.8.4.4", "tls://1.1.1.1"],
|
||||||
|
proxyServerNameserver: (json['proxy-server-nameserver'] as List<dynamic>?)
|
||||||
|
?.map((e) => e as String)
|
||||||
|
.toList() ??
|
||||||
|
const ["https://doh.pub/dns-query"],
|
||||||
|
fallbackFilter: json['fallback-filter'] == null
|
||||||
|
? const FallbackFilter()
|
||||||
|
: FallbackFilter.fromJson(
|
||||||
|
json['fallback-filter'] as Map<String, dynamic>),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$DnsImplToJson(_$DnsImpl instance) => <String, dynamic>{
|
||||||
|
'enable': instance.enable,
|
||||||
|
'prefer-h3': instance.preferH3,
|
||||||
|
'use-hosts': instance.useHosts,
|
||||||
|
'use-system-hosts': instance.useSystemHosts,
|
||||||
|
'respect-rules': instance.respectRules,
|
||||||
|
'ipv6': instance.ipv6,
|
||||||
|
'default-nameserver': instance.defaultNameserver,
|
||||||
|
'enhanced-mode': _$DnsModeEnumMap[instance.enhancedMode]!,
|
||||||
|
'fake-ip-range': instance.fakeIpRange,
|
||||||
|
'fake-ip-filter': instance.fakeIpFilter,
|
||||||
|
'nameserver-policy': instance.nameserverPolicy,
|
||||||
|
'nameserver': instance.nameserver,
|
||||||
|
'fallback': instance.fallback,
|
||||||
|
'proxy-server-nameserver': instance.proxyServerNameserver,
|
||||||
|
'fallback-filter': instance.fallbackFilter,
|
||||||
|
};
|
||||||
|
|
||||||
|
const _$DnsModeEnumMap = {
|
||||||
|
DnsMode.normal: 'normal',
|
||||||
|
DnsMode.fakeIp: 'fake-ip',
|
||||||
|
DnsMode.redirHost: 'redir-host',
|
||||||
|
DnsMode.hosts: 'hosts',
|
||||||
|
};
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -525,6 +552,189 @@ abstract class _CoreState implements CoreState {
|
|||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VPNState _$VPNStateFromJson(Map<String, dynamic> json) {
|
||||||
|
return _VPNState.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$VPNState {
|
||||||
|
AccessControl? get accessControl => throw _privateConstructorUsedError;
|
||||||
|
VpnProps get vpnProps => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$VPNStateCopyWith<VPNState> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $VPNStateCopyWith<$Res> {
|
||||||
|
factory $VPNStateCopyWith(VPNState value, $Res Function(VPNState) then) =
|
||||||
|
_$VPNStateCopyWithImpl<$Res, VPNState>;
|
||||||
|
@useResult
|
||||||
|
$Res call({AccessControl? accessControl, VpnProps vpnProps});
|
||||||
|
|
||||||
|
$AccessControlCopyWith<$Res>? get accessControl;
|
||||||
|
$VpnPropsCopyWith<$Res> get vpnProps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$VPNStateCopyWithImpl<$Res, $Val extends VPNState>
|
||||||
|
implements $VPNStateCopyWith<$Res> {
|
||||||
|
_$VPNStateCopyWithImpl(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? accessControl = freezed,
|
||||||
|
Object? vpnProps = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
accessControl: freezed == accessControl
|
||||||
|
? _value.accessControl
|
||||||
|
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||||
|
as AccessControl?,
|
||||||
|
vpnProps: null == vpnProps
|
||||||
|
? _value.vpnProps
|
||||||
|
: vpnProps // ignore: cast_nullable_to_non_nullable
|
||||||
|
as VpnProps,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
$AccessControlCopyWith<$Res>? get accessControl {
|
||||||
|
if (_value.accessControl == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $AccessControlCopyWith<$Res>(_value.accessControl!, (value) {
|
||||||
|
return _then(_value.copyWith(accessControl: value) as $Val);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
$VpnPropsCopyWith<$Res> get vpnProps {
|
||||||
|
return $VpnPropsCopyWith<$Res>(_value.vpnProps, (value) {
|
||||||
|
return _then(_value.copyWith(vpnProps: value) as $Val);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$VPNStateImplCopyWith<$Res>
|
||||||
|
implements $VPNStateCopyWith<$Res> {
|
||||||
|
factory _$$VPNStateImplCopyWith(
|
||||||
|
_$VPNStateImpl value, $Res Function(_$VPNStateImpl) then) =
|
||||||
|
__$$VPNStateImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({AccessControl? accessControl, VpnProps vpnProps});
|
||||||
|
|
||||||
|
@override
|
||||||
|
$AccessControlCopyWith<$Res>? get accessControl;
|
||||||
|
@override
|
||||||
|
$VpnPropsCopyWith<$Res> get vpnProps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$VPNStateImplCopyWithImpl<$Res>
|
||||||
|
extends _$VPNStateCopyWithImpl<$Res, _$VPNStateImpl>
|
||||||
|
implements _$$VPNStateImplCopyWith<$Res> {
|
||||||
|
__$$VPNStateImplCopyWithImpl(
|
||||||
|
_$VPNStateImpl _value, $Res Function(_$VPNStateImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? accessControl = freezed,
|
||||||
|
Object? vpnProps = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$VPNStateImpl(
|
||||||
|
accessControl: freezed == accessControl
|
||||||
|
? _value.accessControl
|
||||||
|
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||||
|
as AccessControl?,
|
||||||
|
vpnProps: null == vpnProps
|
||||||
|
? _value.vpnProps
|
||||||
|
: vpnProps // ignore: cast_nullable_to_non_nullable
|
||||||
|
as VpnProps,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$VPNStateImpl implements _VPNState {
|
||||||
|
const _$VPNStateImpl({required this.accessControl, required this.vpnProps});
|
||||||
|
|
||||||
|
factory _$VPNStateImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$VPNStateImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final AccessControl? accessControl;
|
||||||
|
@override
|
||||||
|
final VpnProps vpnProps;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'VPNState(accessControl: $accessControl, vpnProps: $vpnProps)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$VPNStateImpl &&
|
||||||
|
(identical(other.accessControl, accessControl) ||
|
||||||
|
other.accessControl == accessControl) &&
|
||||||
|
(identical(other.vpnProps, vpnProps) ||
|
||||||
|
other.vpnProps == vpnProps));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, accessControl, vpnProps);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$VPNStateImplCopyWith<_$VPNStateImpl> get copyWith =>
|
||||||
|
__$$VPNStateImplCopyWithImpl<_$VPNStateImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$VPNStateImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _VPNState implements VPNState {
|
||||||
|
const factory _VPNState(
|
||||||
|
{required final AccessControl? accessControl,
|
||||||
|
required final VpnProps vpnProps}) = _$VPNStateImpl;
|
||||||
|
|
||||||
|
factory _VPNState.fromJson(Map<String, dynamic> json) =
|
||||||
|
_$VPNStateImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
AccessControl? get accessControl;
|
||||||
|
@override
|
||||||
|
VpnProps get vpnProps;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$VPNStateImplCopyWith<_$VPNStateImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
WindowProps _$WindowPropsFromJson(Map<String, dynamic> json) {
|
WindowProps _$WindowPropsFromJson(Map<String, dynamic> json) {
|
||||||
return _WindowProps.fromJson(json);
|
return _WindowProps.fromJson(json);
|
||||||
}
|
}
|
||||||
@@ -715,3 +925,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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config()
|
|||||||
..proxiesSortType =
|
..proxiesSortType =
|
||||||
$enumDecodeNullable(_$ProxiesSortTypeEnumMap, json['proxiesSortType']) ??
|
$enumDecodeNullable(_$ProxiesSortTypeEnumMap, json['proxiesSortType']) ??
|
||||||
ProxiesSortType.none
|
ProxiesSortType.none
|
||||||
|
..proxiesLayout =
|
||||||
|
$enumDecodeNullable(_$ProxiesLayoutEnumMap, json['proxiesLayout']) ??
|
||||||
|
ProxiesLayout.standard
|
||||||
..isMinimizeOnExit = json['isMinimizeOnExit'] as bool? ?? true
|
..isMinimizeOnExit = json['isMinimizeOnExit'] as bool? ?? true
|
||||||
..isAccessControl = json['isAccessControl'] as bool? ?? false
|
..isAccessControl = json['isAccessControl'] as bool? ?? false
|
||||||
..accessControl =
|
..accessControl =
|
||||||
@@ -33,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
|
||||||
@@ -44,12 +45,16 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config()
|
|||||||
..proxyCardType =
|
..proxyCardType =
|
||||||
$enumDecodeNullable(_$ProxyCardTypeEnumMap, json['proxyCardType']) ??
|
$enumDecodeNullable(_$ProxyCardTypeEnumMap, json['proxyCardType']) ??
|
||||||
ProxyCardType.expand
|
ProxyCardType.expand
|
||||||
..proxiesColumns = (json['proxiesColumns'] as num?)?.toInt() ?? 2
|
|
||||||
..testUrl =
|
..testUrl =
|
||||||
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>?)
|
||||||
|
..showLabel = json['showLabel'] as bool? ?? false
|
||||||
|
..overrideDns = json['overrideDns'] as bool? ?? false;
|
||||||
|
|
||||||
Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||||
'profiles': instance.profiles,
|
'profiles': instance.profiles,
|
||||||
@@ -62,6 +67,7 @@ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
|||||||
'locale': instance.locale,
|
'locale': instance.locale,
|
||||||
'primaryColor': instance.primaryColor,
|
'primaryColor': instance.primaryColor,
|
||||||
'proxiesSortType': _$ProxiesSortTypeEnumMap[instance.proxiesSortType]!,
|
'proxiesSortType': _$ProxiesSortTypeEnumMap[instance.proxiesSortType]!,
|
||||||
|
'proxiesLayout': _$ProxiesLayoutEnumMap[instance.proxiesLayout]!,
|
||||||
'isMinimizeOnExit': instance.isMinimizeOnExit,
|
'isMinimizeOnExit': instance.isMinimizeOnExit,
|
||||||
'isAccessControl': instance.isAccessControl,
|
'isAccessControl': instance.isAccessControl,
|
||||||
'accessControl': instance.accessControl,
|
'accessControl': instance.accessControl,
|
||||||
@@ -69,17 +75,18 @@ 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,
|
||||||
'proxiesType': _$ProxiesTypeEnumMap[instance.proxiesType]!,
|
'proxiesType': _$ProxiesTypeEnumMap[instance.proxiesType]!,
|
||||||
'proxyCardType': _$ProxyCardTypeEnumMap[instance.proxyCardType]!,
|
'proxyCardType': _$ProxyCardTypeEnumMap[instance.proxyCardType]!,
|
||||||
'proxiesColumns': instance.proxiesColumns,
|
|
||||||
'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,
|
||||||
|
'showLabel': instance.showLabel,
|
||||||
|
'overrideDns': instance.overrideDns,
|
||||||
};
|
};
|
||||||
|
|
||||||
const _$ThemeModeEnumMap = {
|
const _$ThemeModeEnumMap = {
|
||||||
@@ -94,6 +101,12 @@ const _$ProxiesSortTypeEnumMap = {
|
|||||||
ProxiesSortType.name: 'name',
|
ProxiesSortType.name: 'name',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const _$ProxiesLayoutEnumMap = {
|
||||||
|
ProxiesLayout.loose: 'loose',
|
||||||
|
ProxiesLayout.standard: 'standard',
|
||||||
|
ProxiesLayout.tight: 'tight',
|
||||||
|
};
|
||||||
|
|
||||||
const _$ProxiesTypeEnumMap = {
|
const _$ProxiesTypeEnumMap = {
|
||||||
ProxiesType.tab: 'tab',
|
ProxiesType.tab: 'tab',
|
||||||
ProxiesType.list: 'list',
|
ProxiesType.list: 'list',
|
||||||
@@ -149,6 +162,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(),
|
||||||
@@ -159,12 +173,28 @@ 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,
|
||||||
'onlyProxy': instance.onlyProxy,
|
'onlyProxy': instance.onlyProxy,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_$VPNStateImpl _$$VPNStateImplFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$VPNStateImpl(
|
||||||
|
accessControl: json['accessControl'] == null
|
||||||
|
? null
|
||||||
|
: AccessControl.fromJson(
|
||||||
|
json['accessControl'] as Map<String, dynamic>),
|
||||||
|
vpnProps: VpnProps.fromJson(json['vpnProps'] as Map<String, dynamic>?),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$VPNStateImplToJson(_$VPNStateImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'accessControl': instance.accessControl,
|
||||||
|
'vpnProps': instance.vpnProps,
|
||||||
|
};
|
||||||
|
|
||||||
_$WindowPropsImpl _$$WindowPropsImplFromJson(Map<String, dynamic> json) =>
|
_$WindowPropsImpl _$$WindowPropsImplFromJson(Map<String, dynamic> json) =>
|
||||||
_$WindowPropsImpl(
|
_$WindowPropsImpl(
|
||||||
width: (json['width'] as num?)?.toDouble() ?? 1000,
|
width: (json['width'] as num?)?.toDouble() ?? 1000,
|
||||||
@@ -180,3 +210,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,
|
||||||
|
};
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ mixin _$ConfigExtendedParams {
|
|||||||
bool get isCompatible => throw _privateConstructorUsedError;
|
bool get isCompatible => throw _privateConstructorUsedError;
|
||||||
@JsonKey(name: "selected-map")
|
@JsonKey(name: "selected-map")
|
||||||
Map<String, String> get selectedMap => throw _privateConstructorUsedError;
|
Map<String, String> get selectedMap => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: "override-dns")
|
||||||
|
bool get overrideDns => throw _privateConstructorUsedError;
|
||||||
@JsonKey(name: "test-url")
|
@JsonKey(name: "test-url")
|
||||||
String get testUrl => throw _privateConstructorUsedError;
|
String get testUrl => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
@@ -45,6 +47,7 @@ abstract class $ConfigExtendedParamsCopyWith<$Res> {
|
|||||||
{@JsonKey(name: "is-patch") bool isPatch,
|
{@JsonKey(name: "is-patch") bool isPatch,
|
||||||
@JsonKey(name: "is-compatible") bool isCompatible,
|
@JsonKey(name: "is-compatible") bool isCompatible,
|
||||||
@JsonKey(name: "selected-map") Map<String, String> selectedMap,
|
@JsonKey(name: "selected-map") Map<String, String> selectedMap,
|
||||||
|
@JsonKey(name: "override-dns") bool overrideDns,
|
||||||
@JsonKey(name: "test-url") String testUrl});
|
@JsonKey(name: "test-url") String testUrl});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +68,7 @@ class _$ConfigExtendedParamsCopyWithImpl<$Res,
|
|||||||
Object? isPatch = null,
|
Object? isPatch = null,
|
||||||
Object? isCompatible = null,
|
Object? isCompatible = null,
|
||||||
Object? selectedMap = null,
|
Object? selectedMap = null,
|
||||||
|
Object? overrideDns = null,
|
||||||
Object? testUrl = null,
|
Object? testUrl = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_value.copyWith(
|
return _then(_value.copyWith(
|
||||||
@@ -80,6 +84,10 @@ class _$ConfigExtendedParamsCopyWithImpl<$Res,
|
|||||||
? _value.selectedMap
|
? _value.selectedMap
|
||||||
: selectedMap // ignore: cast_nullable_to_non_nullable
|
: selectedMap // ignore: cast_nullable_to_non_nullable
|
||||||
as Map<String, String>,
|
as Map<String, String>,
|
||||||
|
overrideDns: null == overrideDns
|
||||||
|
? _value.overrideDns
|
||||||
|
: overrideDns // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
testUrl: null == testUrl
|
testUrl: null == testUrl
|
||||||
? _value.testUrl
|
? _value.testUrl
|
||||||
: testUrl // ignore: cast_nullable_to_non_nullable
|
: testUrl // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -100,6 +108,7 @@ abstract class _$$ConfigExtendedParamsImplCopyWith<$Res>
|
|||||||
{@JsonKey(name: "is-patch") bool isPatch,
|
{@JsonKey(name: "is-patch") bool isPatch,
|
||||||
@JsonKey(name: "is-compatible") bool isCompatible,
|
@JsonKey(name: "is-compatible") bool isCompatible,
|
||||||
@JsonKey(name: "selected-map") Map<String, String> selectedMap,
|
@JsonKey(name: "selected-map") Map<String, String> selectedMap,
|
||||||
|
@JsonKey(name: "override-dns") bool overrideDns,
|
||||||
@JsonKey(name: "test-url") String testUrl});
|
@JsonKey(name: "test-url") String testUrl});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +126,7 @@ class __$$ConfigExtendedParamsImplCopyWithImpl<$Res>
|
|||||||
Object? isPatch = null,
|
Object? isPatch = null,
|
||||||
Object? isCompatible = null,
|
Object? isCompatible = null,
|
||||||
Object? selectedMap = null,
|
Object? selectedMap = null,
|
||||||
|
Object? overrideDns = null,
|
||||||
Object? testUrl = null,
|
Object? testUrl = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$ConfigExtendedParamsImpl(
|
return _then(_$ConfigExtendedParamsImpl(
|
||||||
@@ -132,6 +142,10 @@ class __$$ConfigExtendedParamsImplCopyWithImpl<$Res>
|
|||||||
? _value._selectedMap
|
? _value._selectedMap
|
||||||
: selectedMap // ignore: cast_nullable_to_non_nullable
|
: selectedMap // ignore: cast_nullable_to_non_nullable
|
||||||
as Map<String, String>,
|
as Map<String, String>,
|
||||||
|
overrideDns: null == overrideDns
|
||||||
|
? _value.overrideDns
|
||||||
|
: overrideDns // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
testUrl: null == testUrl
|
testUrl: null == testUrl
|
||||||
? _value.testUrl
|
? _value.testUrl
|
||||||
: testUrl // ignore: cast_nullable_to_non_nullable
|
: testUrl // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -148,6 +162,7 @@ class _$ConfigExtendedParamsImpl implements _ConfigExtendedParams {
|
|||||||
@JsonKey(name: "is-compatible") required this.isCompatible,
|
@JsonKey(name: "is-compatible") required this.isCompatible,
|
||||||
@JsonKey(name: "selected-map")
|
@JsonKey(name: "selected-map")
|
||||||
required final Map<String, String> selectedMap,
|
required final Map<String, String> selectedMap,
|
||||||
|
@JsonKey(name: "override-dns") required this.overrideDns,
|
||||||
@JsonKey(name: "test-url") required this.testUrl})
|
@JsonKey(name: "test-url") required this.testUrl})
|
||||||
: _selectedMap = selectedMap;
|
: _selectedMap = selectedMap;
|
||||||
|
|
||||||
@@ -169,13 +184,16 @@ class _$ConfigExtendedParamsImpl implements _ConfigExtendedParams {
|
|||||||
return EqualUnmodifiableMapView(_selectedMap);
|
return EqualUnmodifiableMapView(_selectedMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey(name: "override-dns")
|
||||||
|
final bool overrideDns;
|
||||||
@override
|
@override
|
||||||
@JsonKey(name: "test-url")
|
@JsonKey(name: "test-url")
|
||||||
final String testUrl;
|
final String testUrl;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'ConfigExtendedParams(isPatch: $isPatch, isCompatible: $isCompatible, selectedMap: $selectedMap, testUrl: $testUrl)';
|
return 'ConfigExtendedParams(isPatch: $isPatch, isCompatible: $isCompatible, selectedMap: $selectedMap, overrideDns: $overrideDns, testUrl: $testUrl)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -188,13 +206,15 @@ class _$ConfigExtendedParamsImpl implements _ConfigExtendedParams {
|
|||||||
other.isCompatible == isCompatible) &&
|
other.isCompatible == isCompatible) &&
|
||||||
const DeepCollectionEquality()
|
const DeepCollectionEquality()
|
||||||
.equals(other._selectedMap, _selectedMap) &&
|
.equals(other._selectedMap, _selectedMap) &&
|
||||||
|
(identical(other.overrideDns, overrideDns) ||
|
||||||
|
other.overrideDns == overrideDns) &&
|
||||||
(identical(other.testUrl, testUrl) || other.testUrl == testUrl));
|
(identical(other.testUrl, testUrl) || other.testUrl == testUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, isPatch, isCompatible,
|
int get hashCode => Object.hash(runtimeType, isPatch, isCompatible,
|
||||||
const DeepCollectionEquality().hash(_selectedMap), testUrl);
|
const DeepCollectionEquality().hash(_selectedMap), overrideDns, testUrl);
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
@@ -218,6 +238,7 @@ abstract class _ConfigExtendedParams implements ConfigExtendedParams {
|
|||||||
@JsonKey(name: "is-compatible") required final bool isCompatible,
|
@JsonKey(name: "is-compatible") required final bool isCompatible,
|
||||||
@JsonKey(name: "selected-map")
|
@JsonKey(name: "selected-map")
|
||||||
required final Map<String, String> selectedMap,
|
required final Map<String, String> selectedMap,
|
||||||
|
@JsonKey(name: "override-dns") required final bool overrideDns,
|
||||||
@JsonKey(name: "test-url") required final String testUrl}) =
|
@JsonKey(name: "test-url") required final String testUrl}) =
|
||||||
_$ConfigExtendedParamsImpl;
|
_$ConfigExtendedParamsImpl;
|
||||||
|
|
||||||
@@ -234,6 +255,9 @@ abstract class _ConfigExtendedParams implements ConfigExtendedParams {
|
|||||||
@JsonKey(name: "selected-map")
|
@JsonKey(name: "selected-map")
|
||||||
Map<String, String> get selectedMap;
|
Map<String, String> get selectedMap;
|
||||||
@override
|
@override
|
||||||
|
@JsonKey(name: "override-dns")
|
||||||
|
bool get overrideDns;
|
||||||
|
@override
|
||||||
@JsonKey(name: "test-url")
|
@JsonKey(name: "test-url")
|
||||||
String get testUrl;
|
String get testUrl;
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ _$ConfigExtendedParamsImpl _$$ConfigExtendedParamsImplFromJson(
|
|||||||
isPatch: json['is-patch'] as bool,
|
isPatch: json['is-patch'] as bool,
|
||||||
isCompatible: json['is-compatible'] as bool,
|
isCompatible: json['is-compatible'] as bool,
|
||||||
selectedMap: Map<String, String>.from(json['selected-map'] as Map),
|
selectedMap: Map<String, String>.from(json['selected-map'] as Map),
|
||||||
|
overrideDns: json['override-dns'] as bool,
|
||||||
testUrl: json['test-url'] as String,
|
testUrl: json['test-url'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ Map<String, dynamic> _$$ConfigExtendedParamsImplToJson(
|
|||||||
'is-patch': instance.isPatch,
|
'is-patch': instance.isPatch,
|
||||||
'is-compatible': instance.isCompatible,
|
'is-compatible': instance.isCompatible,
|
||||||
'selected-map': instance.selectedMap,
|
'selected-map': instance.selectedMap,
|
||||||
|
'override-dns': instance.overrideDns,
|
||||||
'test-url': instance.testUrl,
|
'test-url': instance.testUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ mixin _$Group {
|
|||||||
List<Proxy> get all => throw _privateConstructorUsedError;
|
List<Proxy> get all => throw _privateConstructorUsedError;
|
||||||
String? get now => throw _privateConstructorUsedError;
|
String? get now => throw _privateConstructorUsedError;
|
||||||
bool? get hidden => throw _privateConstructorUsedError;
|
bool? get hidden => throw _privateConstructorUsedError;
|
||||||
|
String get icon => throw _privateConstructorUsedError;
|
||||||
String get name => throw _privateConstructorUsedError;
|
String get name => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
@@ -41,6 +42,7 @@ abstract class $GroupCopyWith<$Res> {
|
|||||||
List<Proxy> all,
|
List<Proxy> all,
|
||||||
String? now,
|
String? now,
|
||||||
bool? hidden,
|
bool? hidden,
|
||||||
|
String icon,
|
||||||
String name});
|
String name});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +63,7 @@ class _$GroupCopyWithImpl<$Res, $Val extends Group>
|
|||||||
Object? all = null,
|
Object? all = null,
|
||||||
Object? now = freezed,
|
Object? now = freezed,
|
||||||
Object? hidden = freezed,
|
Object? hidden = freezed,
|
||||||
|
Object? icon = null,
|
||||||
Object? name = null,
|
Object? name = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_value.copyWith(
|
return _then(_value.copyWith(
|
||||||
@@ -80,6 +83,10 @@ class _$GroupCopyWithImpl<$Res, $Val extends Group>
|
|||||||
? _value.hidden
|
? _value.hidden
|
||||||
: hidden // ignore: cast_nullable_to_non_nullable
|
: hidden // ignore: cast_nullable_to_non_nullable
|
||||||
as bool?,
|
as bool?,
|
||||||
|
icon: null == icon
|
||||||
|
? _value.icon
|
||||||
|
: icon // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
name: null == name
|
name: null == name
|
||||||
? _value.name
|
? _value.name
|
||||||
: name // ignore: cast_nullable_to_non_nullable
|
: name // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -100,6 +107,7 @@ abstract class _$$GroupImplCopyWith<$Res> implements $GroupCopyWith<$Res> {
|
|||||||
List<Proxy> all,
|
List<Proxy> all,
|
||||||
String? now,
|
String? now,
|
||||||
bool? hidden,
|
bool? hidden,
|
||||||
|
String icon,
|
||||||
String name});
|
String name});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +126,7 @@ class __$$GroupImplCopyWithImpl<$Res>
|
|||||||
Object? all = null,
|
Object? all = null,
|
||||||
Object? now = freezed,
|
Object? now = freezed,
|
||||||
Object? hidden = freezed,
|
Object? hidden = freezed,
|
||||||
|
Object? icon = null,
|
||||||
Object? name = null,
|
Object? name = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$GroupImpl(
|
return _then(_$GroupImpl(
|
||||||
@@ -137,6 +146,10 @@ class __$$GroupImplCopyWithImpl<$Res>
|
|||||||
? _value.hidden
|
? _value.hidden
|
||||||
: hidden // ignore: cast_nullable_to_non_nullable
|
: hidden // ignore: cast_nullable_to_non_nullable
|
||||||
as bool?,
|
as bool?,
|
||||||
|
icon: null == icon
|
||||||
|
? _value.icon
|
||||||
|
: icon // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
name: null == name
|
name: null == name
|
||||||
? _value.name
|
? _value.name
|
||||||
: name // ignore: cast_nullable_to_non_nullable
|
: name // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -153,6 +166,7 @@ class _$GroupImpl implements _Group {
|
|||||||
final List<Proxy> all = const [],
|
final List<Proxy> all = const [],
|
||||||
this.now,
|
this.now,
|
||||||
this.hidden,
|
this.hidden,
|
||||||
|
this.icon = "",
|
||||||
required this.name})
|
required this.name})
|
||||||
: _all = all;
|
: _all = all;
|
||||||
|
|
||||||
@@ -175,11 +189,14 @@ class _$GroupImpl implements _Group {
|
|||||||
@override
|
@override
|
||||||
final bool? hidden;
|
final bool? hidden;
|
||||||
@override
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final String icon;
|
||||||
|
@override
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Group(type: $type, all: $all, now: $now, hidden: $hidden, name: $name)';
|
return 'Group(type: $type, all: $all, now: $now, hidden: $hidden, icon: $icon, name: $name)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -191,13 +208,14 @@ class _$GroupImpl implements _Group {
|
|||||||
const DeepCollectionEquality().equals(other._all, _all) &&
|
const DeepCollectionEquality().equals(other._all, _all) &&
|
||||||
(identical(other.now, now) || other.now == now) &&
|
(identical(other.now, now) || other.now == now) &&
|
||||||
(identical(other.hidden, hidden) || other.hidden == hidden) &&
|
(identical(other.hidden, hidden) || other.hidden == hidden) &&
|
||||||
|
(identical(other.icon, icon) || other.icon == icon) &&
|
||||||
(identical(other.name, name) || other.name == name));
|
(identical(other.name, name) || other.name == name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, type,
|
int get hashCode => Object.hash(runtimeType, type,
|
||||||
const DeepCollectionEquality().hash(_all), now, hidden, name);
|
const DeepCollectionEquality().hash(_all), now, hidden, icon, name);
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
@@ -219,6 +237,7 @@ abstract class _Group implements Group {
|
|||||||
final List<Proxy> all,
|
final List<Proxy> all,
|
||||||
final String? now,
|
final String? now,
|
||||||
final bool? hidden,
|
final bool? hidden,
|
||||||
|
final String icon,
|
||||||
required final String name}) = _$GroupImpl;
|
required final String name}) = _$GroupImpl;
|
||||||
|
|
||||||
factory _Group.fromJson(Map<String, dynamic> json) = _$GroupImpl.fromJson;
|
factory _Group.fromJson(Map<String, dynamic> json) = _$GroupImpl.fromJson;
|
||||||
@@ -232,6 +251,8 @@ abstract class _Group implements Group {
|
|||||||
@override
|
@override
|
||||||
bool? get hidden;
|
bool? get hidden;
|
||||||
@override
|
@override
|
||||||
|
String get icon;
|
||||||
|
@override
|
||||||
String get name;
|
String get name;
|
||||||
@override
|
@override
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ _$GroupImpl _$$GroupImplFromJson(Map<String, dynamic> json) => _$GroupImpl(
|
|||||||
const [],
|
const [],
|
||||||
now: json['now'] as String?,
|
now: json['now'] as String?,
|
||||||
hidden: json['hidden'] as bool?,
|
hidden: json['hidden'] as bool?,
|
||||||
|
icon: json['icon'] as String? ?? "",
|
||||||
name: json['name'] as String,
|
name: json['name'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ Map<String, dynamic> _$$GroupImplToJson(_$GroupImpl instance) =>
|
|||||||
'all': instance.all,
|
'all': instance.all,
|
||||||
'now': instance.now,
|
'now': instance.now,
|
||||||
'hidden': instance.hidden,
|
'hidden': instance.hidden,
|
||||||
|
'icon': instance.icon,
|
||||||
'name': instance.name,
|
'name': instance.name,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,7 @@ class Group with _$Group {
|
|||||||
@Default([]) List<Proxy> all,
|
@Default([]) List<Proxy> all,
|
||||||
String? now,
|
String? now,
|
||||||
bool? hidden,
|
bool? hidden,
|
||||||
|
@Default("") String icon,
|
||||||
required String name,
|
required String name,
|
||||||
}) = _Group;
|
}) = _Group;
|
||||||
|
|
||||||
@@ -41,4 +42,4 @@ class Proxy with _$Proxy {
|
|||||||
}) = _Proxy;
|
}) = _Proxy;
|
||||||
|
|
||||||
factory Proxy.fromJson(Map<String, Object?> json) => _$ProxyFromJson(json);
|
factory Proxy.fromJson(Map<String, Object?> json) => _$ProxyFromJson(json);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import 'package:fl_clash/enum/enum.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:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:lpinyin/lpinyin.dart';
|
|
||||||
|
|
||||||
part 'generated/selector.freezed.dart';
|
part 'generated/selector.freezed.dart';
|
||||||
|
|
||||||
@@ -37,10 +36,18 @@ class ProfilesSelectorState with _$ProfilesSelectorState {
|
|||||||
const factory ProfilesSelectorState({
|
const factory ProfilesSelectorState({
|
||||||
required List<Profile> profiles,
|
required List<Profile> profiles,
|
||||||
required String? currentProfileId,
|
required String? currentProfileId,
|
||||||
required ViewMode viewMode,
|
required int columns,
|
||||||
}) = _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({
|
||||||
@@ -56,7 +63,9 @@ class TrayContainerSelectorState with _$TrayContainerSelectorState {
|
|||||||
const factory TrayContainerSelectorState({
|
const factory TrayContainerSelectorState({
|
||||||
required Mode mode,
|
required Mode mode,
|
||||||
required bool autoLaunch,
|
required bool autoLaunch,
|
||||||
required bool isRun,
|
required bool systemProxy,
|
||||||
|
required bool tunEnable,
|
||||||
|
required bool isStart,
|
||||||
required String? locale,
|
required String? locale,
|
||||||
}) = _TrayContainerSelectorState;
|
}) = _TrayContainerSelectorState;
|
||||||
}
|
}
|
||||||
@@ -148,19 +157,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(
|
other.getPinyin(a.label),
|
||||||
PinyinHelper.getPinyin(a.label),
|
other.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;
|
||||||
@@ -172,14 +181,6 @@ extension PackageListSelectorStateExt on PackageListSelectorState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
|
||||||
class ColumnsSelectorState with _$ColumnsSelectorState {
|
|
||||||
const factory ColumnsSelectorState({
|
|
||||||
required int columns,
|
|
||||||
required ViewMode viewMode,
|
|
||||||
}) = _ColumnsSelectorState;
|
|
||||||
}
|
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class ProxiesListHeaderSelectorState with _$ProxiesListHeaderSelectorState {
|
class ProxiesListHeaderSelectorState with _$ProxiesListHeaderSelectorState {
|
||||||
const factory ProxiesListHeaderSelectorState({
|
const factory ProxiesListHeaderSelectorState({
|
||||||
@@ -195,3 +196,51 @@ 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 HttpOverridesState with _$HttpOverridesState {
|
||||||
|
const factory HttpOverridesState({
|
||||||
|
required bool isStart,
|
||||||
|
required int port,
|
||||||
|
}) = _HttpOverridesState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 HostsMap hosts,
|
||||||
|
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,62 +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,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
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';
|
||||||
@@ -18,14 +19,18 @@ class GlobalState {
|
|||||||
Timer? timer;
|
Timer? timer;
|
||||||
Timer? groupsUpdateTimer;
|
Timer? groupsUpdateTimer;
|
||||||
var isVpnService = false;
|
var isVpnService = false;
|
||||||
|
var autoRun = false;
|
||||||
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) {
|
||||||
@@ -54,6 +59,7 @@ class GlobalState {
|
|||||||
isPatch: isPatch,
|
isPatch: isPatch,
|
||||||
isCompatible: true,
|
isCompatible: true,
|
||||||
selectedMap: config.currentSelectedMap,
|
selectedMap: config.currentSelectedMap,
|
||||||
|
overrideDns: config.overrideDns,
|
||||||
testUrl: config.testUrl,
|
testUrl: config.testUrl,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -65,23 +71,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 +131,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 +224,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,12 @@
|
|||||||
import 'package:fl_clash/clash/clash.dart';
|
import 'package:fl_clash/clash/clash.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/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 +21,50 @@ 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,
|
||||||
|
hosts: clashConfig.hosts,
|
||||||
|
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:
|
||||||
@@ -38,8 +78,12 @@ class _ClashContainerState extends State<ClashContainer>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_changeProfileHandle() {
|
_changeProfile() async {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
|
if (globalState.autoRun) {
|
||||||
|
globalState.autoRun = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
final appController = globalState.appController;
|
final appController = globalState.appController;
|
||||||
appController.appState.delayMap = {};
|
appController.appState.delayMap = {};
|
||||||
await appController.applyProfile();
|
await appController.applyProfile();
|
||||||
@@ -50,7 +94,7 @@ class _ClashContainerState extends State<ClashContainer>
|
|||||||
return Selector<Config, String?>(
|
return Selector<Config, String?>(
|
||||||
selector: (_, config) => config.currentProfileId,
|
selector: (_, config) => config.currentProfileId,
|
||||||
builder: (__, state, child) {
|
builder: (__, state, child) {
|
||||||
_changeProfileHandle();
|
_changeProfile();
|
||||||
return child!;
|
return child!;
|
||||||
},
|
},
|
||||||
child: child,
|
child: child,
|
||||||
@@ -61,7 +105,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 +135,10 @@ 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);
|
||||||
|
if (log.logLevel == LogLevel.error) {
|
||||||
|
globalState.appController.showSnackBar(log.payload ?? '');
|
||||||
|
}
|
||||||
|
// debugPrint("$log");
|
||||||
super.onLog(log);
|
super.onLog(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,13 +159,4 @@ class _ClashContainerState extends State<ClashContainer>
|
|||||||
appController.addCheckIpNumDebounce();
|
appController.addCheckIpNumDebounce();
|
||||||
super.onLoaded(providerName);
|
super.onLoaded(providerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> onStarted(String runTime) async {
|
|
||||||
super.onStarted(runTime);
|
|
||||||
proxy?.updateStartTime();
|
|
||||||
final appController = globalState.appController;
|
|
||||||
await appController.applyProfile(isPrue: true);
|
|
||||||
appController.addCheckIpNumDebounce();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
293
lib/widgets/input.dart
Normal file
293
lib/widgets/input.dart
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
import 'package:fl_clash/common/constant.dart';
|
||||||
|
import 'package:fl_clash/state.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../common/app_localizations.dart';
|
||||||
|
import 'card.dart';
|
||||||
|
import 'float_layout.dart';
|
||||||
|
import 'list.dart';
|
||||||
|
|
||||||
|
class OptionsDialog<T> extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final List<T> options;
|
||||||
|
final T value;
|
||||||
|
final String Function(T value) textBuilder;
|
||||||
|
|
||||||
|
const OptionsDialog({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
required this.options,
|
||||||
|
required this.textBuilder,
|
||||||
|
required this.value,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(title),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8,
|
||||||
|
vertical: 16,
|
||||||
|
),
|
||||||
|
content: SizedBox(
|
||||||
|
width: 250,
|
||||||
|
child: Wrap(
|
||||||
|
children: [
|
||||||
|
for (final option in options)
|
||||||
|
ListItem.radio(
|
||||||
|
delegate: RadioDelegate(
|
||||||
|
value: option,
|
||||||
|
groupValue: value,
|
||||||
|
onChanged: (T? value) {
|
||||||
|
Navigator.of(context).pop(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
this.textBuilder(option),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class InputDialog extends StatefulWidget {
|
||||||
|
final String title;
|
||||||
|
final String value;
|
||||||
|
final String? suffixText;
|
||||||
|
|
||||||
|
const InputDialog({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
required this.value,
|
||||||
|
this.suffixText,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<InputDialog> createState() => _InputDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _InputDialogState extends State<InputDialog> {
|
||||||
|
late TextEditingController textController;
|
||||||
|
|
||||||
|
String get value => widget.value;
|
||||||
|
|
||||||
|
String get title => widget.title;
|
||||||
|
|
||||||
|
String? get suffixText => widget.suffixText;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
textController = TextEditingController(
|
||||||
|
text: value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_handleUpdate() async {
|
||||||
|
final text = textController.value.text;
|
||||||
|
if (text.isEmpty) return;
|
||||||
|
Navigator.of(context).pop<String>(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(title),
|
||||||
|
content: SizedBox(
|
||||||
|
width: 300,
|
||||||
|
child: Wrap(
|
||||||
|
runSpacing: 16,
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
maxLines: 1,
|
||||||
|
minLines: 1,
|
||||||
|
controller: textController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
suffixText: suffixText,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: _handleUpdate,
|
||||||
|
child: Text(appLocalizations.submit),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class UpdatePage<T> extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final Iterable<T> items;
|
||||||
|
final Widget Function(T item) titleBuilder;
|
||||||
|
final Widget Function(T item)? subtitleBuilder;
|
||||||
|
final Function(T item) onAdd;
|
||||||
|
final Function(T item) onRemove;
|
||||||
|
final bool isMap;
|
||||||
|
|
||||||
|
const UpdatePage({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
required this.items,
|
||||||
|
required this.titleBuilder,
|
||||||
|
required this.onRemove,
|
||||||
|
required this.onAdd,
|
||||||
|
this.isMap = false,
|
||||||
|
this.subtitleBuilder,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return FloatLayout(
|
||||||
|
floatingWidget: FloatWrapper(
|
||||||
|
child: FloatingActionButton(
|
||||||
|
onPressed: () async {
|
||||||
|
final value = await globalState.showCommonDialog<T>(
|
||||||
|
child: AddDialog(
|
||||||
|
isMap: isMap,
|
||||||
|
title: title,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (value == null) return;
|
||||||
|
onAdd(value);
|
||||||
|
},
|
||||||
|
child: const Icon(Icons.add),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: ListView.builder(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
bottom: 16 + 64,
|
||||||
|
left: 16,
|
||||||
|
right: 16,
|
||||||
|
),
|
||||||
|
itemCount: items.length,
|
||||||
|
itemBuilder: (_, index) {
|
||||||
|
final e = items.toList()[index];
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: CommonCard(
|
||||||
|
child: ListItem(
|
||||||
|
title: titleBuilder(e),
|
||||||
|
subtitle: subtitleBuilder != null ? subtitleBuilder!(e) : null,
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: const Icon(Icons.delete_outline),
|
||||||
|
onPressed: () {
|
||||||
|
onRemove(e);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AddDialog extends StatefulWidget {
|
||||||
|
final String title;
|
||||||
|
final bool isMap;
|
||||||
|
|
||||||
|
const AddDialog({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
required this.isMap,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AddDialog> createState() => _AddDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AddDialogState extends State<AddDialog> {
|
||||||
|
late TextEditingController keyController;
|
||||||
|
late TextEditingController valueController;
|
||||||
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
keyController = TextEditingController();
|
||||||
|
valueController = TextEditingController();
|
||||||
|
}
|
||||||
|
|
||||||
|
_submit() {
|
||||||
|
if (!_formKey.currentState!.validate()) return;
|
||||||
|
if (widget.isMap) {
|
||||||
|
Navigator.of(context).pop<MapEntry<String, String>>(
|
||||||
|
MapEntry(
|
||||||
|
keyController.text,
|
||||||
|
valueController.text,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop<String>(
|
||||||
|
valueController.text,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(widget.title),
|
||||||
|
content: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: SizedBox(
|
||||||
|
width: dialogCommonWidth,
|
||||||
|
child: Wrap(
|
||||||
|
runSpacing: 16,
|
||||||
|
children: [
|
||||||
|
if (widget.isMap)
|
||||||
|
TextFormField(
|
||||||
|
maxLines: 2,
|
||||||
|
minLines: 1,
|
||||||
|
controller: keyController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
prefixIcon: const Icon(Icons.key),
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
labelText: appLocalizations.key,
|
||||||
|
),
|
||||||
|
validator: (String? value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return appLocalizations.keyNotEmpty;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
TextFormField(
|
||||||
|
maxLines: 3,
|
||||||
|
minLines: 1,
|
||||||
|
controller: valueController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
prefixIcon: const Icon(Icons.label),
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
labelText: appLocalizations.value,
|
||||||
|
),
|
||||||
|
validator: (String? value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return appLocalizations.valueNotEmpty;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: _submit,
|
||||||
|
child: Text(appLocalizations.confirm),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import 'package:fl_clash/widgets/open_container.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'card.dart';
|
import 'card.dart';
|
||||||
|
import 'input.dart';
|
||||||
import 'sheet.dart';
|
import 'sheet.dart';
|
||||||
import 'scaffold.dart';
|
import 'scaffold.dart';
|
||||||
|
|
||||||
@@ -48,11 +49,13 @@ class OpenDelegate extends Delegate {
|
|||||||
final Widget widget;
|
final Widget widget;
|
||||||
final String title;
|
final String title;
|
||||||
final double? extendPageWidth;
|
final double? extendPageWidth;
|
||||||
|
final bool isBlur;
|
||||||
|
|
||||||
const OpenDelegate({
|
const OpenDelegate({
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.widget,
|
required this.widget,
|
||||||
this.extendPageWidth,
|
this.extendPageWidth,
|
||||||
|
this.isBlur = true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +71,36 @@ class NextDelegate extends Delegate {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class OptionsDelegate<T> extends Delegate {
|
||||||
|
final List<T> options;
|
||||||
|
final String title;
|
||||||
|
final T value;
|
||||||
|
final String Function(T value) textBuilder;
|
||||||
|
final Function(T? value) onChanged;
|
||||||
|
|
||||||
|
const OptionsDelegate({
|
||||||
|
required this.title,
|
||||||
|
required this.options,
|
||||||
|
required this.textBuilder,
|
||||||
|
required this.value,
|
||||||
|
required this.onChanged,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
class InputDelegate extends Delegate {
|
||||||
|
final String title;
|
||||||
|
final String value;
|
||||||
|
final String? suffixText;
|
||||||
|
final Function(String? value) onChanged;
|
||||||
|
|
||||||
|
const InputDelegate({
|
||||||
|
required this.title,
|
||||||
|
required this.value,
|
||||||
|
this.suffixText,
|
||||||
|
required this.onChanged,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
class ListItem<T> extends StatelessWidget {
|
class ListItem<T> extends StatelessWidget {
|
||||||
final Widget? leading;
|
final Widget? leading;
|
||||||
final Widget title;
|
final Widget title;
|
||||||
@@ -106,6 +139,32 @@ class ListItem<T> extends StatelessWidget {
|
|||||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||||
}) : onTap = null;
|
}) : onTap = null;
|
||||||
|
|
||||||
|
const ListItem.options({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
this.subtitle,
|
||||||
|
this.leading,
|
||||||
|
this.padding = const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
this.trailing,
|
||||||
|
required OptionsDelegate<T> this.delegate,
|
||||||
|
this.horizontalTitleGap,
|
||||||
|
this.prue,
|
||||||
|
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||||
|
}) : onTap = null;
|
||||||
|
|
||||||
|
const ListItem.input({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
this.subtitle,
|
||||||
|
this.leading,
|
||||||
|
this.padding = const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
this.trailing,
|
||||||
|
required InputDelegate this.delegate,
|
||||||
|
this.horizontalTitleGap,
|
||||||
|
this.prue,
|
||||||
|
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||||
|
}) : onTap = null;
|
||||||
|
|
||||||
const ListItem.next({
|
const ListItem.next({
|
||||||
super.key,
|
super.key,
|
||||||
required this.title,
|
required this.title,
|
||||||
@@ -125,7 +184,7 @@ class ListItem<T> extends StatelessWidget {
|
|||||||
this.subtitle,
|
this.subtitle,
|
||||||
this.leading,
|
this.leading,
|
||||||
this.padding = const EdgeInsets.only(left: 16, right: 8),
|
this.padding = const EdgeInsets.only(left: 16, right: 8),
|
||||||
required CheckboxDelegate this.delegate,
|
required CheckboxDelegate<T> this.delegate,
|
||||||
this.horizontalTitleGap,
|
this.horizontalTitleGap,
|
||||||
this.prue,
|
this.prue,
|
||||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||||
@@ -138,7 +197,7 @@ class ListItem<T> extends StatelessWidget {
|
|||||||
this.subtitle,
|
this.subtitle,
|
||||||
this.leading,
|
this.leading,
|
||||||
this.padding = const EdgeInsets.only(left: 16, right: 8),
|
this.padding = const EdgeInsets.only(left: 16, right: 8),
|
||||||
required SwitchDelegate this.delegate,
|
required SwitchDelegate<T> this.delegate,
|
||||||
this.horizontalTitleGap,
|
this.horizontalTitleGap,
|
||||||
this.prue,
|
this.prue,
|
||||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||||
@@ -227,6 +286,7 @@ class ListItem<T> extends StatelessWidget {
|
|||||||
body: child,
|
body: child,
|
||||||
title: openDelegate.title,
|
title: openDelegate.title,
|
||||||
extendPageWidth: openDelegate.extendPageWidth,
|
extendPageWidth: openDelegate.extendPageWidth,
|
||||||
|
isBlur: openDelegate.isBlur,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -247,6 +307,37 @@ class ListItem<T> extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (delegate is OptionsDelegate) {
|
||||||
|
final optionsDelegate = delegate as OptionsDelegate<T>;
|
||||||
|
return _buildListTile(
|
||||||
|
onTap: () async {
|
||||||
|
final value = await globalState.showCommonDialog<T>(
|
||||||
|
child: OptionsDialog<T>(
|
||||||
|
title: optionsDelegate.title,
|
||||||
|
options: optionsDelegate.options,
|
||||||
|
textBuilder: optionsDelegate.textBuilder,
|
||||||
|
value: optionsDelegate.value,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
optionsDelegate.onChanged(value);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (delegate is InputDelegate) {
|
||||||
|
final inputDelegate = delegate as InputDelegate;
|
||||||
|
return _buildListTile(
|
||||||
|
onTap: () async {
|
||||||
|
final value = await globalState.showCommonDialog<String>(
|
||||||
|
child: InputDialog(
|
||||||
|
title: inputDelegate.title,
|
||||||
|
value: inputDelegate.value,
|
||||||
|
suffixText: inputDelegate.suffixText,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
inputDelegate.onChanged(value);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
if (delegate is NextDelegate) {
|
if (delegate is NextDelegate) {
|
||||||
final nextDelegate = delegate as NextDelegate;
|
final nextDelegate = delegate as NextDelegate;
|
||||||
return _buildListTile(
|
return _buildListTile(
|
||||||
@@ -423,5 +514,8 @@ Widget generateListView(List<Widget> items) {
|
|||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: items.length,
|
itemCount: items.length,
|
||||||
itemBuilder: (_, index) => items[index],
|
itemBuilder: (_, index) => items[index],
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
bottom: 16,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -286,23 +286,6 @@ class _OpenContainerRoute<T> extends ModalRoute<T> {
|
|||||||
final _FlippableTweenSequence<double> _closedOpacityTween;
|
final _FlippableTweenSequence<double> _closedOpacityTween;
|
||||||
final _FlippableTweenSequence<double> _openOpacityTween;
|
final _FlippableTweenSequence<double> _openOpacityTween;
|
||||||
late _FlippableTweenSequence<Color?> _colorTween;
|
late _FlippableTweenSequence<Color?> _colorTween;
|
||||||
|
|
||||||
static final TweenSequence<Color?> _scrimFadeInTween = TweenSequence<Color?>(
|
|
||||||
<TweenSequenceItem<Color?>>[
|
|
||||||
TweenSequenceItem<Color?>(
|
|
||||||
tween: ColorTween(begin: Colors.transparent, end: Colors.black54),
|
|
||||||
weight: 1 / 5,
|
|
||||||
),
|
|
||||||
TweenSequenceItem<Color>(
|
|
||||||
tween: ConstantTween<Color>(Colors.black54),
|
|
||||||
weight: 4 / 5,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
static final Tween<Color?> _scrimFadeOutTween = ColorTween(
|
|
||||||
begin: Colors.transparent,
|
|
||||||
end: Colors.black54,
|
|
||||||
);
|
|
||||||
final GlobalKey _openBuilderKey = GlobalKey();
|
final GlobalKey _openBuilderKey = GlobalKey();
|
||||||
final RectTween _rectTween = RectTween();
|
final RectTween _rectTween = RectTween();
|
||||||
|
|
||||||
@@ -486,20 +469,17 @@ class _OpenContainerRoute<T> extends ModalRoute<T> {
|
|||||||
closedOpacityTween = _closedOpacityTween;
|
closedOpacityTween = _closedOpacityTween;
|
||||||
openOpacityTween = _openOpacityTween;
|
openOpacityTween = _openOpacityTween;
|
||||||
colorTween = _colorTween;
|
colorTween = _colorTween;
|
||||||
scrimTween = _scrimFadeInTween;
|
|
||||||
break;
|
break;
|
||||||
case AnimationStatus.reverse:
|
case AnimationStatus.reverse:
|
||||||
if (_transitionWasInterrupted) {
|
if (_transitionWasInterrupted) {
|
||||||
closedOpacityTween = _closedOpacityTween;
|
closedOpacityTween = _closedOpacityTween;
|
||||||
openOpacityTween = _openOpacityTween;
|
openOpacityTween = _openOpacityTween;
|
||||||
colorTween = _colorTween;
|
colorTween = _colorTween;
|
||||||
scrimTween = _scrimFadeInTween;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
closedOpacityTween = _closedOpacityTween.flipped;
|
closedOpacityTween = _closedOpacityTween.flipped;
|
||||||
openOpacityTween = _openOpacityTween.flipped;
|
openOpacityTween = _openOpacityTween.flipped;
|
||||||
colorTween = _colorTween.flipped;
|
colorTween = _colorTween.flipped;
|
||||||
scrimTween = _scrimFadeOutTween;
|
|
||||||
break;
|
break;
|
||||||
case AnimationStatus.completed:
|
case AnimationStatus.completed:
|
||||||
assert(false); // Unreachable.
|
assert(false); // Unreachable.
|
||||||
@@ -508,74 +488,70 @@ class _OpenContainerRoute<T> extends ModalRoute<T> {
|
|||||||
assert(colorTween != null);
|
assert(colorTween != null);
|
||||||
assert(closedOpacityTween != null);
|
assert(closedOpacityTween != null);
|
||||||
assert(openOpacityTween != null);
|
assert(openOpacityTween != null);
|
||||||
assert(scrimTween != null);
|
|
||||||
|
|
||||||
final Rect rect = _rectTween.evaluate(curvedAnimation)!;
|
final Rect rect = _rectTween.evaluate(curvedAnimation)!;
|
||||||
return SizedBox.expand(
|
return SizedBox.expand(
|
||||||
child: Container(
|
child: Align(
|
||||||
color: scrimTween!.evaluate(curvedAnimation),
|
alignment: Alignment.topLeft,
|
||||||
child: Align(
|
child: Transform.translate(
|
||||||
alignment: Alignment.topLeft,
|
offset: Offset(rect.left, rect.top),
|
||||||
child: Transform.translate(
|
child: SizedBox(
|
||||||
offset: Offset(rect.left, rect.top),
|
width: rect.width,
|
||||||
child: SizedBox(
|
height: rect.height,
|
||||||
width: rect.width,
|
child: Material(
|
||||||
height: rect.height,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: Material(
|
animationDuration: Duration.zero,
|
||||||
clipBehavior: Clip.antiAlias,
|
color: colorTween!.evaluate(animation),
|
||||||
animationDuration: Duration.zero,
|
child: Stack(
|
||||||
color: colorTween!.evaluate(animation),
|
fit: StackFit.passthrough,
|
||||||
child: Stack(
|
children: <Widget>[
|
||||||
fit: StackFit.passthrough,
|
// Closed child fading out.
|
||||||
children: <Widget>[
|
FittedBox(
|
||||||
// Closed child fading out.
|
fit: BoxFit.fitWidth,
|
||||||
FittedBox(
|
alignment: Alignment.topLeft,
|
||||||
fit: BoxFit.fitWidth,
|
child: SizedBox(
|
||||||
alignment: Alignment.topLeft,
|
width: _rectTween.begin!.width,
|
||||||
child: SizedBox(
|
height: _rectTween.begin!.height,
|
||||||
width: _rectTween.begin!.width,
|
child: (hideableKey.currentState?.isInTree ??
|
||||||
height: _rectTween.begin!.height,
|
false)
|
||||||
child: (hideableKey.currentState?.isInTree ??
|
? null
|
||||||
false)
|
: FadeTransition(
|
||||||
? null
|
opacity: closedOpacityTween!
|
||||||
: FadeTransition(
|
.animate(animation),
|
||||||
opacity: closedOpacityTween!
|
child: Builder(
|
||||||
.animate(animation),
|
key: closedBuilderKey,
|
||||||
child: Builder(
|
builder: (BuildContext context) {
|
||||||
key: closedBuilderKey,
|
// Use dummy "open container" callback
|
||||||
builder: (BuildContext context) {
|
// since we are in the process of opening.
|
||||||
// Use dummy "open container" callback
|
return closedBuilder(
|
||||||
// since we are in the process of opening.
|
context, () {});
|
||||||
return closedBuilder(
|
},
|
||||||
context, () {});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
// Open child fading in.
|
// Open child fading in.
|
||||||
FittedBox(
|
FittedBox(
|
||||||
fit: BoxFit.fitWidth,
|
fit: BoxFit.fitWidth,
|
||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: _rectTween.end!.width,
|
width: _rectTween.end!.width,
|
||||||
height: _rectTween.end!.height,
|
height: _rectTween.end!.height,
|
||||||
child: FadeTransition(
|
child: FadeTransition(
|
||||||
opacity:
|
opacity:
|
||||||
openOpacityTween!.animate(animation),
|
openOpacityTween!.animate(animation),
|
||||||
child: Builder(
|
child: Builder(
|
||||||
key: _openBuilderKey,
|
key: _openBuilderKey,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return openBuilder(
|
return openBuilder(
|
||||||
context, closeContainer);
|
context, closeContainer);
|
||||||
},
|
},
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
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,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ showExtendPage(
|
|||||||
required String title,
|
required String title,
|
||||||
double? extendPageWidth,
|
double? extendPageWidth,
|
||||||
bool forceNotSide = false,
|
bool forceNotSide = false,
|
||||||
|
bool isBlur = true,
|
||||||
Widget? action,
|
Widget? action,
|
||||||
}) {
|
}) {
|
||||||
final NavigatorState navigator = Navigator.of(context);
|
final NavigatorState navigator = Navigator.of(context);
|
||||||
@@ -21,6 +22,17 @@ showExtendPage(
|
|||||||
);
|
);
|
||||||
final isMobile =
|
final isMobile =
|
||||||
globalState.appController.appState.viewMode == ViewMode.mobile;
|
globalState.appController.appState.viewMode == ViewMode.mobile;
|
||||||
|
if (isMobile) {
|
||||||
|
Navigator.of(context).push(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) => CommonScaffold(
|
||||||
|
title: title,
|
||||||
|
body: uniqueBody,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
final isNotSide = isMobile || forceNotSide;
|
final isNotSide = isMobile || forceNotSide;
|
||||||
navigator.push(
|
navigator.push(
|
||||||
ModalSideSheetRoute(
|
ModalSideSheetRoute(
|
||||||
@@ -46,7 +58,7 @@ showExtendPage(
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
constraints: const BoxConstraints(),
|
constraints: const BoxConstraints(),
|
||||||
filter: filter,
|
filter: isBlur ? filter : null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:emoji_regex/emoji_regex.dart';
|
||||||
|
|
||||||
import '../state.dart';
|
import '../state.dart';
|
||||||
|
|
||||||
@@ -30,3 +31,63 @@ class TooltipText extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class EmojiText extends StatelessWidget {
|
||||||
|
final String text;
|
||||||
|
final TextStyle? style;
|
||||||
|
final int? maxLines;
|
||||||
|
final TextOverflow? overflow;
|
||||||
|
|
||||||
|
const EmojiText(
|
||||||
|
this.text, {
|
||||||
|
super.key,
|
||||||
|
this.maxLines,
|
||||||
|
this.overflow,
|
||||||
|
this.style,
|
||||||
|
});
|
||||||
|
|
||||||
|
List<TextSpan> _buildTextSpans(String emojis) {
|
||||||
|
final List<TextSpan> spans = [];
|
||||||
|
final matches = emojiRegex().allMatches(text);
|
||||||
|
|
||||||
|
int lastMatchEnd = 0;
|
||||||
|
for (final match in matches) {
|
||||||
|
if (match.start > lastMatchEnd) {
|
||||||
|
spans.add(
|
||||||
|
TextSpan(
|
||||||
|
text: text.substring(lastMatchEnd, match.start), style: style),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
spans.add(
|
||||||
|
TextSpan(
|
||||||
|
text:match.group(0),
|
||||||
|
style: style?.copyWith(
|
||||||
|
fontFamily: "Twemoji",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
lastMatchEnd = match.end;
|
||||||
|
}
|
||||||
|
if (lastMatchEnd < text.length) {
|
||||||
|
spans.add(
|
||||||
|
TextSpan(
|
||||||
|
text: text.substring(lastMatchEnd),
|
||||||
|
style: style,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return spans;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return RichText(
|
||||||
|
maxLines: maxLines,
|
||||||
|
overflow: overflow ?? TextOverflow.clip,
|
||||||
|
text: TextSpan(
|
||||||
|
children: _buildTextSpans(text),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,92 +52,89 @@ class _TrayContainerState extends State<TrayContainer> with TrayListener {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMenu(TrayContainerSelectorState state) async {
|
updateMenu(TrayContainerSelectorState state) {
|
||||||
if (!Platform.isLinux) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
_updateOtherTray();
|
if (!Platform.isLinux) {
|
||||||
}
|
_updateOtherTray();
|
||||||
List<MenuItem> menuItems = [];
|
}
|
||||||
final showMenuItem = MenuItem(
|
List<MenuItem> menuItems = [];
|
||||||
label: appLocalizations.show,
|
final showMenuItem = MenuItem(
|
||||||
onClick: (_) {
|
label: appLocalizations.show,
|
||||||
window?.show();
|
onClick: (_) {
|
||||||
},
|
window?.show();
|
||||||
);
|
},
|
||||||
menuItems.add(showMenuItem);
|
|
||||||
menuItems.add(MenuItem.separator());
|
|
||||||
// for (final group in state.groups) {
|
|
||||||
// List<MenuItem> subMenuItems = [];
|
|
||||||
// final isCurrentGroup = group.name == state.currentGroupName;
|
|
||||||
// for (final proxy in group.all) {
|
|
||||||
// final isCurrentProxy = proxy.name == state.currentProxyName;
|
|
||||||
// subMenuItems.add(
|
|
||||||
// MenuItem.checkbox(
|
|
||||||
// label: proxy.name,
|
|
||||||
// checked: isCurrentGroup && isCurrentProxy,
|
|
||||||
// onClick: (_) {
|
|
||||||
// final config = globalState.appController.config;
|
|
||||||
// config.currentProfile?.groupName = group.name;
|
|
||||||
// config.currentProfile?.proxyName = proxy.name;
|
|
||||||
// config.update();
|
|
||||||
// globalState.appController.changeProxy();
|
|
||||||
// }),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// menuItems.add(
|
|
||||||
// MenuItem.submenu(
|
|
||||||
// label: group.name,
|
|
||||||
// submenu: Menu(
|
|
||||||
// items: subMenuItems,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// if (state.groups.isNotEmpty) {
|
|
||||||
// menuItems.add(MenuItem.separator());
|
|
||||||
// }
|
|
||||||
for (final mode in Mode.values) {
|
|
||||||
menuItems.add(
|
|
||||||
MenuItem.checkbox(
|
|
||||||
label: Intl.message(mode.name),
|
|
||||||
onClick: (_) {
|
|
||||||
globalState.appController.clashConfig.mode = mode;
|
|
||||||
},
|
|
||||||
checked: mode == state.mode,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
menuItems.add(showMenuItem);
|
||||||
menuItems.add(MenuItem.separator());
|
final startMenuItem = MenuItem.checkbox(
|
||||||
final proxyMenuItem = MenuItem.checkbox(
|
label: state.isStart ? appLocalizations.stop : appLocalizations.start,
|
||||||
label: appLocalizations.systemProxy,
|
onClick: (_) async {
|
||||||
onClick: (_) async {
|
globalState.appController.updateStatus(!state.isStart);
|
||||||
globalState.appController.updateSystemProxy(!state.isRun);
|
},
|
||||||
},
|
checked: false,
|
||||||
checked: state.isRun,
|
);
|
||||||
);
|
menuItems.add(startMenuItem);
|
||||||
menuItems.add(proxyMenuItem);
|
menuItems.add(MenuItem.separator());
|
||||||
final autoStartMenuItem = MenuItem.checkbox(
|
for (final mode in Mode.values) {
|
||||||
label: appLocalizations.autoLaunch,
|
menuItems.add(
|
||||||
onClick: (_) async {
|
MenuItem.checkbox(
|
||||||
globalState.appController.config.autoLaunch =
|
label: Intl.message(mode.name),
|
||||||
!globalState.appController.config.autoLaunch;
|
onClick: (_) {
|
||||||
},
|
globalState.appController.clashConfig.mode = mode;
|
||||||
checked: state.autoLaunch,
|
},
|
||||||
);
|
checked: mode == state.mode,
|
||||||
menuItems.add(autoStartMenuItem);
|
),
|
||||||
menuItems.add(MenuItem.separator());
|
);
|
||||||
final exitMenuItem = MenuItem(
|
}
|
||||||
label: appLocalizations.exit,
|
menuItems.add(MenuItem.separator());
|
||||||
onClick: (_) async {
|
if (state.isStart) {
|
||||||
await globalState.appController.handleExit();
|
menuItems.add(
|
||||||
},
|
MenuItem.checkbox(
|
||||||
);
|
label: appLocalizations.tun,
|
||||||
menuItems.add(exitMenuItem);
|
onClick: (_) {
|
||||||
final menu = Menu();
|
final clashConfig = globalState.appController.clashConfig;
|
||||||
menu.items = menuItems;
|
clashConfig.tun =
|
||||||
trayManager.setContextMenu(menu);
|
clashConfig.tun.copyWith(enable: !state.tunEnable);
|
||||||
if (Platform.isLinux) {
|
},
|
||||||
_updateLinuxTray();
|
checked: state.tunEnable,
|
||||||
}
|
),
|
||||||
|
);
|
||||||
|
menuItems.add(
|
||||||
|
MenuItem.checkbox(
|
||||||
|
label: appLocalizations.systemProxy,
|
||||||
|
onClick: (_) {
|
||||||
|
final config = globalState.appController.config;
|
||||||
|
config.desktopProps =
|
||||||
|
config.desktopProps.copyWith(systemProxy: !state.systemProxy);
|
||||||
|
},
|
||||||
|
checked: state.systemProxy,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
menuItems.add(MenuItem.separator());
|
||||||
|
}
|
||||||
|
final autoStartMenuItem = MenuItem.checkbox(
|
||||||
|
label: appLocalizations.autoLaunch,
|
||||||
|
onClick: (_) async {
|
||||||
|
globalState.appController.config.autoLaunch =
|
||||||
|
!globalState.appController.config.autoLaunch;
|
||||||
|
},
|
||||||
|
checked: state.autoLaunch,
|
||||||
|
);
|
||||||
|
menuItems.add(autoStartMenuItem);
|
||||||
|
menuItems.add(MenuItem.separator());
|
||||||
|
final exitMenuItem = MenuItem(
|
||||||
|
label: appLocalizations.exit,
|
||||||
|
onClick: (_) async {
|
||||||
|
await globalState.appController.handleExit();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
menuItems.add(exitMenuItem);
|
||||||
|
final menu = Menu();
|
||||||
|
menu.items = menuItems;
|
||||||
|
trayManager.setContextMenu(menu);
|
||||||
|
if (Platform.isLinux) {
|
||||||
|
_updateLinuxTray();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -147,13 +144,13 @@ class _TrayContainerState extends State<TrayContainer> with TrayListener {
|
|||||||
TrayContainerSelectorState(
|
TrayContainerSelectorState(
|
||||||
mode: clashConfig.mode,
|
mode: clashConfig.mode,
|
||||||
autoLaunch: config.autoLaunch,
|
autoLaunch: config.autoLaunch,
|
||||||
isRun: appState.runTime != null,
|
isStart: appState.isStart,
|
||||||
locale: config.locale,
|
locale: config.locale,
|
||||||
|
systemProxy: config.desktopProps.systemProxy,
|
||||||
|
tunEnable: clashConfig.tun.enable,
|
||||||
),
|
),
|
||||||
builder: (_, state, child) {
|
builder: (_, state, child) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
updateMenu(state);
|
||||||
updateMenu(state);
|
|
||||||
});
|
|
||||||
return child!;
|
return child!;
|
||||||
},
|
},
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
|
|||||||
58
lib/widgets/vpn_container.dart
Normal file
58
lib/widgets/vpn_container.dart
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import 'package:fl_clash/common/app_localizations.dart';
|
||||||
|
import 'package:fl_clash/models/config.dart';
|
||||||
|
import 'package:fl_clash/state.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../common/function.dart';
|
||||||
|
|
||||||
|
class VpnContainer extends StatefulWidget {
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const VpnContainer({
|
||||||
|
super.key,
|
||||||
|
required this.child,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<VpnContainer> createState() => _VpnContainerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _VpnContainerState extends State<VpnContainer> {
|
||||||
|
Function? vpnTipDebounce;
|
||||||
|
|
||||||
|
showTip() {
|
||||||
|
vpnTipDebounce ??= debounce<Function()>(() async {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
final appState = globalState.appController.appState;
|
||||||
|
if (appState.isStart) {
|
||||||
|
globalState.showSnackBar(
|
||||||
|
context,
|
||||||
|
message: appLocalizations.vpnTip,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
vpnTipDebounce!();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Selector<Config, VPNState>(
|
||||||
|
selector: (_, config) => VPNState(
|
||||||
|
accessControl: config.accessControl,
|
||||||
|
vpnProps: config.vpnProps,
|
||||||
|
),
|
||||||
|
shouldRebuild: (prev,next){
|
||||||
|
if(prev != next){
|
||||||
|
showTip();
|
||||||
|
}
|
||||||
|
return prev != next;
|
||||||
|
},
|
||||||
|
builder: (_, __, child) {
|
||||||
|
return child!;
|
||||||
|
},
|
||||||
|
child: widget.child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,4 +25,6 @@ export 'app_state_container.dart';
|
|||||||
export 'text.dart';
|
export 'text.dart';
|
||||||
export 'connection_item.dart';
|
export 'connection_item.dart';
|
||||||
export 'builder.dart';
|
export 'builder.dart';
|
||||||
export 'setting.dart';
|
export 'setting.dart';
|
||||||
|
export 'vpn_container.dart';
|
||||||
|
export 'input.dart';
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user