Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ba2f72b1a | ||
|
|
d6c22d4cca | ||
|
|
614dfc841a | ||
|
|
5afa552b6c | ||
|
|
ee0e2a15a7 | ||
|
|
7b7fd084bf | ||
|
|
03c39bf4bf | ||
|
|
fd7c3be02f | ||
|
|
b67d221063 | ||
|
|
1a74c0a12f | ||
|
|
9fc9c53427 | ||
|
|
8954b88d7f | ||
|
|
3990f8d7fa | ||
|
|
98688bcd2a | ||
|
|
2957311682 | ||
|
|
87a903af60 | ||
|
|
c65746709d | ||
|
|
d2d9bdab02 | ||
|
|
d0f8444b6d | ||
|
|
fccabfbe27 | ||
|
|
e9bb97c6ce | ||
|
|
068fe14d89 | ||
|
|
43c397007c | ||
|
|
5e801d5f5e | ||
|
|
52d61b15fd | ||
|
|
fea3c14608 | ||
|
|
84be01a38a | ||
|
|
93da242148 | ||
|
|
bb7e44da30 | ||
|
|
01f1b2d72f | ||
|
|
3074b1299e | ||
|
|
bd5470b863 | ||
|
|
83fafa4b68 | ||
|
|
b7fb969301 | ||
|
|
3ef3190785 | ||
|
|
b1c763fcfa | ||
|
|
9452ffa514 | ||
|
|
c9291e5027 | ||
|
|
3ba86dc9c2 | ||
|
|
fd3040283c | ||
|
|
91d30c0f0e | ||
|
|
c4b470ffaf | ||
|
|
9a07c785f2 | ||
|
|
a134c32493 | ||
|
|
472cea9037 | ||
|
|
08d07498b9 | ||
|
|
d5aa09949a | ||
|
|
fd1dfe5c60 | ||
|
|
9f89fe8b29 | ||
|
|
78081a12e8 | ||
|
|
6896837f28 | ||
|
|
85eb903402 | ||
|
|
9aa9180f1f | ||
|
|
feb9688a29 | ||
|
|
5c71992174 | ||
|
|
74c3d0ae25 | ||
|
|
ecd1bcafd5 | ||
|
|
184d2d117a | ||
|
|
89e6f17794 | ||
|
|
aef50fe0e3 | ||
|
|
fc0767ed25 | ||
|
|
dbf1724cca | ||
|
|
909aa4038e | ||
|
|
2d0a7d8d46 | ||
|
|
ca96cd1d82 | ||
|
|
91ab1e5dac | ||
|
|
b3a5f74df8 | ||
|
|
1f98be8ad8 | ||
|
|
453c7c98d0 | ||
|
|
91faed35c0 | ||
|
|
07bbaf6b6f | ||
|
|
e8feb7c431 | ||
|
|
4d16820526 | ||
|
|
92294b49c6 | ||
|
|
8a188a37c9 | ||
|
|
48af16c265 |
7
.github/workflows/build.yml
vendored
@@ -21,6 +21,12 @@ jobs:
|
||||
os: macos-13
|
||||
|
||||
steps:
|
||||
- name: Check Matrix
|
||||
run: |
|
||||
echo "Running on ${{ matrix.os }}"
|
||||
echo "Arch: ${{ runner.arch }}"
|
||||
gcc --version
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -82,6 +88,7 @@ jobs:
|
||||
|
||||
|
||||
upload-release:
|
||||
if: ${{ !contains(github.ref, '+') }}
|
||||
permissions: write-all
|
||||
needs: [ build ]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
2
.gitignore
vendored
@@ -31,6 +31,7 @@ migrate_working_dir/
|
||||
.pub-cache/
|
||||
.pub/
|
||||
/build/
|
||||
/dist/
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
@@ -44,6 +45,7 @@ app.*.map.json
|
||||
/android/app/release
|
||||
|
||||
|
||||
|
||||
#libclash
|
||||
/libclash/
|
||||
|
||||
|
||||
2
.gitmodules
vendored
@@ -5,4 +5,4 @@
|
||||
[submodule "plugins/flutter_distributor"]
|
||||
path = plugins/flutter_distributor
|
||||
url = git@github.com:chen08209/flutter_distributor.git
|
||||
branch = main
|
||||
branch = FlClash
|
||||
|
||||
@@ -34,6 +34,8 @@ on Mobile:
|
||||
|
||||
💡 Based on Material You Design, [Surfboard](https://github.com/getsurfboard/surfboard)-like UI
|
||||
|
||||
☁️ Supports data sync via WebDAV
|
||||
|
||||
✨ Support subscription link, Dark mode
|
||||
|
||||
## Contact
|
||||
|
||||
@@ -34,6 +34,8 @@ on Mobile:
|
||||
|
||||
💡 基本 Material You 设计, 类[Surfboard](https://github.com/getsurfboard/surfboard)用户界面
|
||||
|
||||
☁️ 支持通过WebDAV同步数据
|
||||
|
||||
✨ 支持一键导入订阅, 深色模式
|
||||
|
||||
## Contact
|
||||
|
||||
@@ -62,7 +62,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.follow.clash"
|
||||
minSdkVersion 21
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 34
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-feature
|
||||
android:name="android.software.leanback"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
@@ -17,12 +14,15 @@
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.ACCESS_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.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"
|
||||
tools:ignore="SystemPermissionTypo" />
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission" />
|
||||
|
||||
<application
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:extractNativeLibs="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:label="FlClash">
|
||||
<activity
|
||||
@@ -73,7 +73,8 @@
|
||||
<service
|
||||
android:name=".services.FlClashTileService"
|
||||
android:exported="true"
|
||||
android:icon="@drawable/tile_icon"
|
||||
android:icon="@drawable/icon"
|
||||
android:foregroundServiceType="specialUse"
|
||||
android:label="FlClash"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
<intent-filter>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.follow.clash
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.follow.clash.plugins.AppPlugin
|
||||
import com.follow.clash.plugins.TilePlugin
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import java.util.Date
|
||||
@@ -18,6 +19,9 @@ class GlobalState {
|
||||
var flutterEngine: FlutterEngine? = null
|
||||
fun getCurrentTilePlugin(): TilePlugin? =
|
||||
flutterEngine?.plugins?.get(TilePlugin::class.java) as TilePlugin?
|
||||
|
||||
fun getCurrentAppPlugin(): AppPlugin? =
|
||||
flutterEngine?.plugins?.get(AppPlugin::class.java) as AppPlugin?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package com.follow.clash.extensions
|
||||
|
||||
import java.net.InetSocketAddress
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.system.OsConstants.IPPROTO_TCP
|
||||
import android.system.OsConstants.IPPROTO_UDP
|
||||
import android.util.Base64
|
||||
import java.net.URL
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import com.follow.clash.models.Metadata
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.net.InetAddress
|
||||
import java.net.InetSocketAddress
|
||||
|
||||
|
||||
suspend fun Drawable.getBase64(): String {
|
||||
@@ -29,3 +30,8 @@ fun Metadata.getProtocol(): Int? {
|
||||
if (network.startsWith("udp")) return IPPROTO_UDP
|
||||
return null
|
||||
}
|
||||
|
||||
fun String.getInetSocketAddress(): InetSocketAddress {
|
||||
val url = URL("https://$this")
|
||||
return InetSocketAddress(InetAddress.getByName(url.host), url.port)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.follow.clash.models
|
||||
|
||||
data class Process(
|
||||
val id: Int,
|
||||
val metadata: Metadata,
|
||||
)
|
||||
|
||||
data class Metadata(
|
||||
val network: String,
|
||||
val sourceIP: String,
|
||||
val sourcePort: Int,
|
||||
val destinationIP: String,
|
||||
val destinationPort: Int,
|
||||
val remoteDestination: String,
|
||||
val host: String
|
||||
)
|
||||
@@ -10,3 +10,9 @@ data class AccessControl(
|
||||
val acceptList: List<String>,
|
||||
val rejectList: List<String>,
|
||||
)
|
||||
|
||||
data class Props(
|
||||
val accessControl: AccessControl?,
|
||||
val allowBypass: Boolean?,
|
||||
val systemProxy: Boolean?,
|
||||
)
|
||||
@@ -6,13 +6,16 @@ import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import com.follow.clash.extensions.getBase64
|
||||
import com.follow.clash.extensions.getInetSocketAddress
|
||||
import com.follow.clash.extensions.getProtocol
|
||||
import com.follow.clash.models.Metadata
|
||||
import com.follow.clash.models.Process
|
||||
import com.follow.clash.models.Package
|
||||
import com.google.gson.Gson
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
@@ -78,21 +81,34 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
||||
"getPackageIcon" -> {
|
||||
scope.launch {
|
||||
val packageName = call.argument<String>("packageName")
|
||||
if (packageName != null) {
|
||||
result.success(getPackageIcon(packageName))
|
||||
} else {
|
||||
if (packageName == null) {
|
||||
result.success(null)
|
||||
return@launch
|
||||
}
|
||||
val packageIcon = getPackageIcon(packageName)
|
||||
packageIcon.let {
|
||||
if (it != null) {
|
||||
result.success(it)
|
||||
return@launch
|
||||
}
|
||||
if (iconMap["default"] == null) {
|
||||
iconMap["default"] =
|
||||
context?.packageManager?.defaultActivityIcon?.getBase64()
|
||||
}
|
||||
result.success(iconMap["default"])
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"getPackageName" -> {
|
||||
"resolverProcess" -> {
|
||||
val data = call.argument<String>("data")
|
||||
val metadata =
|
||||
val process =
|
||||
if (data != null) Gson().fromJson(
|
||||
data,
|
||||
Metadata::class.java
|
||||
Process::class.java
|
||||
) else null
|
||||
val metadata = process?.metadata
|
||||
val protocol = metadata?.getProtocol()
|
||||
if (protocol == null) {
|
||||
result.success(null)
|
||||
@@ -100,17 +116,27 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
||||
}
|
||||
scope.launch {
|
||||
withContext(Dispatchers.Default) {
|
||||
if (context == null) result.success(null)
|
||||
val source = InetSocketAddress(metadata.sourceIP, metadata.sourcePort)
|
||||
val target = InetSocketAddress(
|
||||
metadata.host.ifEmpty { metadata.destinationIP },
|
||||
metadata.destinationPort
|
||||
)
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q){
|
||||
result.success(null)
|
||||
return@withContext
|
||||
}
|
||||
if (context == null) {
|
||||
result.success(null)
|
||||
return@withContext
|
||||
}
|
||||
if (connectivity == null) {
|
||||
connectivity = context!!.getSystemService<ConnectivityManager>()
|
||||
}
|
||||
val uid =
|
||||
connectivity?.getConnectionOwnerUid(protocol, source, target)
|
||||
val src = InetSocketAddress(metadata.sourceIP, metadata.sourcePort)
|
||||
val dst = InetSocketAddress(
|
||||
metadata.destinationIP.ifEmpty { metadata.host },
|
||||
metadata.destinationPort
|
||||
)
|
||||
val uid = try {
|
||||
connectivity?.getConnectionOwnerUid(protocol, src, dst)
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
if (uid == null || uid == -1) {
|
||||
result.success(null)
|
||||
return@withContext
|
||||
@@ -137,13 +163,18 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
||||
private suspend fun getPackageIcon(packageName: String): String? {
|
||||
val packageManager = context?.packageManager
|
||||
if (iconMap[packageName] == null) {
|
||||
iconMap[packageName] = packageManager?.getApplicationIcon(packageName)?.getBase64()
|
||||
iconMap[packageName] = try {
|
||||
packageManager?.getApplicationIcon(packageName)?.getBase64()
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
|
||||
}
|
||||
return iconMap[packageName]
|
||||
}
|
||||
|
||||
private suspend fun getPackages(): String {
|
||||
return withContext(Dispatchers.Default){
|
||||
return withContext(Dispatchers.Default) {
|
||||
val packageManager = context?.packageManager
|
||||
val packages: List<Package>? =
|
||||
packageManager?.getInstalledPackages(PackageManager.GET_META_DATA)?.filter {
|
||||
@@ -162,6 +193,10 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
||||
}
|
||||
}
|
||||
|
||||
fun requestGc() {
|
||||
channel.invokeMethod("gc", null)
|
||||
}
|
||||
|
||||
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
||||
activity = binding.activity;
|
||||
scope = CoroutineScope(Dispatchers.Default)
|
||||
|
||||
@@ -16,7 +16,7 @@ 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.AccessControl
|
||||
import com.follow.clash.models.Props
|
||||
import com.follow.clash.services.FlClashVpnService
|
||||
import com.google.gson.Gson
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
@@ -41,7 +41,7 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
|
||||
private var flClashVpnService: FlClashVpnService? = null
|
||||
private var isBound = false
|
||||
private var port: Int? = null
|
||||
private var accessControl: AccessControl? = null
|
||||
private var props: Props? = null
|
||||
private lateinit var title: String
|
||||
private lateinit var content: String
|
||||
|
||||
@@ -73,8 +73,8 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
|
||||
"StartProxy" -> {
|
||||
port = call.argument<Int>("port")
|
||||
val args = call.argument<String>("args")
|
||||
accessControl =
|
||||
if (args != null) Gson().fromJson(args, AccessControl::class.java) else null
|
||||
props =
|
||||
if (args != null) Gson().fromJson(args, Props::class.java) else null
|
||||
handleStartVpn()
|
||||
result.success(true)
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
|
||||
|
||||
private fun startVpn(port: Int) {
|
||||
if (GlobalState.runState.value == RunState.START) return;
|
||||
flClashVpnService?.start(port, accessControl)
|
||||
flClashVpnService?.start(port, props)
|
||||
GlobalState.runState.value = RunState.START
|
||||
GlobalState.runTime = Date()
|
||||
startAfter()
|
||||
|
||||
@@ -19,7 +19,6 @@ import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.embedding.engine.dart.DartExecutor
|
||||
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class FlClashTileService : TileService() {
|
||||
|
||||
private val observer = Observer<RunState> { runState ->
|
||||
@@ -43,19 +42,27 @@ class FlClashTileService : TileService() {
|
||||
GlobalState.runState.observeForever(observer)
|
||||
}
|
||||
|
||||
@SuppressLint("StartActivityAndCollapseDeprecated")
|
||||
private fun activityTransfer() {
|
||||
val intent = Intent(this, TempActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
if (Build.VERSION.SDK_INT >= 34) {
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
|
||||
val pendingIntent = if (Build.VERSION.SDK_INT >= 31) {
|
||||
PendingIntent.getActivity(
|
||||
this,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
startActivityAndCollapse(pendingIntent)
|
||||
} else {
|
||||
PendingIntent.getActivity(
|
||||
this,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
startActivityAndCollapse(pendingIntent)
|
||||
}else{
|
||||
startActivityAndCollapse(intent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
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.net.ProxyInfo
|
||||
@@ -13,15 +12,13 @@ import android.os.Binder
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE
|
||||
import androidx.core.graphics.drawable.IconCompat
|
||||
import com.follow.clash.GlobalState
|
||||
import com.follow.clash.MainActivity
|
||||
import com.follow.clash.models.AccessControl
|
||||
import com.follow.clash.R
|
||||
import com.follow.clash.models.AccessControlMode
|
||||
import com.follow.clash.models.Props
|
||||
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
class FlClashVpnService : VpnService() {
|
||||
|
||||
|
||||
@@ -54,12 +51,12 @@ class FlClashVpnService : VpnService() {
|
||||
return START_STICKY
|
||||
}
|
||||
|
||||
fun start(port: Int, accessControl: AccessControl?) {
|
||||
fun start(port: Int, props: Props?) {
|
||||
fd = with(Builder()) {
|
||||
addAddress("172.16.0.1", 30)
|
||||
setMtu(9000)
|
||||
addRoute("0.0.0.0", 0)
|
||||
if (accessControl != null) {
|
||||
props?.accessControl?.let { accessControl ->
|
||||
when (accessControl.mode) {
|
||||
AccessControlMode.acceptSelected -> {
|
||||
(accessControl.acceptList + packageName).forEach {
|
||||
@@ -80,8 +77,10 @@ class FlClashVpnService : VpnService() {
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
setMetered(false)
|
||||
}
|
||||
allowBypass()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
if (props?.allowBypass == true) {
|
||||
allowBypass()
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && props?.systemProxy == true) {
|
||||
setHttpProxy(
|
||||
ProxyInfo.buildDirectProxy(
|
||||
"127.0.0.1",
|
||||
@@ -100,10 +99,10 @@ class FlClashVpnService : VpnService() {
|
||||
}
|
||||
|
||||
|
||||
private val notificationBuilder by lazy {
|
||||
private val notificationBuilder: NotificationCompat.Builder by lazy {
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
|
||||
val pendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
val pendingIntent = if (Build.VERSION.SDK_INT >= 31) {
|
||||
PendingIntent.getActivity(
|
||||
this,
|
||||
0,
|
||||
@@ -119,34 +118,40 @@ class FlClashVpnService : VpnService() {
|
||||
)
|
||||
}
|
||||
|
||||
val icon = IconCompat.createWithResource(this, this.applicationInfo.icon)
|
||||
|
||||
with(NotificationCompat.Builder(this, CHANNEL)) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
setSmallIcon(icon)
|
||||
}
|
||||
setSmallIcon(R.drawable.ic_stat_name)
|
||||
setContentTitle("FlClash")
|
||||
foregroundServiceBehavior = FOREGROUND_SERVICE_IMMEDIATE
|
||||
setContentIntent(pendingIntent)
|
||||
setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||
priority = NotificationCompat.PRIORITY_LOW
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ForegroundServiceType", "WrongConstant")
|
||||
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) {
|
||||
val channel =
|
||||
NotificationChannel(CHANNEL, "FlClash", NotificationManager.IMPORTANCE_LOW)
|
||||
val manager = getSystemService(NotificationManager::class.java)
|
||||
manager.createNotificationChannel(channel)
|
||||
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) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
||||
} else {
|
||||
startForeground(notificationId, notification)
|
||||
@@ -155,7 +160,7 @@ class FlClashVpnService : VpnService() {
|
||||
|
||||
private fun stopForeground() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
stopForeground(Service.STOP_FOREGROUND_REMOVE)
|
||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BIN
android/app/src/main/res/drawable-hdpi/ic_stat_name.png
Normal file
|
After Width: | Height: | Size: 763 B |
BIN
android/app/src/main/res/drawable-mdpi/ic_stat_name.png
Normal file
|
After Width: | Height: | Size: 520 B |
BIN
android/app/src/main/res/drawable-xhdpi/ic_stat_name.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
android/app/src/main/res/drawable-xxhdpi/ic_stat_name.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
android/app/src/main/res/drawable-xxxhdpi/ic_stat_name.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
android/app/src/main/res/drawable/icon.png
Normal file
|
After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 105 KiB |
@@ -4,7 +4,6 @@
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
the Flutter engine draws its first frame -->
|
||||
<item name="android:windowBackground">@mipmap/ic_launcher_foreground</item>
|
||||
</style>
|
||||
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||
This theme determines the color of the Android Window while your
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
the Flutter engine draws its first frame -->
|
||||
<item name="android:windowBackground">@mipmap/ic_launcher_foreground</item>
|
||||
</style>
|
||||
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||
This theme determines the color of the Android Window while your
|
||||
|
||||
@@ -2,25 +2,24 @@ package main
|
||||
|
||||
import "C"
|
||||
import (
|
||||
"github.com/metacubex/mihomo/adapter"
|
||||
"github.com/metacubex/mihomo/adapter/inbound"
|
||||
ap "github.com/metacubex/mihomo/adapter/provider"
|
||||
"github.com/metacubex/mihomo/component/dialer"
|
||||
"github.com/metacubex/mihomo/component/process"
|
||||
"github.com/metacubex/mihomo/component/resolver"
|
||||
"github.com/metacubex/mihomo/config"
|
||||
"github.com/metacubex/mihomo/constant/provider"
|
||||
"github.com/metacubex/mihomo/dns"
|
||||
"github.com/metacubex/mihomo/constant"
|
||||
"github.com/metacubex/mihomo/hub"
|
||||
"github.com/metacubex/mihomo/hub/executor"
|
||||
"github.com/metacubex/mihomo/hub/route"
|
||||
"github.com/metacubex/mihomo/listener"
|
||||
"github.com/metacubex/mihomo/log"
|
||||
"github.com/metacubex/mihomo/tunnel"
|
||||
"math"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
@@ -83,10 +82,13 @@ type Delay struct {
|
||||
}
|
||||
|
||||
type Process struct {
|
||||
Uid uint32 `json:"uid"`
|
||||
Network string `json:"network"`
|
||||
Source string `json:"source"`
|
||||
Target string `json:"target"`
|
||||
Id int64 `json:"id"`
|
||||
Metadata *constant.Metadata `json:"metadata"`
|
||||
}
|
||||
|
||||
type ProcessMapItem struct {
|
||||
Id int64 `json:"id"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
type Now struct {
|
||||
@@ -321,48 +323,55 @@ func generateProxyGroupAndRule(proxyGroup *[]map[string]any, rule *[]string) {
|
||||
}
|
||||
|
||||
func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfig, compatible bool) {
|
||||
targetConfig.ExternalController = ""
|
||||
targetConfig.ExternalController = patchConfig.ExternalController
|
||||
targetConfig.ExternalUI = ""
|
||||
targetConfig.Interface = ""
|
||||
targetConfig.ExternalUIURL = ""
|
||||
//targetConfig.IPv6 = patchConfig.IPv6
|
||||
targetConfig.TCPConcurrent = patchConfig.TCPConcurrent
|
||||
targetConfig.UnifiedDelay = patchConfig.UnifiedDelay
|
||||
targetConfig.GeodataMode = false
|
||||
targetConfig.IPv6 = patchConfig.IPv6
|
||||
targetConfig.LogLevel = patchConfig.LogLevel
|
||||
targetConfig.FindProcessMode = process.FindProcessAlways
|
||||
targetConfig.AllowLan = patchConfig.AllowLan
|
||||
targetConfig.Port = 0
|
||||
targetConfig.SocksPort = 0
|
||||
targetConfig.MixedPort = patchConfig.MixedPort
|
||||
targetConfig.FindProcessMode = patchConfig.FindProcessMode
|
||||
targetConfig.AllowLan = patchConfig.AllowLan
|
||||
targetConfig.Mode = patchConfig.Mode
|
||||
targetConfig.Tun.Enable = patchConfig.Tun.Enable
|
||||
targetConfig.Tun.Device = patchConfig.Tun.Device
|
||||
targetConfig.Tun.DNSHijack = patchConfig.Tun.DNSHijack
|
||||
targetConfig.Tun.Stack = patchConfig.Tun.Stack
|
||||
targetConfig.GeodataLoader = "standard"
|
||||
//targetConfig.Tun.DNSHijack = patchConfig.Tun.DNSHijack
|
||||
//targetConfig.Tun.Stack = patchConfig.Tun.Stack
|
||||
targetConfig.GeodataLoader = patchConfig.GeodataLoader
|
||||
targetConfig.Profile.StoreSelected = false
|
||||
if targetConfig.DNS.Enable == false {
|
||||
targetConfig.DNS = patchConfig.DNS
|
||||
}
|
||||
if runtime.GOOS == "android" {
|
||||
targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, "dhcp://"+dns.SystemDNSPlaceholder)
|
||||
} else if runtime.GOOS == "windows" {
|
||||
targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, dns.SystemDNSPlaceholder)
|
||||
}
|
||||
//if runtime.GOOS == "android" {
|
||||
// targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, "dhcp://"+dns.SystemDNSPlaceholder)
|
||||
//} else if runtime.GOOS == "windows" {
|
||||
// targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, dns.SystemDNSPlaceholder)
|
||||
//}
|
||||
if compatible == false {
|
||||
targetConfig.ProxyProvider = make(map[string]map[string]any)
|
||||
targetConfig.RuleProvider = make(map[string]map[string]any)
|
||||
generateProxyGroupAndRule(&targetConfig.ProxyGroup, &targetConfig.Rule)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func patchConfig(general *config.General) {
|
||||
log.Infoln("[Apply] patch")
|
||||
route.ReStartServer(general.ExternalController)
|
||||
listener.SetAllowLan(general.AllowLan)
|
||||
inbound.SetSkipAuthPrefixes(general.SkipAuthPrefixes)
|
||||
inbound.SetAllowedIPs(general.LanAllowedIPs)
|
||||
inbound.SetDisAllowedIPs(general.LanDisAllowedIPs)
|
||||
listener.SetBindAddress(general.BindAddress)
|
||||
tunnel.SetSniffing(general.Sniffing)
|
||||
tunnel.SetFindProcessMode(general.FindProcessMode)
|
||||
dialer.SetTcpConcurrent(general.TCPConcurrent)
|
||||
dialer.DefaultInterface.Store(general.Interface)
|
||||
adapter.UnifiedDelay.Store(general.UnifiedDelay)
|
||||
listener.ReCreateHTTP(general.Port, tunnel.Tunnel)
|
||||
listener.ReCreateSocks(general.SocksPort, tunnel.Tunnel)
|
||||
listener.ReCreateRedir(general.RedirPort, tunnel.Tunnel)
|
||||
@@ -375,31 +384,10 @@ func patchConfig(general *config.General) {
|
||||
listener.ReCreateTuic(general.TuicServer, tunnel.Tunnel)
|
||||
tunnel.SetMode(general.Mode)
|
||||
log.SetLevel(general.LogLevel)
|
||||
|
||||
resolver.DisableIPv6 = !general.IPv6
|
||||
}
|
||||
|
||||
const concurrentCount = math.MaxInt
|
||||
|
||||
func hcCompatibleProvider(proxyProviders map[string]provider.ProxyProvider) {
|
||||
wg := sync.WaitGroup{}
|
||||
ch := make(chan struct{}, concurrentCount)
|
||||
for _, proxyProvider := range proxyProviders {
|
||||
proxyProvider := proxyProvider
|
||||
if proxyProvider.VehicleType() == provider.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)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func applyConfig(isPatch bool) {
|
||||
cfg, err := config.ParseRawConfig(currentConfig)
|
||||
if err != nil {
|
||||
@@ -408,7 +396,6 @@ func applyConfig(isPatch bool) {
|
||||
if isPatch {
|
||||
patchConfig(cfg.General)
|
||||
} else {
|
||||
executor.ApplyConfig(cfg, true)
|
||||
healthcheck()
|
||||
hub.UltraApplyConfig(cfg, true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ const (
|
||||
Delay MessageType = "delay"
|
||||
Now MessageType = "now"
|
||||
Process MessageType = "process"
|
||||
Request MessageType = "request"
|
||||
Run MessageType = "run"
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
@@ -19,11 +21,18 @@ type Message struct {
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
func (message *Message) Json() string {
|
||||
data, _ := json.Marshal(message)
|
||||
return string(data)
|
||||
func (message *Message) Json() (string, error) {
|
||||
data, err := json.Marshal(message)
|
||||
return string(data), err
|
||||
}
|
||||
|
||||
func SendMessage(message Message) {
|
||||
SendToPort(*Port, message.Json())
|
||||
if Port == nil {
|
||||
return
|
||||
}
|
||||
s, err := message.Json()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
SendToPort(*Port, s)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ require (
|
||||
github.com/RyuaNerin/go-krypto v1.2.4 // indirect
|
||||
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344 // indirect
|
||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
|
||||
github.com/ajg/form v1.5.1 // indirect
|
||||
github.com/andybalholm/brotli v1.0.6 // indirect
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
@@ -30,6 +31,9 @@ require (
|
||||
github.com/ericlagergren/subtle v0.0.0-20220507045147-890d697da010 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/gaukas/godicttls v0.0.4 // indirect
|
||||
github.com/go-chi/chi/v5 v5.0.12 // indirect
|
||||
github.com/go-chi/cors v1.2.1 // indirect
|
||||
github.com/go-chi/render v1.0.3 // indirect
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
||||
github.com/gobwas/httphead v0.1.0 // indirect
|
||||
|
||||
@@ -9,6 +9,8 @@ github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344 h1:cDVUiFo+npB0ZASqnw4
|
||||
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344/go.mod h1:9pIqrY6SXNL8vjRQE5Hd/OL5GyK/9MrGUWs87z/eFfk=
|
||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY=
|
||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
|
||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
|
||||
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
|
||||
@@ -46,6 +48,12 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/gaukas/godicttls v0.0.4 h1:NlRaXb3J6hAnTmWdsEKb9bcSBD6BvcIjdGdeb0zfXbk=
|
||||
github.com/gaukas/godicttls v0.0.4/go.mod h1:l6EenT4TLWgTdwslVb4sEMOCf7Bv0JAK67deKr9/NCI=
|
||||
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
|
||||
github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||
github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
|
||||
github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
|
||||
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
||||
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
||||
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
||||
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
|
||||
44
core/hub.go
@@ -60,17 +60,20 @@ func shutdownClash() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
//export forceGc
|
||||
func forceGc() {
|
||||
go func() {
|
||||
log.Infoln("[APP] request force GC")
|
||||
runtime.GC()
|
||||
}()
|
||||
}
|
||||
|
||||
//export validateConfig
|
||||
func validateConfig(s *C.char, port C.longlong) {
|
||||
i := int64(port)
|
||||
go func() {
|
||||
bytes := []byte(C.GoString(s))
|
||||
rawConfig, err := config.UnmarshalRawConfig(bytes)
|
||||
if err != nil {
|
||||
bridge.SendToPort(i, err.Error())
|
||||
return
|
||||
}
|
||||
_, err = config.ParseRawConfig(rawConfig)
|
||||
_, err := config.UnmarshalRawConfig(bytes)
|
||||
if err != nil {
|
||||
bridge.SendToPort(i, err.Error())
|
||||
return
|
||||
@@ -186,7 +189,8 @@ func getTraffic() *C.char {
|
||||
}
|
||||
|
||||
//export asyncTestDelay
|
||||
func asyncTestDelay(s *C.char) {
|
||||
func asyncTestDelay(s *C.char, port C.longlong) {
|
||||
i := int64(port)
|
||||
go func() {
|
||||
paramsString := C.GoString(s)
|
||||
var params = &TestDelayParams{}
|
||||
@@ -210,26 +214,25 @@ func asyncTestDelay(s *C.char) {
|
||||
Name: params.ProxyName,
|
||||
}
|
||||
|
||||
message := bridge.Message{
|
||||
Type: bridge.Delay,
|
||||
Data: delayData,
|
||||
}
|
||||
|
||||
if proxy == nil {
|
||||
delayData.Value = -1
|
||||
bridge.SendMessage(message)
|
||||
data, _ := json.Marshal(delayData)
|
||||
bridge.SendToPort(i, string(data))
|
||||
return
|
||||
}
|
||||
|
||||
delay, err := proxy.URLTest(ctx, constant.DefaultTestURL, expectedStatus)
|
||||
if err != nil || delay == 0 {
|
||||
delayData.Value = -1
|
||||
bridge.SendMessage(message)
|
||||
data, _ := json.Marshal(delayData)
|
||||
bridge.SendToPort(i, string(data))
|
||||
return
|
||||
}
|
||||
|
||||
delayData.Value = int32(delay)
|
||||
bridge.SendMessage(message)
|
||||
data, _ := json.Marshal(delayData)
|
||||
bridge.SendToPort(i, string(data))
|
||||
return
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -379,11 +382,6 @@ func updateExternalProvider(providerName *C.char, providerType *C.char, port C.l
|
||||
}()
|
||||
}
|
||||
|
||||
//export healthcheck
|
||||
func healthcheck() {
|
||||
hcCompatibleProvider(tunnel.Providers())
|
||||
}
|
||||
|
||||
//export initNativeApiBridge
|
||||
func initNativeApiBridge(api unsafe.Pointer, port C.longlong) {
|
||||
bridge.InitDartApi(api)
|
||||
@@ -406,4 +404,10 @@ func init() {
|
||||
Data: delayData,
|
||||
})
|
||||
}
|
||||
statistic.DefaultRequestNotify = func(c statistic.Tracker) {
|
||||
bridge.SendMessage(bridge.Message{
|
||||
Type: bridge.Request,
|
||||
Data: c,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ func startLog() {
|
||||
logSubscriber = log.Subscribe()
|
||||
go func() {
|
||||
for logData := range logSubscriber {
|
||||
if logData.LogLevel < log.Level() {
|
||||
continue
|
||||
}
|
||||
message := &bridge.Message{
|
||||
Type: bridge.Log,
|
||||
Data: logData,
|
||||
|
||||
@@ -1,3 +1,82 @@
|
||||
//go:build android
|
||||
|
||||
package main
|
||||
|
||||
import "C"
|
||||
import (
|
||||
bridge "core/dart-bridge"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/metacubex/mihomo/component/process"
|
||||
"github.com/metacubex/mihomo/constant"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ProcessMap struct {
|
||||
m sync.Map
|
||||
}
|
||||
|
||||
func (cm *ProcessMap) Store(key int64, value string) {
|
||||
cm.m.Store(key, value)
|
||||
}
|
||||
|
||||
func (cm *ProcessMap) Load(key int64) (string, bool) {
|
||||
value, ok := cm.m.Load(key)
|
||||
if !ok || value == nil {
|
||||
return "", false
|
||||
}
|
||||
return value.(string), true
|
||||
}
|
||||
|
||||
var counter int64 = 0
|
||||
|
||||
var processMap ProcessMap
|
||||
|
||||
func init() {
|
||||
process.DefaultPackageNameResolver = func(metadata *constant.Metadata) (string, error) {
|
||||
if metadata == nil {
|
||||
return "", process.ErrInvalidNetwork
|
||||
}
|
||||
id := atomic.AddInt64(&counter, 1)
|
||||
|
||||
timeout := time.After(200 * time.Millisecond)
|
||||
|
||||
bridge.SendMessage(bridge.Message{
|
||||
Type: bridge.Process,
|
||||
Data: Process{
|
||||
Id: id,
|
||||
Metadata: metadata,
|
||||
},
|
||||
})
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-timeout:
|
||||
return "", errors.New("package resolver timeout")
|
||||
default:
|
||||
value, exists := processMap.Load(id)
|
||||
if exists {
|
||||
return value, nil
|
||||
}
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//export setProcessMap
|
||||
func setProcessMap(s *C.char) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
paramsString := C.GoString(s)
|
||||
var processMapItem = &ProcessMapItem{}
|
||||
err := json.Unmarshal([]byte(paramsString), processMapItem)
|
||||
if err == nil {
|
||||
processMap.Store(processMapItem.Id, processMapItem.Value)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
71
core/tun.go
@@ -17,58 +17,49 @@ var tunLock sync.Mutex
|
||||
var tun *t.Tun
|
||||
|
||||
//export startTUN
|
||||
func startTUN(fd C.int) bool {
|
||||
tunLock.Lock()
|
||||
defer tunLock.Unlock()
|
||||
func startTUN(fd C.int) {
|
||||
go func() {
|
||||
tunLock.Lock()
|
||||
defer tunLock.Unlock()
|
||||
|
||||
if tun != nil {
|
||||
tun.Close()
|
||||
tun = nil
|
||||
}
|
||||
f := int(fd)
|
||||
gateway := "172.16.0.1/30"
|
||||
portal := "172.16.0.2"
|
||||
dns := "0.0.0.0"
|
||||
if tun != nil {
|
||||
tun.Close()
|
||||
tun = nil
|
||||
}
|
||||
f := int(fd)
|
||||
gateway := "172.16.0.1/30"
|
||||
portal := "172.16.0.2"
|
||||
dns := "0.0.0.0"
|
||||
|
||||
tempTun := &t.Tun{Closed: false, Limit: semaphore.NewWeighted(4)}
|
||||
tempTun := &t.Tun{Closed: false, Limit: semaphore.NewWeighted(4)}
|
||||
|
||||
closer, err := t.Start(f, gateway, portal, dns)
|
||||
closer, err := t.Start(f, gateway, portal, dns)
|
||||
|
||||
applyConfig(true)
|
||||
applyConfig(true)
|
||||
|
||||
if err != nil {
|
||||
log.Errorln("startTUN error: %v", err)
|
||||
tempTun.Close()
|
||||
return false
|
||||
}
|
||||
if err != nil {
|
||||
log.Errorln("startTUN error: %v", err)
|
||||
tempTun.Close()
|
||||
}
|
||||
|
||||
tempTun.Closer = closer
|
||||
tempTun.Closer = closer
|
||||
|
||||
tun = tempTun
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
//export updateMarkSocketPort
|
||||
func updateMarkSocketPort(markSocketPort C.longlong) bool {
|
||||
tunLock.Lock()
|
||||
defer tunLock.Unlock()
|
||||
//if tun != nil {
|
||||
// tun.MarkSocketPort = int64(markSocketPort)
|
||||
//}
|
||||
return true
|
||||
tun = tempTun
|
||||
}()
|
||||
}
|
||||
|
||||
//export stopTun
|
||||
func stopTun() {
|
||||
tunLock.Lock()
|
||||
defer tunLock.Unlock()
|
||||
go func() {
|
||||
tunLock.Lock()
|
||||
defer tunLock.Unlock()
|
||||
|
||||
if tun != nil {
|
||||
tun.Close()
|
||||
applyConfig(true)
|
||||
tun = nil
|
||||
}
|
||||
if tun != nil {
|
||||
tun.Close()
|
||||
applyConfig(true)
|
||||
tun = nil
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -82,7 +82,11 @@ class ApplicationState extends State<Application> {
|
||||
super.initState();
|
||||
globalState.appController = AppController(context);
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
globalState.appController.afterInit();
|
||||
final currentContext = globalState.navigatorKey.currentContext;
|
||||
if (currentContext != null) {
|
||||
globalState.appController = AppController(currentContext);
|
||||
}
|
||||
await globalState.appController.init();
|
||||
globalState.appController.initLink();
|
||||
_updateGroups();
|
||||
});
|
||||
@@ -160,8 +164,9 @@ class ApplicationState extends State<Application> {
|
||||
AppLocalizations.delegate.supportedLocales,
|
||||
themeMode: state.themeMode,
|
||||
theme: ThemeData(
|
||||
pageTransitionsTheme: _pageTransitionsTheme,
|
||||
useMaterial3: true,
|
||||
fontFamily: '',
|
||||
pageTransitionsTheme: _pageTransitionsTheme,
|
||||
colorScheme: _getAppColorScheme(
|
||||
brightness: Brightness.light,
|
||||
systemColorSchemes: systemColorSchemes,
|
||||
@@ -170,6 +175,7 @@ class ApplicationState extends State<Application> {
|
||||
),
|
||||
darkTheme: ThemeData(
|
||||
useMaterial3: true,
|
||||
fontFamily: '',
|
||||
pageTransitionsTheme: _pageTransitionsTheme,
|
||||
colorScheme: _getAppColorScheme(
|
||||
brightness: Brightness.dark,
|
||||
|
||||
@@ -99,8 +99,8 @@ class ClashCore {
|
||||
final groupNames = [
|
||||
UsedProxy.GLOBAL.name,
|
||||
...(proxies[UsedProxy.GLOBAL.name]["all"] as List).where((e) {
|
||||
final proxy = proxies[e];
|
||||
return GroupTypeExtension.valueList.contains(proxy['type']);
|
||||
final proxy = proxies[e] ?? {};
|
||||
return GroupTypeExtension.valueList.contains(proxy['type']) && proxy['hidden'] != true;
|
||||
})
|
||||
];
|
||||
final groupsRaw = groupNames.map((groupName) {
|
||||
@@ -156,23 +156,36 @@ class ClashCore {
|
||||
return clashFFI.changeProxy(params.toNativeUtf8().cast()) == 1;
|
||||
}
|
||||
|
||||
bool delay(String proxyName) {
|
||||
Future<Delay> getDelay(String proxyName) {
|
||||
final delayParams = {
|
||||
"proxy-name": proxyName,
|
||||
"timeout": httpTimeoutDuration.inMilliseconds,
|
||||
};
|
||||
clashFFI.asyncTestDelay(json.encode(delayParams).toNativeUtf8().cast());
|
||||
return true;
|
||||
final completer = Completer<Delay>();
|
||||
final receiver = ReceivePort();
|
||||
receiver.listen((message) {
|
||||
if (!completer.isCompleted) {
|
||||
completer.complete(Delay.fromJson(json.decode(message)));
|
||||
receiver.close();
|
||||
}
|
||||
});
|
||||
clashFFI.asyncTestDelay(
|
||||
json.encode(delayParams).toNativeUtf8().cast(),
|
||||
receiver.sendPort.nativePort,
|
||||
);
|
||||
Future.delayed(httpTimeoutDuration + moreDuration, () {
|
||||
receiver.close();
|
||||
completer.complete(
|
||||
Delay(name: proxyName, value: -1),
|
||||
);
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
clearEffect(String path) {
|
||||
clashFFI.clearEffect(path.toNativeUtf8().cast());
|
||||
}
|
||||
|
||||
healthcheck() {
|
||||
clashFFI.healthcheck();
|
||||
}
|
||||
|
||||
VersionInfo getVersionInfo() {
|
||||
final versionInfoRaw = clashFFI.getVersionInfo();
|
||||
final versionInfo = json.decode(versionInfoRaw.cast<Utf8>().toDartString());
|
||||
@@ -197,10 +210,24 @@ class ClashCore {
|
||||
clashFFI.startTUN(fd);
|
||||
}
|
||||
|
||||
requestGc() {
|
||||
clashFFI.forceGc();
|
||||
}
|
||||
|
||||
void stopTun() {
|
||||
clashFFI.stopTun();
|
||||
}
|
||||
|
||||
void setProcessMap(ProcessMapItem processMapItem) {
|
||||
clashFFI.setProcessMap(json.encode(processMapItem).toNativeUtf8().cast());
|
||||
}
|
||||
|
||||
DateTime? getRunTime() {
|
||||
final runTimeString = clashFFI.getRunTime().cast<Utf8>().toDartString();
|
||||
if (runTimeString.isEmpty) return null;
|
||||
return DateTime.fromMillisecondsSinceEpoch(int.parse(runTimeString));
|
||||
}
|
||||
|
||||
List<Connection> getConnections() {
|
||||
final connectionsDataRaw = clashFFI.getConnections();
|
||||
final connectionsData =
|
||||
|
||||
@@ -893,6 +893,14 @@ class ClashFFI {
|
||||
_lookup<ffi.NativeFunction<GoUint8 Function()>>('shutdownClash');
|
||||
late final _shutdownClash = _shutdownClashPtr.asFunction<int Function()>();
|
||||
|
||||
void forceGc() {
|
||||
return _forceGc();
|
||||
}
|
||||
|
||||
late final _forceGcPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function()>>('forceGc');
|
||||
late final _forceGc = _forceGcPtr.asFunction<void Function()>();
|
||||
|
||||
void validateConfig(
|
||||
ffi.Pointer<ffi.Char> s,
|
||||
int port,
|
||||
@@ -977,17 +985,20 @@ class ClashFFI {
|
||||
|
||||
void asyncTestDelay(
|
||||
ffi.Pointer<ffi.Char> s,
|
||||
int port,
|
||||
) {
|
||||
return _asyncTestDelay(
|
||||
s,
|
||||
port,
|
||||
);
|
||||
}
|
||||
|
||||
late final _asyncTestDelayPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>(
|
||||
'asyncTestDelay');
|
||||
late final _asyncTestDelay =
|
||||
_asyncTestDelayPtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
|
||||
late final _asyncTestDelayPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<ffi.Char>, ffi.LongLong)>>('asyncTestDelay');
|
||||
late final _asyncTestDelay = _asyncTestDelayPtr
|
||||
.asFunction<void Function(ffi.Pointer<ffi.Char>, int)>();
|
||||
|
||||
ffi.Pointer<ffi.Char> getVersionInfo() {
|
||||
return _getVersionInfo();
|
||||
@@ -1086,14 +1097,6 @@ class ClashFFI {
|
||||
late final _updateExternalProvider = _updateExternalProviderPtr.asFunction<
|
||||
void Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int)>();
|
||||
|
||||
void healthcheck() {
|
||||
return _healthcheck();
|
||||
}
|
||||
|
||||
late final _healthcheckPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function()>>('healthcheck');
|
||||
late final _healthcheck = _healthcheckPtr.asFunction<void Function()>();
|
||||
|
||||
void initNativeApiBridge(
|
||||
ffi.Pointer<ffi.Void> api,
|
||||
int port,
|
||||
@@ -1127,7 +1130,21 @@ class ClashFFI {
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function()>>('stopLog');
|
||||
late final _stopLog = _stopLogPtr.asFunction<void Function()>();
|
||||
|
||||
int startTUN(
|
||||
void setProcessMap(
|
||||
ffi.Pointer<ffi.Char> s,
|
||||
) {
|
||||
return _setProcessMap(
|
||||
s,
|
||||
);
|
||||
}
|
||||
|
||||
late final _setProcessMapPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>(
|
||||
'setProcessMap');
|
||||
late final _setProcessMap =
|
||||
_setProcessMapPtr.asFunction<void Function(ffi.Pointer<ffi.Char>)>();
|
||||
|
||||
void startTUN(
|
||||
int fd,
|
||||
) {
|
||||
return _startTUN(
|
||||
@@ -1136,22 +1153,18 @@ class ClashFFI {
|
||||
}
|
||||
|
||||
late final _startTUNPtr =
|
||||
_lookup<ffi.NativeFunction<GoUint8 Function(ffi.Int)>>('startTUN');
|
||||
late final _startTUN = _startTUNPtr.asFunction<int Function(int)>();
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int)>>('startTUN');
|
||||
late final _startTUN = _startTUNPtr.asFunction<void Function(int)>();
|
||||
|
||||
int updateMarkSocketPort(
|
||||
int markSocketPort,
|
||||
) {
|
||||
return _updateMarkSocketPort(
|
||||
markSocketPort,
|
||||
);
|
||||
ffi.Pointer<ffi.Char> getRunTime() {
|
||||
return _getRunTime();
|
||||
}
|
||||
|
||||
late final _updateMarkSocketPortPtr =
|
||||
_lookup<ffi.NativeFunction<GoUint8 Function(ffi.LongLong)>>(
|
||||
'updateMarkSocketPort');
|
||||
late final _updateMarkSocketPort =
|
||||
_updateMarkSocketPortPtr.asFunction<int Function(int)>();
|
||||
late final _getRunTimePtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
|
||||
'getRunTime');
|
||||
late final _getRunTime =
|
||||
_getRunTimePtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
||||
|
||||
void stopTun() {
|
||||
return _stopTun();
|
||||
|
||||
@@ -14,9 +14,13 @@ abstract mixin class ClashMessageListener {
|
||||
|
||||
void onDelay(Delay delay) {}
|
||||
|
||||
void onProcess(Metadata metadata) {}
|
||||
void onProcess(Process process) {}
|
||||
|
||||
void onRequest(Connection connection) {}
|
||||
|
||||
void onNow(Now now) {}
|
||||
|
||||
void onRun(String runTime) {}
|
||||
}
|
||||
|
||||
class ClashMessage {
|
||||
@@ -41,11 +45,17 @@ class ClashMessage {
|
||||
listener.onDelay(Delay.fromJson(m.data));
|
||||
break;
|
||||
case MessageType.process:
|
||||
listener.onProcess(Metadata.fromJson(m.data));
|
||||
listener.onProcess(Process.fromJson(m.data));
|
||||
break;
|
||||
case MessageType.now:
|
||||
listener.onNow(Now.fromJson(m.data));
|
||||
break;
|
||||
case MessageType.request:
|
||||
listener.onRequest(Connection.fromJson(m.data));
|
||||
break;
|
||||
case MessageType.run:
|
||||
listener.onRun(m.data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ class Android {
|
||||
init() async {
|
||||
app?.onExit = () {
|
||||
clashCore.shutdown();
|
||||
print("adsadda==>");
|
||||
exit(0);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,8 +18,11 @@ const configKey = "config";
|
||||
const listItemPadding = EdgeInsets.symmetric(horizontal: 16);
|
||||
const double dialogCommonWidth = 300;
|
||||
const repository = "chen08209/FlClash";
|
||||
const defaultExternalController = "127.0.0.1:9090";
|
||||
const maxMobileWidth = 600;
|
||||
const maxLaptopWidth = 840;
|
||||
const geodataLoaderMemconservative = "memconservative";
|
||||
const geodataLoaderStandard = "standard";
|
||||
final filter = ImageFilter.blur(
|
||||
sigmaX: 5,
|
||||
sigmaY: 5,
|
||||
|
||||
@@ -35,4 +35,8 @@ extension DateTimeExtension on DateTime {
|
||||
}
|
||||
return appLocalizations.just;
|
||||
}
|
||||
}
|
||||
|
||||
String get show {
|
||||
return toIso8601String().substring(0, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,11 @@ class Measure {
|
||||
double? _bodyMediumHeight;
|
||||
double? _bodySmallHeight;
|
||||
double? _labelSmallHeight;
|
||||
double? _labelMediumHeight;
|
||||
double? _titleLargeHeight;
|
||||
double? _titleMediumHeight;
|
||||
|
||||
|
||||
double get bodyMediumHeight{
|
||||
double get bodyMediumHeight {
|
||||
_bodyMediumHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
@@ -36,7 +37,7 @@ class Measure {
|
||||
return _bodyMediumHeight!;
|
||||
}
|
||||
|
||||
double get bodySmallHeight{
|
||||
double get bodySmallHeight {
|
||||
_bodySmallHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
@@ -46,7 +47,7 @@ class Measure {
|
||||
return _bodySmallHeight!;
|
||||
}
|
||||
|
||||
double get labelSmallHeight{
|
||||
double get labelSmallHeight {
|
||||
_labelSmallHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
@@ -56,7 +57,17 @@ class Measure {
|
||||
return _labelSmallHeight!;
|
||||
}
|
||||
|
||||
double get titleLargeHeight{
|
||||
double get labelMediumHeight {
|
||||
_labelMediumHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
style: context.textTheme.labelMedium,
|
||||
),
|
||||
).height;
|
||||
return _labelMediumHeight!;
|
||||
}
|
||||
|
||||
double get titleLargeHeight {
|
||||
_titleLargeHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
@@ -65,4 +76,14 @@ class Measure {
|
||||
).height;
|
||||
return _titleLargeHeight!;
|
||||
}
|
||||
|
||||
double get titleMediumHeight {
|
||||
_titleMediumHeight ??= computeTextSize(
|
||||
Text(
|
||||
"",
|
||||
style: context.textTheme.titleMedium,
|
||||
),
|
||||
).height;
|
||||
return _titleMediumHeight!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,13 @@ class Navigation {
|
||||
label: "profiles",
|
||||
fragment: ProfilesFragment(),
|
||||
),
|
||||
const NavigationItem(
|
||||
icon: Icon(Icons.ballot),
|
||||
label: "requests",
|
||||
fragment: RequestFragment(),
|
||||
description: "requestsDesc",
|
||||
modes: [NavigationItemMode.desktop, NavigationItemMode.more],
|
||||
),
|
||||
const NavigationItem(
|
||||
icon: Icon(Icons.swap_vert_circle),
|
||||
label: "resources",
|
||||
|
||||
@@ -10,8 +10,7 @@ class Picker {
|
||||
if (Platform.isAndroid) {
|
||||
filePickerResult = await FilePicker.platform.pickFiles(
|
||||
withData: true,
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['txt', 'conf'],
|
||||
allowMultiple: false,
|
||||
);
|
||||
} else {
|
||||
filePickerResult = await FilePicker.platform.pickFiles(
|
||||
|
||||
@@ -9,13 +9,11 @@ import 'package:fl_clash/state.dart';
|
||||
class Request {
|
||||
late final Dio _dio;
|
||||
int? _port;
|
||||
bool _isStart = false;
|
||||
|
||||
Request() {
|
||||
_dio = Dio(
|
||||
BaseOptions(
|
||||
connectTimeout: httpTimeoutDuration,
|
||||
sendTimeout: httpTimeoutDuration,
|
||||
receiveTimeout: httpTimeoutDuration,
|
||||
headers: {"User-Agent": coreName},
|
||||
),
|
||||
);
|
||||
@@ -29,11 +27,14 @@ class Request {
|
||||
|
||||
_syncProxy() {
|
||||
final port = globalState.appController.clashConfig.mixedPort;
|
||||
if (_port != port) {
|
||||
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.findProxy = (url) {
|
||||
return "PROXY localhost:$_port;DIRECT";
|
||||
};
|
||||
@@ -52,7 +53,7 @@ class Request {
|
||||
),
|
||||
)
|
||||
.timeout(
|
||||
httpTimeoutDuration,
|
||||
httpTimeoutDuration * 2,
|
||||
);
|
||||
return response;
|
||||
}
|
||||
@@ -82,12 +83,14 @@ class Request {
|
||||
"https://ipinfo.io/json/": IpInfo.fromIpInfoIoJson,
|
||||
};
|
||||
|
||||
Future<IpInfo> checkIp() async {
|
||||
Future<IpInfo?> checkIp(CancelToken? cancelToken) async {
|
||||
for (final source in _ipInfoSources.entries) {
|
||||
try {
|
||||
final response = await _dio.get<Map<String, dynamic>>(
|
||||
source.key,
|
||||
);
|
||||
final response = await _dio
|
||||
.get<Map<String, dynamic>>(source.key, cancelToken: cancelToken)
|
||||
.timeout(
|
||||
httpTimeoutDuration,
|
||||
);
|
||||
if (response.statusCode == 200 && response.data != null) {
|
||||
return source.value(response.data!);
|
||||
}
|
||||
@@ -95,7 +98,7 @@ class Request {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
throw "无法检索ip";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,11 @@ extension TextStyleExtension on TextStyle {
|
||||
return copyWith(color: color?.toLight());
|
||||
}
|
||||
|
||||
toLighter() {
|
||||
return copyWith(color: color?.toLighter());
|
||||
}
|
||||
|
||||
|
||||
toSoftBold() {
|
||||
return copyWith(fontWeight: FontWeight.w500);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -39,8 +40,6 @@ class AppController {
|
||||
updateRunTime,
|
||||
updateTraffic,
|
||||
];
|
||||
clearShowProxyDelay();
|
||||
testShowProxyDelay();
|
||||
} else {
|
||||
await globalState.stopSystemProxy();
|
||||
appState.traffics = [];
|
||||
@@ -98,10 +97,12 @@ class AppController {
|
||||
}
|
||||
}
|
||||
|
||||
updateProfile(String id) async {
|
||||
Future<void> updateProfile(String id) async {
|
||||
final profile = config.getCurrentProfileForId(id);
|
||||
if (profile != null) {
|
||||
await profile.update();
|
||||
final tempProfile = profile.copyWith();
|
||||
await tempProfile.update();
|
||||
config.setProfile(tempProfile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,16 +136,34 @@ class AppController {
|
||||
|
||||
autoUpdateProfiles() async {
|
||||
for (final profile in config.profiles) {
|
||||
if (!profile.autoUpdate) return;
|
||||
if (!profile.autoUpdate) continue;
|
||||
final isNotNeedUpdate = profile.lastUpdateDate
|
||||
?.add(
|
||||
profile.autoUpdateDuration,
|
||||
)
|
||||
.isBeforeNow;
|
||||
if (isNotNeedUpdate == false ||
|
||||
profile.url == null ||
|
||||
profile.url!.isEmpty) continue;
|
||||
await profile.update();
|
||||
if (isNotNeedUpdate == false || profile.type == ProfileType.file) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
await updateProfile(profile.id);
|
||||
} catch (e) {
|
||||
appState.addLog(
|
||||
Log(
|
||||
logLevel: LogLevel.info,
|
||||
payload: e.toString(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateProfiles() async {
|
||||
for (final profile in config.profiles) {
|
||||
if (profile.type == ProfileType.file) {
|
||||
continue;
|
||||
}
|
||||
await updateProfile(profile.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,20 +231,21 @@ class AppController {
|
||||
final tagName = data['tag_name'];
|
||||
final body = data['body'];
|
||||
final submits = other.parseReleaseBody(body);
|
||||
final textTheme = context.textTheme;
|
||||
globalState.showMessage(
|
||||
title: appLocalizations.discoverNewVersion,
|
||||
message: TextSpan(
|
||||
text: "$tagName \n",
|
||||
style: context.textTheme.headlineSmall,
|
||||
style: textTheme.headlineSmall,
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "\n",
|
||||
style: context.textTheme.bodyMedium,
|
||||
style: textTheme.bodyMedium,
|
||||
),
|
||||
for (final submit in submits)
|
||||
TextSpan(
|
||||
text: "- $submit \n",
|
||||
style: context.textTheme.bodyMedium,
|
||||
style: textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -246,6 +266,29 @@ class AppController {
|
||||
}
|
||||
}
|
||||
|
||||
init() async {
|
||||
if (!config.silentLaunch) {
|
||||
window?.show();
|
||||
}
|
||||
final commonScaffoldState = globalState.homeScaffoldKey.currentState;
|
||||
if (commonScaffoldState?.mounted == true) {
|
||||
await commonScaffoldState?.loadingRun(() async {
|
||||
await globalState.applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
},title: appLocalizations.init);
|
||||
} else {
|
||||
await globalState.applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
}
|
||||
await afterInit();
|
||||
}
|
||||
|
||||
afterInit() async {
|
||||
if (config.autoRun) {
|
||||
await updateSystemProxy(true);
|
||||
@@ -255,25 +298,9 @@ class AppController {
|
||||
}
|
||||
autoUpdateProfiles();
|
||||
updateLogStatus();
|
||||
if (!config.silentLaunch) {
|
||||
window?.show();
|
||||
}
|
||||
autoCheckUpdate();
|
||||
}
|
||||
|
||||
healthcheck() {
|
||||
if (globalState.healthcheckLock) return;
|
||||
for (final delay in appState.delayMap.entries) {
|
||||
setDelay(
|
||||
Delay(
|
||||
name: delay.key,
|
||||
value: 0,
|
||||
),
|
||||
);
|
||||
}
|
||||
clashCore.healthcheck();
|
||||
}
|
||||
|
||||
setDelay(Delay delay) {
|
||||
appState.setDelay(delay);
|
||||
}
|
||||
@@ -383,22 +410,6 @@ class AppController {
|
||||
addProfileFormURL(url);
|
||||
}
|
||||
|
||||
clearShowProxyDelay() {
|
||||
final showProxyDelay = appState.getRealProxyName(appState.showProxyName);
|
||||
if (showProxyDelay != null) {
|
||||
appState.setDelay(
|
||||
Delay(name: showProxyDelay, value: null),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
testShowProxyDelay() {
|
||||
final showProxyDelay = appState.getRealProxyName(appState.showProxyName);
|
||||
if (showProxyDelay != null) {
|
||||
globalState.updateCurrentDelay(showProxyDelay);
|
||||
}
|
||||
}
|
||||
|
||||
updateViewWidth(double width) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
appState.viewWidth = width;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
enum GroupType { Selector, URLTest, Fallback }
|
||||
enum GroupType { Selector, URLTest, Fallback, LoadBalance, Relay }
|
||||
|
||||
enum GroupName { GLOBAL, Proxy, Auto, Fallback }
|
||||
|
||||
@@ -56,7 +56,9 @@ enum ProfileType { file, url }
|
||||
|
||||
enum ResultType { success, error }
|
||||
|
||||
enum MessageType { log, tun, delay, process, now }
|
||||
enum MessageType { log, tun, delay, process, now, request, run }
|
||||
|
||||
enum FindProcessMode { always, off }
|
||||
|
||||
enum RecoveryOption {
|
||||
all,
|
||||
|
||||
@@ -8,6 +8,13 @@ import 'package:fl_clash/widgets/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
extension AccessControlExtension on AccessControl {
|
||||
List<String> get currentList => switch (mode) {
|
||||
AccessControlMode.acceptSelected => acceptList,
|
||||
AccessControlMode.rejectSelected => rejectList,
|
||||
};
|
||||
}
|
||||
|
||||
class AccessFragment extends StatefulWidget {
|
||||
const AccessFragment({super.key});
|
||||
|
||||
@@ -83,136 +90,70 @@ class _AccessFragmentState extends State<AccessFragment> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSelectedAllButton({
|
||||
required bool isSelectedAll,
|
||||
required List<String> allValueList,
|
||||
}) {
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
final tooltip = isSelectedAll
|
||||
? appLocalizations.cancelSelectAll
|
||||
: appLocalizations.selectAll;
|
||||
return IconButton(
|
||||
tooltip: tooltip,
|
||||
onPressed: () {
|
||||
final config = globalState.appController.config;
|
||||
final isAccept =
|
||||
config.accessControl.mode == AccessControlMode.acceptSelected;
|
||||
|
||||
if (isSelectedAll) {
|
||||
config.accessControl = switch (isAccept) {
|
||||
true => config.accessControl.copyWith(
|
||||
acceptList: [],
|
||||
),
|
||||
false => config.accessControl.copyWith(
|
||||
rejectList: [],
|
||||
),
|
||||
};
|
||||
} else {
|
||||
config.accessControl = switch (isAccept) {
|
||||
true => config.accessControl.copyWith(
|
||||
acceptList: allValueList,
|
||||
),
|
||||
false => config.accessControl.copyWith(
|
||||
rejectList: allValueList,
|
||||
),
|
||||
};
|
||||
}
|
||||
},
|
||||
icon: isSelectedAll
|
||||
? const Icon(Icons.deselect)
|
||||
: const Icon(Icons.select_all),
|
||||
);
|
||||
Widget _buildSearchButton(List<Package> packages) {
|
||||
return IconButton(
|
||||
tooltip: appLocalizations.search,
|
||||
onPressed: () {
|
||||
showSearch(
|
||||
context: context,
|
||||
delegate: AccessControlSearchDelegate(
|
||||
packages: packages,
|
||||
),
|
||||
).then((_) => {setState(() {})});
|
||||
},
|
||||
icon: const Icon(Icons.search),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _actionHeader({
|
||||
_buildSelectedAllButton({
|
||||
required bool isAccessControl,
|
||||
required List<String> valueList,
|
||||
required String describe,
|
||||
required List<String> packageNameList,
|
||||
required bool isSelectedAll,
|
||||
required List<String> allValueList,
|
||||
}) {
|
||||
return AbsorbPointer(
|
||||
absorbing: !isAccessControl,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 4,
|
||||
bottom: 4,
|
||||
left: 16,
|
||||
right: 8,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Expanded(
|
||||
child: IntrinsicHeight(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
appLocalizations.selected,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(
|
||||
color:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Flexible(
|
||||
child: SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
"${valueList.length}",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(
|
||||
color:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final tooltip = isSelectedAll
|
||||
? appLocalizations.cancelSelectAll
|
||||
: appLocalizations.selectAll;
|
||||
final commonScaffoldState =
|
||||
context.findAncestorStateOfType<CommonScaffoldState>();
|
||||
commonScaffoldState?.floatingActionButton = DisabledMask(
|
||||
status: !isAccessControl,
|
||||
child: AbsorbPointer(
|
||||
absorbing: !isAccessControl,
|
||||
child: FloatingActionButton (
|
||||
tooltip: tooltip,
|
||||
onPressed: () {
|
||||
final config = globalState.appController.config;
|
||||
final isAccept =
|
||||
config.accessControl.mode == AccessControlMode.acceptSelected;
|
||||
|
||||
if (isSelectedAll) {
|
||||
config.accessControl = switch (isAccept) {
|
||||
true => config.accessControl.copyWith(
|
||||
acceptList: [],
|
||||
),
|
||||
Flexible(
|
||||
child: Text(describe),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(
|
||||
child: _buildSelectedAllButton(
|
||||
isSelectedAll: const ListEquality<String>()
|
||||
.equals(valueList, packageNameList),
|
||||
allValueList: packageNameList,
|
||||
),
|
||||
),
|
||||
Flexible(child: _buildFilterSystemAppButton()),
|
||||
Flexible(child: _buildAppProxyModePopup()),
|
||||
],
|
||||
),
|
||||
],
|
||||
false => config.accessControl.copyWith(
|
||||
rejectList: [],
|
||||
),
|
||||
};
|
||||
} else {
|
||||
config.accessControl = switch (isAccept) {
|
||||
true => config.accessControl.copyWith(
|
||||
acceptList: allValueList,
|
||||
),
|
||||
false => config.accessControl.copyWith(
|
||||
rejectList: allValueList,
|
||||
),
|
||||
};
|
||||
}
|
||||
},
|
||||
child: isSelectedAll
|
||||
? const Icon(Icons.deselect)
|
||||
: const Icon(Icons.select_all),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildPackageList() {
|
||||
@@ -252,14 +193,11 @@ class _AccessFragmentState extends State<AccessFragment> {
|
||||
accessControlMode == AccessControlMode.acceptSelected
|
||||
? acceptPackages
|
||||
: rejectPackages;
|
||||
final currentList =
|
||||
accessControlMode == AccessControlMode.acceptSelected
|
||||
? accessControl.acceptList
|
||||
: accessControl.rejectList;
|
||||
final currentList = accessControl.currentList;
|
||||
final currentPackages = isFilterSystemApp
|
||||
? packages
|
||||
.where((element) => element.isSystem == false)
|
||||
.toList()
|
||||
.where((element) => element.isSystem == false)
|
||||
.toList()
|
||||
: packages;
|
||||
final packageNameList =
|
||||
currentPackages.map((e) => e.packageName).toList();
|
||||
@@ -268,15 +206,91 @@ class _AccessFragmentState extends State<AccessFragment> {
|
||||
accessControlMode == AccessControlMode.acceptSelected
|
||||
? appLocalizations.accessControlAllowDesc
|
||||
: appLocalizations.accessControlNotAllowDesc;
|
||||
_buildSelectedAllButton(
|
||||
isAccessControl: isAccessControl,
|
||||
isSelectedAll: valueList.length == packageNameList.length,
|
||||
allValueList: packageNameList,
|
||||
);
|
||||
return DisabledMask(
|
||||
status: !isAccessControl,
|
||||
child: Column(
|
||||
children: [
|
||||
_actionHeader(
|
||||
isAccessControl: isAccessControl,
|
||||
valueList: valueList,
|
||||
describe: describe,
|
||||
packageNameList: packageNameList,
|
||||
AbsorbPointer(
|
||||
absorbing: !isAccessControl,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 4,
|
||||
bottom: 4,
|
||||
left: 16,
|
||||
right: 8,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Expanded(
|
||||
child: IntrinsicHeight(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
appLocalizations.selected,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Flexible(
|
||||
child: SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
"${valueList.length}",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(describe),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(
|
||||
child: _buildSearchButton(currentPackages)),
|
||||
Flexible(child: _buildFilterSystemAppButton()),
|
||||
Flexible(child: _buildAppProxyModePopup()),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
@@ -429,3 +443,111 @@ class PackageListItem extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AccessControlSearchDelegate extends SearchDelegate {
|
||||
final List<Package> packages;
|
||||
|
||||
AccessControlSearchDelegate({
|
||||
required this.packages,
|
||||
});
|
||||
|
||||
List<Package> get _results {
|
||||
final lowQuery = query.toLowerCase();
|
||||
return packages
|
||||
.where(
|
||||
(package) =>
|
||||
package.label.toLowerCase().contains(lowQuery) ||
|
||||
package.packageName.contains(lowQuery),
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget>? buildActions(BuildContext context) {
|
||||
return [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
if (query.isEmpty) {
|
||||
close(context, null);
|
||||
return;
|
||||
}
|
||||
query = '';
|
||||
},
|
||||
icon: const Icon(Icons.clear),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget? buildLeading(BuildContext context) {
|
||||
return IconButton(
|
||||
onPressed: () {
|
||||
close(context, null);
|
||||
},
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _packageList(List<Package> packages) {
|
||||
return Selector<Config, PackageListSelectorState>(
|
||||
selector: (_, config) => PackageListSelectorState(
|
||||
accessControl: config.accessControl,
|
||||
isAccessControl: config.isAccessControl,
|
||||
),
|
||||
builder: (context, state, __) {
|
||||
final accessControl = state.accessControl;
|
||||
final isAccessControl = state.isAccessControl;
|
||||
final accessControlMode = accessControl.mode;
|
||||
final currentList = accessControl.currentList;
|
||||
final packageNameList =
|
||||
this.packages.map((e) => e.packageName).toList();
|
||||
final valueList = currentList.intersection(packageNameList);
|
||||
return DisabledMask(
|
||||
status: !isAccessControl,
|
||||
child: ListView.builder(
|
||||
itemCount: packages.length,
|
||||
itemBuilder: (_, index) {
|
||||
final package = packages[index];
|
||||
return PackageListItem(
|
||||
key: Key(package.packageName),
|
||||
package: package,
|
||||
value: valueList.contains(package.packageName),
|
||||
isActive: isAccessControl,
|
||||
onChanged: (value) {
|
||||
if (value == true) {
|
||||
valueList.add(package.packageName);
|
||||
} else {
|
||||
valueList.remove(package.packageName);
|
||||
}
|
||||
final config = globalState.appController.config;
|
||||
if (accessControlMode == AccessControlMode.acceptSelected) {
|
||||
config.accessControl = config.accessControl.copyWith(
|
||||
acceptList: valueList,
|
||||
);
|
||||
} else {
|
||||
config.accessControl = config.accessControl.copyWith(
|
||||
rejectList: valueList,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildResults(BuildContext context) {
|
||||
return buildSuggestions(context);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildSuggestions(BuildContext context) {
|
||||
return _packageList(_results);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
@@ -37,16 +39,132 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
}
|
||||
}
|
||||
|
||||
_updateLoglevel(LogLevel? logLevel) {
|
||||
if (logLevel == null ||
|
||||
logLevel == globalState.appController.clashConfig.logLevel) return;
|
||||
globalState.appController.clashConfig.logLevel = logLevel;
|
||||
globalState.appController.updateClashConfigDebounce();
|
||||
Widget _buildAppSection() {
|
||||
final 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;
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
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.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.updateClashConfig(isPatch: false);
|
||||
await appController.updateGroups();
|
||||
appController.changeProxy();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
];
|
||||
return Section(
|
||||
title: appLocalizations.app,
|
||||
child: Column(
|
||||
children: [
|
||||
for (final item in items) ...[
|
||||
item,
|
||||
if (items.last != item)
|
||||
const Divider(
|
||||
height: 0,
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> items = [
|
||||
_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),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGeneralSection() {
|
||||
final 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),
|
||||
onTab: () {
|
||||
_showLogLevelDialog(value);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
Selector<ClashConfig, int>(
|
||||
selector: (_, clashConfig) => clashConfig.mixedPort,
|
||||
builder: (_, mixedPort, __) {
|
||||
@@ -54,9 +172,9 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
onTab: () {
|
||||
_modifyMixedPort(mixedPort);
|
||||
},
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16,vertical: 4),
|
||||
leading: const Icon(Icons.adjust),
|
||||
leading: const Icon(Icons.adjust_outlined),
|
||||
title: Text(appLocalizations.proxyPort),
|
||||
subtitle: Text(appLocalizations.proxyPortDesc),
|
||||
trailing: FilledButton.tonal(
|
||||
onPressed: () {
|
||||
_modifyMixedPort(mixedPort);
|
||||
@@ -68,6 +186,24 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
);
|
||||
},
|
||||
),
|
||||
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, __) {
|
||||
@@ -86,12 +222,129 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
);
|
||||
},
|
||||
),
|
||||
if (system.isDesktop)
|
||||
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();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
];
|
||||
return Section(
|
||||
title: appLocalizations.general,
|
||||
child: Column(
|
||||
children: [
|
||||
for (final item in items) ...[
|
||||
item,
|
||||
if (items.last != item)
|
||||
const Divider(
|
||||
height: 0,
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMoreSection() {
|
||||
final items = [
|
||||
if (false)
|
||||
Selector<ClashConfig, bool>(
|
||||
selector: (_, clashConfig) => clashConfig.tun.enable,
|
||||
builder: (_, tunEnable, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.support),
|
||||
leading: const Icon(
|
||||
Icons.important_devices_outlined
|
||||
),
|
||||
title: Text(appLocalizations.tun),
|
||||
subtitle: Text(appLocalizations.tunDesc),
|
||||
delegate: SwitchDelegate(
|
||||
@@ -105,73 +358,39 @@ class _ConfigFragmentState extends State<ConfigFragment> {
|
||||
);
|
||||
},
|
||||
),
|
||||
Selector<Config, bool>(
|
||||
selector: (_, config) => config.isCompatible,
|
||||
builder: (_, isCompatible, __) {
|
||||
return ListItem.switchItem(
|
||||
leading: const Icon(Icons.expand),
|
||||
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.updateClashConfig(isPatch: false);
|
||||
await appController.updateGroups();
|
||||
appController.changeProxy();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Padding(
|
||||
padding: kMaterialListPadding,
|
||||
child: Selector<ClashConfig, LogLevel>(
|
||||
selector: (_, clashConfig) => clashConfig.logLevel,
|
||||
builder: (_, value, __) {
|
||||
return ListItem(
|
||||
leading: const Icon(Icons.feedback),
|
||||
title: Text(appLocalizations.logLevel),
|
||||
trailing: SizedBox(
|
||||
height: 48,
|
||||
child: DropdownMenu<LogLevel>(
|
||||
width: 124,
|
||||
inputDecorationTheme: const InputDecorationTheme(
|
||||
filled: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 5,
|
||||
horizontal: 16,
|
||||
),
|
||||
),
|
||||
initialSelection: value,
|
||||
dropdownMenuEntries: [
|
||||
for (final logLevel in LogLevel.values)
|
||||
DropdownMenuEntry<LogLevel>(
|
||||
value: logLevel,
|
||||
label: logLevel.name,
|
||||
)
|
||||
],
|
||||
onSelected: _updateLoglevel,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
];
|
||||
return ListView.separated(
|
||||
if(items.isEmpty) return Container();
|
||||
return Section(
|
||||
title: appLocalizations.general,
|
||||
child: Column(
|
||||
children: [
|
||||
for (final item in items) ...[
|
||||
item,
|
||||
if (items.last != item)
|
||||
const Divider(
|
||||
height: 0,
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@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],
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) {
|
||||
return const Divider(
|
||||
height: 0,
|
||||
);
|
||||
},
|
||||
itemCount: items.length,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,140 +1,140 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fl_clash/clash/core.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/plugins/app.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:fl_clash/widgets/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ConnectionsFragment extends StatefulWidget {
|
||||
const ConnectionsFragment({super.key});
|
||||
|
||||
@override
|
||||
State<ConnectionsFragment> createState() => _ConnectionsFragmentState();
|
||||
}
|
||||
|
||||
class _ConnectionsFragmentState extends State<ConnectionsFragment> {
|
||||
final connectionsNotifier = ValueNotifier<List<Connection>>([]);
|
||||
Map<String, String?> idPackageNameMap = {};
|
||||
|
||||
Timer? timer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
_getConnections();
|
||||
if (timer != null) {
|
||||
timer?.cancel();
|
||||
timer = null;
|
||||
}
|
||||
timer = Timer.periodic(const Duration(seconds: 3), (timer) {
|
||||
if (mounted) {
|
||||
_getConnections();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_getConnections() {
|
||||
connectionsNotifier.value = clashCore
|
||||
.getConnections();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
timer?.cancel();
|
||||
timer = null;
|
||||
}
|
||||
|
||||
Future<ImageProvider?> _getPackageIconWithConnection(
|
||||
Connection connection) async {
|
||||
final uid = connection.metadata.uid;
|
||||
// if(globalState.packageNameMap[uid] == null){
|
||||
// globalState.packageNameMap[uid] = await app?.getPackageName(connection.metadata);
|
||||
// }
|
||||
final packageName = globalState.packageNameMap[uid];
|
||||
if(packageName == null) return null;
|
||||
return await app?.getPackageIcon(packageName);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ValueListenableBuilder<List<Connection>>(
|
||||
valueListenable: connectionsNotifier,
|
||||
builder: (_, List<Connection> connections, __) {
|
||||
if (connections.isEmpty) {
|
||||
return const NullStatus(
|
||||
label: "未开启代理,或者没有连接数据",
|
||||
);
|
||||
}
|
||||
return ListView.separated(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemBuilder: (_, index) {
|
||||
final connection = connections[index];
|
||||
return ListTile(
|
||||
titleAlignment: ListTileTitleAlignment.top,
|
||||
leading: Container(
|
||||
margin: const EdgeInsets.only(top: 4),
|
||||
width: 48,
|
||||
height: 48,
|
||||
child: FutureBuilder<ImageProvider?>(
|
||||
future: _getPackageIconWithConnection(connection),
|
||||
builder: (_, snapshot) {
|
||||
if (!snapshot.hasData && snapshot.data == null) {
|
||||
return Container();
|
||||
} else {
|
||||
return Image(
|
||||
image: snapshot.data!,
|
||||
gaplessPlayback: true,
|
||||
width: 48,
|
||||
height: 48,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(connection.metadata.host.isNotEmpty
|
||||
? connection.metadata.host
|
||||
: connection.metadata.destinationIP),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 12,
|
||||
),
|
||||
child: Wrap(
|
||||
runSpacing: 8,
|
||||
spacing: 8,
|
||||
children: [
|
||||
for (final chain in connection.chains)
|
||||
CommonChip(
|
||||
label: chain,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.block),
|
||||
onPressed: () {},
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 0,
|
||||
);
|
||||
},
|
||||
itemCount: connections.length,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
// import 'dart:async';
|
||||
//
|
||||
// import 'package:fl_clash/clash/core.dart';
|
||||
// import 'package:fl_clash/models/models.dart';
|
||||
// import 'package:fl_clash/plugins/app.dart';
|
||||
// import 'package:fl_clash/state.dart';
|
||||
// import 'package:fl_clash/widgets/widgets.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
//
|
||||
// class ConnectionsFragment extends StatefulWidget {
|
||||
// const ConnectionsFragment({super.key});
|
||||
//
|
||||
// @override
|
||||
// State<ConnectionsFragment> createState() => _ConnectionsFragmentState();
|
||||
// }
|
||||
//
|
||||
// class _ConnectionsFragmentState extends State<ConnectionsFragment> {
|
||||
// final connectionsNotifier = ValueNotifier<List<Connection>>([]);
|
||||
// Map<String, String?> idPackageNameMap = {};
|
||||
//
|
||||
// Timer? timer;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
// _getConnections();
|
||||
// if (timer != null) {
|
||||
// timer?.cancel();
|
||||
// timer = null;
|
||||
// }
|
||||
// timer = Timer.periodic(const Duration(seconds: 3), (timer) {
|
||||
// if (mounted) {
|
||||
// _getConnections();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// _getConnections() {
|
||||
// connectionsNotifier.value = clashCore
|
||||
// .getConnections();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// super.dispose();
|
||||
// timer?.cancel();
|
||||
// timer = null;
|
||||
// }
|
||||
//
|
||||
// Future<ImageProvider?> _getPackageIconWithConnection(
|
||||
// Connection connection) async {
|
||||
// final uid = connection.metadata.uid;
|
||||
// // if(globalState.packageNameMap[uid] == null){
|
||||
// // globalState.packageNameMap[uid] = await app?.getPackageName(connection.metadata);
|
||||
// // }
|
||||
// final packageName = globalState.packageNameMap[uid];
|
||||
// if(packageName == null) return null;
|
||||
// return await app?.getPackageIcon(packageName);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return ValueListenableBuilder<List<Connection>>(
|
||||
// valueListenable: connectionsNotifier,
|
||||
// builder: (_, List<Connection> connections, __) {
|
||||
// if (connections.isEmpty) {
|
||||
// return const NullStatus(
|
||||
// label: "未开启代理,或者没有连接数据",
|
||||
// );
|
||||
// }
|
||||
// return ListView.separated(
|
||||
// physics: const AlwaysScrollableScrollPhysics(),
|
||||
// itemBuilder: (_, index) {
|
||||
// final connection = connections[index];
|
||||
// return ListTile(
|
||||
// titleAlignment: ListTileTitleAlignment.top,
|
||||
// leading: Container(
|
||||
// margin: const EdgeInsets.only(top: 4),
|
||||
// width: 48,
|
||||
// height: 48,
|
||||
// child: FutureBuilder<ImageProvider?>(
|
||||
// future: _getPackageIconWithConnection(connection),
|
||||
// builder: (_, snapshot) {
|
||||
// if (!snapshot.hasData && snapshot.data == null) {
|
||||
// return Container();
|
||||
// } else {
|
||||
// return Image(
|
||||
// image: snapshot.data!,
|
||||
// gaplessPlayback: true,
|
||||
// width: 48,
|
||||
// height: 48,
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// contentPadding:
|
||||
// const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||
// title: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(connection.metadata.host.isNotEmpty
|
||||
// ? connection.metadata.host
|
||||
// : connection.metadata.destinationIP),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(
|
||||
// top: 12,
|
||||
// ),
|
||||
// child: Wrap(
|
||||
// runSpacing: 8,
|
||||
// spacing: 8,
|
||||
// children: [
|
||||
// for (final chain in connection.chains)
|
||||
// CommonChip(
|
||||
// label: chain,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// trailing: IconButton(
|
||||
// icon: const Icon(Icons.block),
|
||||
// onPressed: () {},
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// separatorBuilder: (BuildContext context, int index) {
|
||||
// return const Divider(
|
||||
// height: 0,
|
||||
// );
|
||||
// },
|
||||
// itemCount: connections.length,
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:country_flags/country_flags.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
@@ -13,118 +15,162 @@ class NetworkDetection extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _NetworkDetectionState extends State<NetworkDetection> {
|
||||
Widget _buildDescription(String? currentProxyName, int? delay) {
|
||||
if (currentProxyName == null) {
|
||||
return TooltipText(
|
||||
text: Text(
|
||||
appLocalizations.noProxyDesc,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
final ipInfoNotifier = ValueNotifier<IpInfo?>(null);
|
||||
final timeoutNotifier = ValueNotifier<bool>(false);
|
||||
bool? _preIsStart;
|
||||
CancelToken? cancelToken;
|
||||
|
||||
_checkIp(
|
||||
bool isInit,
|
||||
bool isStart,
|
||||
) async {
|
||||
if (!isInit) return;
|
||||
timeoutNotifier.value = false;
|
||||
if (_preIsStart == false && _preIsStart == isStart) return;
|
||||
if (cancelToken != null) {
|
||||
cancelToken!.cancel();
|
||||
cancelToken = null;
|
||||
}
|
||||
if (delay == 0 || delay == null) {
|
||||
return const AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: CircularProgressIndicator(
|
||||
strokeCap: StrokeCap.round,
|
||||
),
|
||||
);
|
||||
ipInfoNotifier.value = null;
|
||||
final ipInfo = await request.checkIp(cancelToken);
|
||||
if (ipInfo == null) {
|
||||
timeoutNotifier.value = true;
|
||||
return;
|
||||
} else {
|
||||
timeoutNotifier.value = false;
|
||||
}
|
||||
if (delay > 0) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
TooltipText(
|
||||
text: Text(
|
||||
"$delay",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: context.textTheme.titleLarge
|
||||
?.copyWith(
|
||||
color: context.colorScheme.primary,
|
||||
)
|
||||
.toSoftBold(),
|
||||
),
|
||||
),
|
||||
const Flexible(
|
||||
child: SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 0,
|
||||
child: Text(
|
||||
'ms',
|
||||
style: Theme.of(context).textTheme.bodyMedium?.toLight(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return Text(
|
||||
"Timeout",
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Colors.red,
|
||||
),
|
||||
_preIsStart = isStart;
|
||||
ipInfoNotifier.value = ipInfo;
|
||||
}
|
||||
|
||||
_checkIpContainer(Widget child) {
|
||||
return Selector2<AppState, Config, CheckIpSelectorState>(
|
||||
selector: (_, appState, config) {
|
||||
return CheckIpSelectorState(
|
||||
isInit: appState.isInit,
|
||||
selectedMap: appState.selectedMap,
|
||||
isStart: appState.isStart,
|
||||
);
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
_checkIp(state.isInit, state.isStart);
|
||||
return child;
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CommonCard(
|
||||
info: Info(
|
||||
iconData: Icons.network_check,
|
||||
label: appLocalizations.networkDetection,
|
||||
),
|
||||
child: Selector<AppState, NetworkDetectionSelectorState>(
|
||||
selector: (_, appState) {
|
||||
return NetworkDetectionSelectorState(
|
||||
currentProxyName: appState.showProxyName,
|
||||
delay: appState.getDelay(
|
||||
appState.showProxyName,
|
||||
),
|
||||
);
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16).copyWith(top: 0),
|
||||
return _checkIpContainer(
|
||||
ValueListenableBuilder<IpInfo?>(
|
||||
valueListenable: ipInfoNotifier,
|
||||
builder: (_, ipInfo, __) {
|
||||
return CommonCard(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 0,
|
||||
child: TooltipText(
|
||||
text: Text(
|
||||
state.currentProxyName ?? appLocalizations.noProxy,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium
|
||||
?.toSoftBold(),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Flexible(
|
||||
child: Container(
|
||||
height: globalState.appController.measure.titleLargeHeight,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: FadeBox(
|
||||
child: _buildDescription(
|
||||
state.currentProxyName,
|
||||
state.delay,
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.network_check,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FadeBox(
|
||||
child: ipInfo != null
|
||||
? CountryFlag.fromCountryCode(
|
||||
ipInfo.countryCode,
|
||||
width: 24,
|
||||
height: 24,
|
||||
)
|
||||
: ValueListenableBuilder(
|
||||
valueListenable: timeoutNotifier,
|
||||
builder: (_, timeout, __) {
|
||||
if (timeout) {
|
||||
return Text(
|
||||
appLocalizations.checkError,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
}
|
||||
return TooltipText(
|
||||
text: Text(
|
||||
appLocalizations.checking,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height:
|
||||
globalState.appController.measure.titleLargeHeight + 24,
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.all(16).copyWith(top: 0),
|
||||
child: FadeBox(
|
||||
child: ipInfo != null
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: TooltipText(
|
||||
text: Text(
|
||||
ipInfo.ip,
|
||||
style: context.textTheme.titleLarge
|
||||
?.toSoftBold(),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: ValueListenableBuilder(
|
||||
valueListenable: timeoutNotifier,
|
||||
builder: (_, timeout, __) {
|
||||
if (timeout) {
|
||||
return Text(
|
||||
"timeout",
|
||||
style: context.textTheme.titleMedium
|
||||
?.copyWith(color: Colors.red)
|
||||
.toSoftBold(),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
}
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: const AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -19,7 +19,7 @@ class _StartButtonState extends State<StartButton>
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
isStart = context.read<AppState>().runTime != null;
|
||||
isStart = globalState.appController.appState.isStart;
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
value: isStart ? 1 : 0,
|
||||
@@ -48,9 +48,11 @@ class _StartButtonState extends State<StartButton>
|
||||
}
|
||||
}
|
||||
|
||||
updateSystemProxy() async {
|
||||
final appController = globalState.appController;
|
||||
await appController.updateSystemProxy(isStart);
|
||||
updateSystemProxy() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
final appController = globalState.appController;
|
||||
await appController.updateSystemProxy(isStart);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -9,4 +9,5 @@ export 'config.dart';
|
||||
export 'application_setting.dart';
|
||||
export 'about.dart';
|
||||
export 'backup_and_recovery.dart';
|
||||
export 'resources.dart';
|
||||
export 'resources.dart';
|
||||
export 'requests.dart';
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
@@ -22,14 +23,21 @@ class _LogsFragmentState extends State<LogsFragment> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
logsNotifier.value = context.read<AppState>().logs;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final appState = globalState.appController.appState;
|
||||
logsNotifier.value = List<Log>.from(appState.logs);
|
||||
if (timer != null) {
|
||||
timer?.cancel();
|
||||
timer = null;
|
||||
}
|
||||
timer = Timer.periodic(const Duration(milliseconds: 200), (timer) {
|
||||
logsNotifier.value = globalState.appController.appState.logs;
|
||||
final logs = List<Log>.from(appState.logs);
|
||||
if (!const ListEquality<Log>().equals(
|
||||
logsNotifier.value,
|
||||
logs,
|
||||
)) {
|
||||
logsNotifier.value = logs;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -56,6 +64,9 @@ class _LogsFragmentState extends State<LogsFragment> {
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.search),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
];
|
||||
});
|
||||
@@ -139,6 +150,9 @@ class LogsSearchDelegate extends SearchDelegate {
|
||||
},
|
||||
icon: const Icon(Icons.clear),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
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';
|
||||
@@ -40,7 +41,7 @@ class _EditProfileState extends State<EditProfile> {
|
||||
_handleConfirm() {
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
final config = widget.context.read<Config>();
|
||||
final hasUpdate = widget.profile.url != urlController.text;
|
||||
final hasUpdate = urlController.text.isNotEmpty && widget.profile.url != urlController.text;
|
||||
widget.profile.url = urlController.text;
|
||||
widget.profile.label = labelController.text;
|
||||
widget.profile.autoUpdate = autoUpdate;
|
||||
@@ -82,7 +83,7 @@ class _EditProfileState extends State<EditProfile> {
|
||||
},
|
||||
),
|
||||
),
|
||||
if (widget.profile.url != null)...[
|
||||
if (widget.profile.type == ProfileType.url)...[
|
||||
ListItem(
|
||||
title: TextFormField(
|
||||
controller: urlController,
|
||||
@@ -151,6 +152,7 @@ class _EditProfileState extends State<EditProfile> {
|
||||
vertical: 16,
|
||||
),
|
||||
child: ListView.separated(
|
||||
primary: true,
|
||||
itemBuilder: (_, index) {
|
||||
return items[index];
|
||||
},
|
||||
|
||||
@@ -25,15 +25,7 @@ class ProfilesFragment extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ProfilesFragmentState extends State<ProfilesFragment> {
|
||||
_handleDeleteProfile(String id) async {
|
||||
globalState.appController.deleteProfile(id);
|
||||
}
|
||||
|
||||
_handleUpdateProfile(String id) async {
|
||||
context.findAncestorStateOfType<CommonScaffoldState>()?.loadingRun(
|
||||
() => globalState.appController.updateProfile(id),
|
||||
);
|
||||
}
|
||||
final hasPadding = ValueNotifier<bool>(false);
|
||||
|
||||
_handleShowAddExtendPage() {
|
||||
showExtendPage(
|
||||
@@ -45,76 +37,6 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
||||
);
|
||||
}
|
||||
|
||||
_handleShowEditExtendPage(Profile profile) {
|
||||
showExtendPage(
|
||||
context,
|
||||
body: EditProfile(
|
||||
profile: profile.copyWith(),
|
||||
context: context,
|
||||
),
|
||||
title: "${appLocalizations.edit}${appLocalizations.profile}",
|
||||
);
|
||||
}
|
||||
|
||||
_buildGrid({
|
||||
required ProfilesSelectorState state,
|
||||
int crossAxisCount = 1,
|
||||
}) {
|
||||
return SingleChildScrollView(
|
||||
padding: crossAxisCount > 1
|
||||
? const EdgeInsets.symmetric(horizontal: 16)
|
||||
: EdgeInsets.zero,
|
||||
child: Grid.baseGap(
|
||||
crossAxisCount: crossAxisCount,
|
||||
children: [
|
||||
for (final profile in state.profiles)
|
||||
GridItem(
|
||||
child: ProfileItem(
|
||||
profile: profile,
|
||||
commonPopupMenu: CommonPopupMenu<ProfileActions>(
|
||||
items: [
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.edit,
|
||||
label: appLocalizations.edit,
|
||||
iconData: Icons.edit,
|
||||
),
|
||||
if (profile.url != null)
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.update,
|
||||
label: appLocalizations.update,
|
||||
iconData: Icons.sync,
|
||||
),
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.delete,
|
||||
label: appLocalizations.delete,
|
||||
iconData: Icons.delete,
|
||||
),
|
||||
],
|
||||
onSelected: (ProfileActions? action) async {
|
||||
switch (action) {
|
||||
case ProfileActions.edit:
|
||||
_handleShowEditExtendPage(profile);
|
||||
break;
|
||||
case ProfileActions.delete:
|
||||
_handleDeleteProfile(profile.id);
|
||||
break;
|
||||
case ProfileActions.update:
|
||||
_handleUpdateProfile(profile.id);
|
||||
break;
|
||||
case null:
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
groupValue: state.currentProfileId,
|
||||
onChanged: globalState.appController.changeProfile,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_getColumns(ViewMode viewMode) {
|
||||
switch (viewMode) {
|
||||
case ViewMode.mobile:
|
||||
@@ -126,33 +48,104 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FloatLayout(
|
||||
floatingWidget: Container(
|
||||
margin: const EdgeInsets.all(kFloatingActionButtonMargin),
|
||||
child: FloatingActionButton(
|
||||
_initScaffoldState() {
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) {
|
||||
final commonScaffoldState =
|
||||
context.findAncestorStateOfType<CommonScaffoldState>();
|
||||
commonScaffoldState?.actions = [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
commonScaffoldState.loadingRun<void>(
|
||||
() async {
|
||||
await globalState.appController.updateProfiles();
|
||||
},
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.sync),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
];
|
||||
commonScaffoldState?.floatingActionButton = FloatingActionButton(
|
||||
heroTag: null,
|
||||
onPressed: _handleShowAddExtendPage,
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.add,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<AppState, bool>(
|
||||
selector: (_, appState) => appState.currentLabel == 'profiles',
|
||||
builder: (_, isCurrent, child) {
|
||||
if (isCurrent) {
|
||||
_initScaffoldState();
|
||||
}
|
||||
return child!;
|
||||
},
|
||||
child: Selector2<AppState, Config, ProfilesSelectorState>(
|
||||
selector: (_, appState, config) => ProfilesSelectorState(
|
||||
profiles: config.profiles,
|
||||
currentProfileId: config.currentProfileId,
|
||||
viewMode: appState.viewMode),
|
||||
profiles: config.profiles,
|
||||
currentProfileId: config.currentProfileId,
|
||||
viewMode: appState.viewMode,
|
||||
),
|
||||
builder: (context, state, child) {
|
||||
if (state.profiles.isEmpty) {
|
||||
return NullStatus(
|
||||
label: appLocalizations.nullProfileDesc,
|
||||
);
|
||||
}
|
||||
final columns = _getColumns(state.viewMode);
|
||||
final isMobile = state.viewMode == ViewMode.mobile;
|
||||
return Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: _buildGrid(
|
||||
state: state,
|
||||
crossAxisCount: _getColumns(state.viewMode),
|
||||
child: NotificationListener<ScrollNotification>(
|
||||
onNotification: (scrollNotification) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
hasPadding.value =
|
||||
scrollNotification.metrics.maxScrollExtent > 0;
|
||||
});
|
||||
return true;
|
||||
},
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: hasPadding,
|
||||
builder: (_, hasPadding, __) {
|
||||
return SingleChildScrollView(
|
||||
padding: !isMobile
|
||||
? EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 16,
|
||||
bottom: 16 + (hasPadding ? 56 : 0),
|
||||
)
|
||||
: EdgeInsets.only(
|
||||
bottom: 0 + (hasPadding ? 56 : 0),
|
||||
),
|
||||
child: Grid(
|
||||
mainAxisSpacing: isMobile ? 8 : 16,
|
||||
crossAxisSpacing: 16,
|
||||
crossAxisCount: columns,
|
||||
children: [
|
||||
for (final profile in state.profiles)
|
||||
GridItem(
|
||||
child: ProfileItem(
|
||||
profile: profile,
|
||||
groupValue: state.currentProfileId,
|
||||
onChanged:
|
||||
globalState.appController.changeProfile,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -161,92 +154,188 @@ class _ProfilesFragmentState extends State<ProfilesFragment> {
|
||||
}
|
||||
}
|
||||
|
||||
class ProfileItem extends StatelessWidget {
|
||||
class ProfileItem extends StatefulWidget {
|
||||
final Profile profile;
|
||||
final String? groupValue;
|
||||
final CommonPopupMenu commonPopupMenu;
|
||||
final void Function(String? value) onChanged;
|
||||
|
||||
const ProfileItem({
|
||||
super.key,
|
||||
required this.profile,
|
||||
required this.commonPopupMenu,
|
||||
required this.groupValue,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String useShow;
|
||||
String totalShow;
|
||||
double progress;
|
||||
final userInfo = profile.userInfo;
|
||||
if (userInfo == null) {
|
||||
useShow = "Infinite";
|
||||
totalShow = "Infinite";
|
||||
progress = 1;
|
||||
} else {
|
||||
final use = userInfo.upload + userInfo.download;
|
||||
final total = userInfo.total;
|
||||
useShow = TrafficValue(value: use).show;
|
||||
totalShow = TrafficValue(value: total).show;
|
||||
progress = total == 0 ? 0.0 : use / total;
|
||||
}
|
||||
return ListItem.radio(
|
||||
horizontalTitleGap: 16,
|
||||
delegate: RadioDelegate<String?>(
|
||||
value: profile.id,
|
||||
groupValue: groupValue,
|
||||
onChanged: onChanged,
|
||||
State<ProfileItem> createState() => _ProfileItemState();
|
||||
}
|
||||
|
||||
class _ProfileItemState extends State<ProfileItem> {
|
||||
final isUpdating = ValueNotifier<bool>(false);
|
||||
|
||||
_handleDeleteProfile(String id) async {
|
||||
globalState.appController.deleteProfile(id);
|
||||
}
|
||||
|
||||
_handleUpdateProfile(String id) async {
|
||||
isUpdating.value = true;
|
||||
await globalState.safeRun<void>(() async {
|
||||
await globalState.appController.updateProfile(id);
|
||||
});
|
||||
isUpdating.value = false;
|
||||
}
|
||||
|
||||
_handleShowEditExtendPage(
|
||||
Profile profile,
|
||||
) {
|
||||
showExtendPage(
|
||||
context,
|
||||
body: EditProfile(
|
||||
profile: profile.copyWith(),
|
||||
context: context,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
trailing: commonPopupMenu,
|
||||
title: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
title: "${appLocalizations.edit}${appLocalizations.profile}",
|
||||
);
|
||||
}
|
||||
|
||||
_buildTitle(Profile profile) {
|
||||
final textTheme = context.textTheme;
|
||||
final userInfo = profile.userInfo ?? UserInfo();
|
||||
final use = userInfo.upload + userInfo.download;
|
||||
final total = userInfo.total;
|
||||
final useShow = TrafficValue(value: use).show;
|
||||
final totalShow = TrafficValue(value: total).show;
|
||||
final progress = total == 0 ? 0.0 : use / total;
|
||||
final expireShow = userInfo.expire == 0
|
||||
? "长期有效"
|
||||
: DateTime.fromMillisecondsSinceEpoch(userInfo.expire * 1000).show;
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
profile.label ?? profile.id,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
profile.lastUpdateDate?.lastUpdateTimeDesc ?? '',
|
||||
style: Theme.of(context).textTheme.labelMedium?.toLight(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
profile.label ?? profile.id,
|
||||
style: textTheme.titleMedium,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
child: LinearProgressIndicator(
|
||||
minHeight: 6,
|
||||
value: progress,
|
||||
Text(
|
||||
profile.lastUpdateDate?.lastUpdateTimeDesc ?? '',
|
||||
style: textTheme.labelMedium?.toLight(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
"$useShow / $totalShow",
|
||||
style: Theme.of(context).textTheme.labelMedium?.toLight(),
|
||||
),
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
),
|
||||
child: LinearProgressIndicator(
|
||||
minHeight: 6,
|
||||
value: progress,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"$useShow / $totalShow",
|
||||
style: textTheme.labelMedium?.toLight(),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 2,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"到期时间:",
|
||||
style: textTheme.labelMedium?.toLighter(),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text(
|
||||
expireShow,
|
||||
style: textTheme.labelMedium?.toLighter(),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final profile = widget.profile;
|
||||
final groupValue = widget.groupValue;
|
||||
final onChanged = widget.onChanged;
|
||||
return Selector<AppState, ViewMode>(
|
||||
selector: (_, appState) => appState.viewMode,
|
||||
builder: (_, viewMode, child) {
|
||||
if (viewMode == ViewMode.mobile) {
|
||||
return child!;
|
||||
}
|
||||
return CommonCard(
|
||||
child: child!,
|
||||
);
|
||||
},
|
||||
child: ListItem.radio(
|
||||
key: Key(profile.id),
|
||||
horizontalTitleGap: 16,
|
||||
delegate: RadioDelegate<String?>(
|
||||
value: profile.id,
|
||||
groupValue: groupValue,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
trailing: CommonPopupMenu<ProfileActions>(
|
||||
items: [
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.edit,
|
||||
label: appLocalizations.edit,
|
||||
iconData: Icons.edit,
|
||||
),
|
||||
if (profile.type == ProfileType.url)
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.update,
|
||||
label: appLocalizations.update,
|
||||
iconData: Icons.sync,
|
||||
),
|
||||
CommonPopupMenuItem(
|
||||
action: ProfileActions.delete,
|
||||
label: appLocalizations.delete,
|
||||
iconData: Icons.delete,
|
||||
),
|
||||
],
|
||||
onSelected: (ProfileActions? action) async {
|
||||
switch (action) {
|
||||
case ProfileActions.edit:
|
||||
_handleShowEditExtendPage(profile);
|
||||
break;
|
||||
case ProfileActions.delete:
|
||||
_handleDeleteProfile(profile.id);
|
||||
break;
|
||||
case ProfileActions.update:
|
||||
_handleUpdateProfile(profile.id);
|
||||
break;
|
||||
case null:
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
title: _buildTitle(profile),
|
||||
tileTitleAlignment: ListTileTitleAlignment.titleHeight,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/clash/clash.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -50,79 +52,99 @@ class _ProxiesFragmentState extends State<ProxiesFragment>
|
||||
selectedValue: proxiesSortType,
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
)
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
_handleTabControllerChange() {
|
||||
final indexIsChanging = _tabController?.indexIsChanging ?? false;
|
||||
if (indexIsChanging) return;
|
||||
final index = _tabController?.index;
|
||||
if(index == null) return;
|
||||
final appController = globalState.appController;
|
||||
final currentGroups = appController.appState.currentGroups;
|
||||
if (currentGroups.length > index) {
|
||||
appController.config.updateCurrentGroupName(currentGroups[index].name);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DelayTestButtonContainer(
|
||||
child: Selector<AppState, bool>(
|
||||
selector: (_, appState) => appState.currentLabel == 'proxies',
|
||||
builder: (_, isCurrent, child) {
|
||||
if (isCurrent) {
|
||||
_initActions();
|
||||
}
|
||||
return child!;
|
||||
return Selector<AppState, bool>(
|
||||
selector: (_, appState) => appState.currentLabel == 'proxies',
|
||||
builder: (_, isCurrent, child) {
|
||||
if (isCurrent) {
|
||||
_initActions();
|
||||
}
|
||||
return child!;
|
||||
},
|
||||
child: Selector2<AppState, Config, ProxiesSelectorState>(
|
||||
selector: (_, appState, config) {
|
||||
final currentGroups = appState.currentGroups;
|
||||
final groupNames = currentGroups.map((e) => e.name).toList();
|
||||
return ProxiesSelectorState(
|
||||
groupNames: groupNames,
|
||||
currentGroupName: config.currentGroupName,
|
||||
);
|
||||
},
|
||||
child: Selector3<AppState, Config, ClashConfig, ProxiesSelectorState>(
|
||||
selector: (_, appState, config, clashConfig) {
|
||||
final currentGroups = appState.currentGroups;
|
||||
final groupNames = currentGroups.map((e) => e.name).toList();
|
||||
return ProxiesSelectorState(
|
||||
groupNames: groupNames,
|
||||
);
|
||||
},
|
||||
shouldRebuild: (prev, next) {
|
||||
if (prev.groupNames.length != next.groupNames.length) {
|
||||
_tabController?.dispose();
|
||||
_tabController = null;
|
||||
}
|
||||
return prev != next;
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
_tabController ??= TabController(
|
||||
length: state.groupNames.length,
|
||||
vsync: this,
|
||||
);
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TabBar(
|
||||
shouldRebuild: (prev, next) {
|
||||
if (!const ListEquality<String>()
|
||||
.equals(prev.groupNames, next.groupNames)) {
|
||||
_tabController?.removeListener(_handleTabControllerChange);
|
||||
_tabController?.dispose();
|
||||
_tabController = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
final index = state.groupNames.indexWhere(
|
||||
(item) => item == state.currentGroupName,
|
||||
);
|
||||
_tabController ??= TabController(
|
||||
length: state.groupNames.length,
|
||||
initialIndex: index == -1 ? 0 : index,
|
||||
vsync: this,
|
||||
)..addListener(_handleTabControllerChange);
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TabBar(
|
||||
controller: _tabController,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
dividerColor: Colors.transparent,
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
overlayColor: const WidgetStatePropertyAll(Colors.transparent),
|
||||
tabs: [
|
||||
for (final groupName in state.groupNames)
|
||||
Tab(
|
||||
text: groupName,
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
dividerColor: Colors.transparent,
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
overlayColor:
|
||||
const WidgetStatePropertyAll(Colors.transparent),
|
||||
tabs: [
|
||||
children: [
|
||||
for (final groupName in state.groupNames)
|
||||
Tab(
|
||||
text: groupName,
|
||||
KeepContainer(
|
||||
key: ObjectKey(groupName),
|
||||
child: ProxiesTabView(
|
||||
groupName: groupName,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
for (final groupName in state.groupNames)
|
||||
KeepContainer(
|
||||
key: ObjectKey(groupName),
|
||||
child: ProxiesTabView(
|
||||
groupName: groupName,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -196,6 +218,24 @@ class ProxiesTabView extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
_delayTest(List<Proxy> proxies) async {
|
||||
for (final proxy in proxies) {
|
||||
final appController = globalState.appController;
|
||||
final proxyName =
|
||||
appController.appState.getRealProxyName(proxy.name) ?? proxy.name;
|
||||
globalState.appController.setDelay(
|
||||
Delay(
|
||||
name: proxyName,
|
||||
value: 0,
|
||||
),
|
||||
);
|
||||
clashCore.getDelay(proxyName).then((delay) {
|
||||
globalState.appController.setDelay(delay);
|
||||
});
|
||||
}
|
||||
await Future.delayed(httpTimeoutDuration + moreDuration);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector2<AppState, Config, ProxiesTabViewSelectorState>(
|
||||
@@ -213,25 +253,32 @@ class ProxiesTabView extends StatelessWidget {
|
||||
state.group.all,
|
||||
state.proxiesSortType,
|
||||
);
|
||||
return Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: GridView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: _getColumns(state.viewMode),
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisExtent: _getItemHeight(context),
|
||||
return DelayTestButtonContainer(
|
||||
onClick: () async {
|
||||
await _delayTest(
|
||||
state.group.all,
|
||||
);
|
||||
},
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: GridView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: _getColumns(state.viewMode),
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisExtent: _getItemHeight(context),
|
||||
),
|
||||
itemCount: proxies.length,
|
||||
itemBuilder: (_, index) {
|
||||
final proxy = proxies[index];
|
||||
return ProxyCard(
|
||||
key: ValueKey('$groupName.${proxy.name}'),
|
||||
proxy: proxy,
|
||||
groupName: groupName,
|
||||
);
|
||||
},
|
||||
),
|
||||
itemCount: proxies.length,
|
||||
itemBuilder: (_, index) {
|
||||
final proxy = proxies[index];
|
||||
return ProxyCard(
|
||||
key: ValueKey('$groupName.${proxy.name}'),
|
||||
proxy: proxy,
|
||||
groupName: groupName,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -384,10 +431,12 @@ class ProxyCard extends StatelessWidget {
|
||||
|
||||
class DelayTestButtonContainer extends StatefulWidget {
|
||||
final Widget child;
|
||||
final Future Function() onClick;
|
||||
|
||||
const DelayTestButtonContainer({
|
||||
super.key,
|
||||
required this.child,
|
||||
required this.onClick,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -401,12 +450,9 @@ class _DelayTestButtonContainerState extends State<DelayTestButtonContainer>
|
||||
late Animation<double> _scale;
|
||||
|
||||
_healthcheck() async {
|
||||
if (globalState.healthcheckLock) return;
|
||||
_controller.forward();
|
||||
globalState.appController.healthcheck();
|
||||
Future.delayed(httpTimeoutDuration + moreDuration, () {
|
||||
_controller.reverse();
|
||||
});
|
||||
await widget.onClick();
|
||||
_controller.reverse();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -415,7 +461,7 @@ class _DelayTestButtonContainerState extends State<DelayTestButtonContainer>
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(
|
||||
milliseconds: 600,
|
||||
milliseconds: 200,
|
||||
),
|
||||
);
|
||||
_scale = Tween<double>(
|
||||
@@ -427,7 +473,6 @@ class _DelayTestButtonContainerState extends State<DelayTestButtonContainer>
|
||||
curve: const Interval(
|
||||
0,
|
||||
1,
|
||||
curve: Curves.elasticInOut,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -441,6 +486,7 @@ class _DelayTestButtonContainerState extends State<DelayTestButtonContainer>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_controller.reverse();
|
||||
return FloatLayout(
|
||||
floatingWidget: FloatWrapper(
|
||||
child: AnimatedBuilder(
|
||||
|
||||
178
lib/fragments/requests.dart
Normal file
@@ -0,0 +1,178 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/plugins/app.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:fl_clash/widgets/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RequestFragment extends StatefulWidget {
|
||||
const RequestFragment({super.key});
|
||||
|
||||
@override
|
||||
State<RequestFragment> createState() => _RequestFragmentState();
|
||||
}
|
||||
|
||||
class _RequestFragmentState extends State<RequestFragment> {
|
||||
final requestsNotifier = ValueNotifier<List<Connection>>([]);
|
||||
final ScrollController _scrollController = ScrollController(
|
||||
keepScrollOffset: false,
|
||||
);
|
||||
|
||||
Timer? timer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final appState = globalState.appController.appState;
|
||||
requestsNotifier.value = List<Connection>.from(appState.requests);
|
||||
if (timer != null) {
|
||||
timer?.cancel();
|
||||
timer = null;
|
||||
}
|
||||
timer = Timer.periodic(const Duration(milliseconds: 200), (timer) {
|
||||
final requests = List<Connection>.from(appState.requests);
|
||||
if (!const ListEquality<Connection>().equals(
|
||||
requestsNotifier.value,
|
||||
requests,
|
||||
)) {
|
||||
requestsNotifier.value = requests;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
timer?.cancel();
|
||||
_scrollController.dispose();
|
||||
timer = null;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ValueListenableBuilder<List<Connection>>(
|
||||
valueListenable: requestsNotifier,
|
||||
builder: (_, List<Connection> connections, __) {
|
||||
if (connections.isEmpty) {
|
||||
return NullStatus(
|
||||
label: appLocalizations.nullRequestsDesc,
|
||||
);
|
||||
}
|
||||
connections = connections.reversed.toList();
|
||||
return ListView.separated(
|
||||
controller: _scrollController,
|
||||
itemBuilder: (_, index) {
|
||||
final connection = connections[index];
|
||||
return RequestItem(
|
||||
key: Key(connection.id),
|
||||
connection: connection,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 0,
|
||||
);
|
||||
},
|
||||
itemCount: connections.length,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RequestItem extends StatelessWidget {
|
||||
final Connection connection;
|
||||
|
||||
const RequestItem({
|
||||
super.key,
|
||||
required this.connection,
|
||||
});
|
||||
|
||||
Future<ImageProvider?> _getPackageIcon(Connection connection) async {
|
||||
return await app?.getPackageIcon(connection.metadata.process);
|
||||
}
|
||||
|
||||
String _getRequestText(Metadata metadata) {
|
||||
var text = "${metadata.network}:://";
|
||||
final ips = [
|
||||
metadata.host,
|
||||
metadata.destinationIP,
|
||||
].where((ip) => ip.isNotEmpty);
|
||||
text += ips.join("/");
|
||||
text += ":${metadata.destinationPort}";
|
||||
return text;
|
||||
}
|
||||
|
||||
String _getSourceText(Connection connection) {
|
||||
final metadata = connection.metadata;
|
||||
if (metadata.process.isEmpty) {
|
||||
return connection.start.lastUpdateTimeDesc;
|
||||
}
|
||||
return "${metadata.process} · ${connection.start.lastUpdateTimeDesc}";
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
titleAlignment: ListTileTitleAlignment.top,
|
||||
leading: Platform.isAndroid
|
||||
? Container(
|
||||
margin: const EdgeInsets.only(top: 4),
|
||||
width: 48,
|
||||
height: 48,
|
||||
child: FutureBuilder<ImageProvider?>(
|
||||
future: _getPackageIcon(connection),
|
||||
builder: (_, snapshot) {
|
||||
if (!snapshot.hasData && snapshot.data == null) {
|
||||
return Container();
|
||||
} else {
|
||||
return Image(
|
||||
image: snapshot.data!,
|
||||
gaplessPlayback: true,
|
||||
width: 48,
|
||||
height: 48,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
: null,
|
||||
title: Text(
|
||||
_getRequestText(connection.metadata),
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Text(
|
||||
_getSourceText(connection),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Wrap(
|
||||
runSpacing: 8,
|
||||
spacing: 8,
|
||||
children: [
|
||||
for (final chain in connection.chains)
|
||||
CommonChip(
|
||||
label: chain,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -166,6 +166,7 @@ class _ToolboxFragmentState extends State<ToolsFragment> {
|
||||
delegate: OpenDelegate(
|
||||
title: appLocalizations.override,
|
||||
widget: const ConfigFragment(),
|
||||
extendPageWidth: 360,
|
||||
),
|
||||
),
|
||||
ListItem.open(
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
"noMoreInfoDesc": "No more info",
|
||||
"profileParseErrorDesc": "profile parse error",
|
||||
"proxyPort": "ProxyPort",
|
||||
"proxyPortDesc": "Set the clash listening port",
|
||||
"port": "Port",
|
||||
"logLevel": "LogLevel",
|
||||
"show": "Show",
|
||||
@@ -156,5 +157,30 @@
|
||||
"goDownload": "Go to download",
|
||||
"unknown": "Unknown",
|
||||
"geoData": "GeoData",
|
||||
"externalResources": "External resources"
|
||||
"externalResources": "External resources",
|
||||
"checking": "Checking...",
|
||||
"country": "Country",
|
||||
"checkError": "Check error",
|
||||
"ipCheckTimeout": "Ip check timeout",
|
||||
"search": "Search",
|
||||
"allowBypass": "Allow applications to bypass VPN",
|
||||
"allowBypassDesc": "Some apps can bypass VPN when turned on",
|
||||
"externalController": "ExternalController",
|
||||
"externalControllerDesc": "Once enabled, the clash kernel can be controlled on port 9090",
|
||||
"ipv6Desc": "When turned on it will be able to receive ipv6 traffic",
|
||||
"app": "App",
|
||||
"general": "General",
|
||||
"systemProxyDesc": "Attach HTTP proxy to VpnService",
|
||||
"unifiedDelay": "Unified delay",
|
||||
"unifiedDelayDesc": "Remove extra delays such as handshaking",
|
||||
"tcpConcurrent": "Tcp concurrent",
|
||||
"tcpConcurrentDesc": "Enabling it will allow tcp concurrency",
|
||||
"geodataLoader": "Geo Low Memory Mode",
|
||||
"geodataLoaderDesc": "Enabling will use the Geo low memory loader",
|
||||
"requests": "Requests",
|
||||
"requestsDesc": "View recently requested data",
|
||||
"nullRequestsDesc": "No proxy or no request",
|
||||
"findProcessMode": "Find process",
|
||||
"findProcessModeDesc": "There is a risk of flashback after opening",
|
||||
"init": "Init"
|
||||
}
|
||||
@@ -111,6 +111,7 @@
|
||||
"noMoreInfoDesc": "暂无更多信息",
|
||||
"profileParseErrorDesc": "配置文件解析错误",
|
||||
"proxyPort": "代理端口",
|
||||
"proxyPortDesc": "设置clash监听端口",
|
||||
"port": "端口",
|
||||
"logLevel": "日志等级",
|
||||
"show": "显示",
|
||||
@@ -156,5 +157,30 @@
|
||||
"goDownload": "前往下载",
|
||||
"unknown": "未知",
|
||||
"geoData": "地理数据",
|
||||
"externalResources": "外部资源"
|
||||
"externalResources": "外部资源",
|
||||
"checking": "检测中...",
|
||||
"country": "区域",
|
||||
"checkError": "检测失败",
|
||||
"ipCheckTimeout": "Ip检测超时",
|
||||
"search": "搜索",
|
||||
"allowBypass": "允许应用绕过vpn",
|
||||
"allowBypassDesc": "开启后部分应用可绕过VPN",
|
||||
"externalController": "外部控制器",
|
||||
"externalControllerDesc": "开启后将可以通过9090端口控制clash内核",
|
||||
"ipv6Desc": "开启后将可以接收ipv6流量",
|
||||
"app": "应用",
|
||||
"general": "基础",
|
||||
"systemProxyDesc": "为VpnService附加HTTP代理",
|
||||
"unifiedDelay": "统一延迟",
|
||||
"unifiedDelayDesc": "去除握手等额外延迟",
|
||||
"tcpConcurrent": "TCP并发",
|
||||
"tcpConcurrentDesc": "开启后允许tcp并发",
|
||||
"geodataLoader": "Geo低内存模式",
|
||||
"geodataLoaderDesc": "开启将使用Geo低内存加载器",
|
||||
"requests": "请求",
|
||||
"requestsDesc": "查看最近请求数据",
|
||||
"nullRequestsDesc": "未开启代理或者没有请求",
|
||||
"findProcessMode": "查找进程",
|
||||
"findProcessModeDesc": "开启后存在闪退风险",
|
||||
"init": "初始化"
|
||||
}
|
||||
@@ -40,9 +40,14 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"addressTip": MessageLookupByLibrary.simpleMessage(
|
||||
"Please enter a valid WebDAV address"),
|
||||
"ago": MessageLookupByLibrary.simpleMessage(" Ago"),
|
||||
"allowBypass": MessageLookupByLibrary.simpleMessage(
|
||||
"Allow applications to bypass VPN"),
|
||||
"allowBypassDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Some apps can bypass VPN when turned on"),
|
||||
"allowLan": MessageLookupByLibrary.simpleMessage("AllowLan"),
|
||||
"allowLanDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Allow access proxy through the LAN"),
|
||||
"app": MessageLookupByLibrary.simpleMessage("App"),
|
||||
"appAccessControl":
|
||||
MessageLookupByLibrary.simpleMessage("App access control"),
|
||||
"application": MessageLookupByLibrary.simpleMessage("Application"),
|
||||
@@ -76,10 +81,12 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("Cancel filter system app"),
|
||||
"cancelSelectAll":
|
||||
MessageLookupByLibrary.simpleMessage("Cancel select all"),
|
||||
"checkError": MessageLookupByLibrary.simpleMessage("Check error"),
|
||||
"checkUpdate":
|
||||
MessageLookupByLibrary.simpleMessage("Check for updates"),
|
||||
"checkUpdateError": MessageLookupByLibrary.simpleMessage(
|
||||
"The current application is already the latest version"),
|
||||
"checking": MessageLookupByLibrary.simpleMessage("Checking..."),
|
||||
"compatible":
|
||||
MessageLookupByLibrary.simpleMessage("Compatibility mode"),
|
||||
"compatibleDesc": MessageLookupByLibrary.simpleMessage(
|
||||
@@ -88,6 +95,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"connectivity": MessageLookupByLibrary.simpleMessage("Connectivity:"),
|
||||
"core": MessageLookupByLibrary.simpleMessage("Core"),
|
||||
"coreInfo": MessageLookupByLibrary.simpleMessage("Core info"),
|
||||
"country": MessageLookupByLibrary.simpleMessage("Country"),
|
||||
"create": MessageLookupByLibrary.simpleMessage("Create"),
|
||||
"dark": MessageLookupByLibrary.simpleMessage("Dark"),
|
||||
"dashboard": MessageLookupByLibrary.simpleMessage("Dashboard"),
|
||||
@@ -109,6 +117,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"edit": MessageLookupByLibrary.simpleMessage("Edit"),
|
||||
"en": MessageLookupByLibrary.simpleMessage("English"),
|
||||
"exit": MessageLookupByLibrary.simpleMessage("Exit"),
|
||||
"externalController":
|
||||
MessageLookupByLibrary.simpleMessage("ExternalController"),
|
||||
"externalControllerDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Once enabled, the clash kernel can be controlled on port 9090"),
|
||||
"externalResources":
|
||||
MessageLookupByLibrary.simpleMessage("External resources"),
|
||||
"file": MessageLookupByLibrary.simpleMessage("File"),
|
||||
@@ -116,12 +128,25 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("Directly upload profile"),
|
||||
"filterSystemApp":
|
||||
MessageLookupByLibrary.simpleMessage("Filter system app"),
|
||||
"findProcessMode": MessageLookupByLibrary.simpleMessage("Find process"),
|
||||
"findProcessModeDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"There is a risk of flashback after opening"),
|
||||
"general": MessageLookupByLibrary.simpleMessage("General"),
|
||||
"geoData": MessageLookupByLibrary.simpleMessage("GeoData"),
|
||||
"geodataLoader":
|
||||
MessageLookupByLibrary.simpleMessage("Geo Low Memory Mode"),
|
||||
"geodataLoaderDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Enabling will use the Geo low memory loader"),
|
||||
"global": MessageLookupByLibrary.simpleMessage("Global"),
|
||||
"goDownload": MessageLookupByLibrary.simpleMessage("Go to download"),
|
||||
"hours": MessageLookupByLibrary.simpleMessage("Hours"),
|
||||
"importFromURL":
|
||||
MessageLookupByLibrary.simpleMessage("Import from URL"),
|
||||
"init": MessageLookupByLibrary.simpleMessage("Init"),
|
||||
"ipCheckTimeout":
|
||||
MessageLookupByLibrary.simpleMessage("Ip check timeout"),
|
||||
"ipv6Desc": MessageLookupByLibrary.simpleMessage(
|
||||
"When turned on it will be able to receive ipv6 traffic"),
|
||||
"just": MessageLookupByLibrary.simpleMessage("Just"),
|
||||
"language": MessageLookupByLibrary.simpleMessage("Language"),
|
||||
"light": MessageLookupByLibrary.simpleMessage("Light"),
|
||||
@@ -155,6 +180,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"nullLogsDesc": MessageLookupByLibrary.simpleMessage("No logs"),
|
||||
"nullProfileDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"No profile, Please add a profile"),
|
||||
"nullRequestsDesc":
|
||||
MessageLookupByLibrary.simpleMessage("No proxy or no request"),
|
||||
"other": MessageLookupByLibrary.simpleMessage("Other"),
|
||||
"outboundMode": MessageLookupByLibrary.simpleMessage("Outbound mode"),
|
||||
"override": MessageLookupByLibrary.simpleMessage("Override"),
|
||||
@@ -190,6 +217,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"project": MessageLookupByLibrary.simpleMessage("Project"),
|
||||
"proxies": MessageLookupByLibrary.simpleMessage("Proxies"),
|
||||
"proxyPort": MessageLookupByLibrary.simpleMessage("ProxyPort"),
|
||||
"proxyPortDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Set the clash listening port"),
|
||||
"qrcode": MessageLookupByLibrary.simpleMessage("QR code"),
|
||||
"qrcodeDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Scan QR code to obtain profile"),
|
||||
@@ -202,11 +231,15 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("Only recovery profiles"),
|
||||
"recoverySuccess":
|
||||
MessageLookupByLibrary.simpleMessage("Recovery success"),
|
||||
"requests": MessageLookupByLibrary.simpleMessage("Requests"),
|
||||
"requestsDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"View recently requested data"),
|
||||
"resources": MessageLookupByLibrary.simpleMessage("Resources"),
|
||||
"resourcesDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"External resource related info"),
|
||||
"rule": MessageLookupByLibrary.simpleMessage("Rule"),
|
||||
"save": MessageLookupByLibrary.simpleMessage("Save"),
|
||||
"search": MessageLookupByLibrary.simpleMessage("Search"),
|
||||
"selectAll": MessageLookupByLibrary.simpleMessage("Select all"),
|
||||
"selected": MessageLookupByLibrary.simpleMessage("Selected"),
|
||||
"settings": MessageLookupByLibrary.simpleMessage("Settings"),
|
||||
@@ -218,9 +251,14 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"stopVpn": MessageLookupByLibrary.simpleMessage("Stopping VPN..."),
|
||||
"submit": MessageLookupByLibrary.simpleMessage("Submit"),
|
||||
"systemProxy": MessageLookupByLibrary.simpleMessage("SystemProxy"),
|
||||
"systemProxyDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Attach HTTP proxy to VpnService"),
|
||||
"tabAnimation": MessageLookupByLibrary.simpleMessage("Tab animation"),
|
||||
"tabAnimationDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"When enabled, the home tab will add a toggle animation"),
|
||||
"tcpConcurrent": MessageLookupByLibrary.simpleMessage("Tcp concurrent"),
|
||||
"tcpConcurrentDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Enabling it will allow tcp concurrency"),
|
||||
"theme": MessageLookupByLibrary.simpleMessage("Theme"),
|
||||
"themeColor": MessageLookupByLibrary.simpleMessage("Theme color"),
|
||||
"themeDesc": MessageLookupByLibrary.simpleMessage(
|
||||
@@ -235,6 +273,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"unableToUpdateCurrentProfileDesc":
|
||||
MessageLookupByLibrary.simpleMessage(
|
||||
"unable to update current profile"),
|
||||
"unifiedDelay": MessageLookupByLibrary.simpleMessage("Unified delay"),
|
||||
"unifiedDelayDesc": MessageLookupByLibrary.simpleMessage(
|
||||
"Remove extra delays such as handshaking"),
|
||||
"unknown": MessageLookupByLibrary.simpleMessage("Unknown"),
|
||||
"update": MessageLookupByLibrary.simpleMessage("Update"),
|
||||
"upload": MessageLookupByLibrary.simpleMessage("Upload"),
|
||||
|
||||
@@ -36,8 +36,12 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"addressHelp": MessageLookupByLibrary.simpleMessage("WebDAV服务器地址"),
|
||||
"addressTip": MessageLookupByLibrary.simpleMessage("请输入有效的WebDAV地址"),
|
||||
"ago": MessageLookupByLibrary.simpleMessage("前"),
|
||||
"allowBypass": MessageLookupByLibrary.simpleMessage("允许应用绕过vpn"),
|
||||
"allowBypassDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启后部分应用可绕过VPN"),
|
||||
"allowLan": MessageLookupByLibrary.simpleMessage("局域网代理"),
|
||||
"allowLanDesc": MessageLookupByLibrary.simpleMessage("允许通过局域网访问代理"),
|
||||
"app": MessageLookupByLibrary.simpleMessage("应用"),
|
||||
"appAccessControl": MessageLookupByLibrary.simpleMessage("应用访问控制"),
|
||||
"application": MessageLookupByLibrary.simpleMessage("应用程序"),
|
||||
"applicationDesc": MessageLookupByLibrary.simpleMessage("修改应用程序相关设置"),
|
||||
@@ -63,8 +67,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"cancelFilterSystemApp":
|
||||
MessageLookupByLibrary.simpleMessage("取消过滤系统应用"),
|
||||
"cancelSelectAll": MessageLookupByLibrary.simpleMessage("取消全选"),
|
||||
"checkError": MessageLookupByLibrary.simpleMessage("检测失败"),
|
||||
"checkUpdate": MessageLookupByLibrary.simpleMessage("检查更新"),
|
||||
"checkUpdateError": MessageLookupByLibrary.simpleMessage("当前应用已经是最新版了"),
|
||||
"checking": MessageLookupByLibrary.simpleMessage("检测中..."),
|
||||
"compatible": MessageLookupByLibrary.simpleMessage("兼容模式"),
|
||||
"compatibleDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启将失去部分应用能力,获得全量的Clash的支持"),
|
||||
@@ -72,6 +78,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"connectivity": MessageLookupByLibrary.simpleMessage("连通性:"),
|
||||
"core": MessageLookupByLibrary.simpleMessage("内核"),
|
||||
"coreInfo": MessageLookupByLibrary.simpleMessage("内核信息"),
|
||||
"country": MessageLookupByLibrary.simpleMessage("区域"),
|
||||
"create": MessageLookupByLibrary.simpleMessage("创建"),
|
||||
"dark": MessageLookupByLibrary.simpleMessage("深色"),
|
||||
"dashboard": MessageLookupByLibrary.simpleMessage("仪表盘"),
|
||||
@@ -90,15 +97,28 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"edit": MessageLookupByLibrary.simpleMessage("编辑"),
|
||||
"en": MessageLookupByLibrary.simpleMessage("英语"),
|
||||
"exit": MessageLookupByLibrary.simpleMessage("退出"),
|
||||
"externalController": MessageLookupByLibrary.simpleMessage("外部控制器"),
|
||||
"externalControllerDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启后将可以通过9090端口控制clash内核"),
|
||||
"externalResources": MessageLookupByLibrary.simpleMessage("外部资源"),
|
||||
"file": MessageLookupByLibrary.simpleMessage("文件"),
|
||||
"fileDesc": MessageLookupByLibrary.simpleMessage("直接上传配置文件"),
|
||||
"filterSystemApp": MessageLookupByLibrary.simpleMessage("过滤系统应用"),
|
||||
"findProcessMode": MessageLookupByLibrary.simpleMessage("查找进程"),
|
||||
"findProcessModeDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启后存在闪退风险"),
|
||||
"general": MessageLookupByLibrary.simpleMessage("基础"),
|
||||
"geoData": MessageLookupByLibrary.simpleMessage("地理数据"),
|
||||
"geodataLoader": MessageLookupByLibrary.simpleMessage("Geo低内存模式"),
|
||||
"geodataLoaderDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启将使用Geo低内存加载器"),
|
||||
"global": MessageLookupByLibrary.simpleMessage("全局"),
|
||||
"goDownload": MessageLookupByLibrary.simpleMessage("前往下载"),
|
||||
"hours": MessageLookupByLibrary.simpleMessage("小时"),
|
||||
"importFromURL": MessageLookupByLibrary.simpleMessage("从URL导入"),
|
||||
"init": MessageLookupByLibrary.simpleMessage("初始化"),
|
||||
"ipCheckTimeout": MessageLookupByLibrary.simpleMessage("Ip检测超时"),
|
||||
"ipv6Desc": MessageLookupByLibrary.simpleMessage("开启后将可以接收ipv6流量"),
|
||||
"just": MessageLookupByLibrary.simpleMessage("刚刚"),
|
||||
"language": MessageLookupByLibrary.simpleMessage("语言"),
|
||||
"light": MessageLookupByLibrary.simpleMessage("浅色"),
|
||||
@@ -127,6 +147,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"nullLogsDesc": MessageLookupByLibrary.simpleMessage("暂无日志"),
|
||||
"nullProfileDesc":
|
||||
MessageLookupByLibrary.simpleMessage("没有配置文件,请先添加配置文件"),
|
||||
"nullRequestsDesc": MessageLookupByLibrary.simpleMessage("未开启代理或者没有请求"),
|
||||
"other": MessageLookupByLibrary.simpleMessage("其他"),
|
||||
"outboundMode": MessageLookupByLibrary.simpleMessage("出站模式"),
|
||||
"override": MessageLookupByLibrary.simpleMessage("覆写"),
|
||||
@@ -156,6 +177,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"project": MessageLookupByLibrary.simpleMessage("项目"),
|
||||
"proxies": MessageLookupByLibrary.simpleMessage("代理"),
|
||||
"proxyPort": MessageLookupByLibrary.simpleMessage("代理端口"),
|
||||
"proxyPortDesc": MessageLookupByLibrary.simpleMessage("设置clash监听端口"),
|
||||
"qrcode": MessageLookupByLibrary.simpleMessage("二维码"),
|
||||
"qrcodeDesc": MessageLookupByLibrary.simpleMessage("扫描二维码获取配置文件"),
|
||||
"recovery": MessageLookupByLibrary.simpleMessage("恢复"),
|
||||
@@ -163,10 +185,13 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"recoveryDesc": MessageLookupByLibrary.simpleMessage("从WebDAV恢复数据"),
|
||||
"recoveryProfiles": MessageLookupByLibrary.simpleMessage("仅恢复配置文件"),
|
||||
"recoverySuccess": MessageLookupByLibrary.simpleMessage("恢复成功"),
|
||||
"requests": MessageLookupByLibrary.simpleMessage("请求"),
|
||||
"requestsDesc": MessageLookupByLibrary.simpleMessage("查看最近请求数据"),
|
||||
"resources": MessageLookupByLibrary.simpleMessage("资源"),
|
||||
"resourcesDesc": MessageLookupByLibrary.simpleMessage("外部资源相关信息"),
|
||||
"rule": MessageLookupByLibrary.simpleMessage("规则"),
|
||||
"save": MessageLookupByLibrary.simpleMessage("保存"),
|
||||
"search": MessageLookupByLibrary.simpleMessage("搜索"),
|
||||
"selectAll": MessageLookupByLibrary.simpleMessage("全选"),
|
||||
"selected": MessageLookupByLibrary.simpleMessage("已选择"),
|
||||
"settings": MessageLookupByLibrary.simpleMessage("设置"),
|
||||
@@ -177,9 +202,13 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"stopVpn": MessageLookupByLibrary.simpleMessage("正在停止VPN..."),
|
||||
"submit": MessageLookupByLibrary.simpleMessage("提交"),
|
||||
"systemProxy": MessageLookupByLibrary.simpleMessage("系统代理"),
|
||||
"systemProxyDesc":
|
||||
MessageLookupByLibrary.simpleMessage("为VpnService附加HTTP代理"),
|
||||
"tabAnimation": MessageLookupByLibrary.simpleMessage("选项卡动画"),
|
||||
"tabAnimationDesc":
|
||||
MessageLookupByLibrary.simpleMessage("开启后,主页选项卡将添加切换动画"),
|
||||
"tcpConcurrent": MessageLookupByLibrary.simpleMessage("TCP并发"),
|
||||
"tcpConcurrentDesc": MessageLookupByLibrary.simpleMessage("开启后允许tcp并发"),
|
||||
"theme": MessageLookupByLibrary.simpleMessage("主题"),
|
||||
"themeColor": MessageLookupByLibrary.simpleMessage("主题色彩"),
|
||||
"themeDesc": MessageLookupByLibrary.simpleMessage("设置深色模式,调整色彩"),
|
||||
@@ -191,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"tunDesc": MessageLookupByLibrary.simpleMessage("仅在管理员模式生效"),
|
||||
"unableToUpdateCurrentProfileDesc":
|
||||
MessageLookupByLibrary.simpleMessage("无法更新当前配置文件"),
|
||||
"unifiedDelay": MessageLookupByLibrary.simpleMessage("统一延迟"),
|
||||
"unifiedDelayDesc": MessageLookupByLibrary.simpleMessage("去除握手等额外延迟"),
|
||||
"unknown": MessageLookupByLibrary.simpleMessage("未知"),
|
||||
"update": MessageLookupByLibrary.simpleMessage("更新"),
|
||||
"upload": MessageLookupByLibrary.simpleMessage("上传"),
|
||||
|
||||
@@ -1170,6 +1170,16 @@ class AppLocalizations {
|
||||
);
|
||||
}
|
||||
|
||||
/// `Set the clash listening port`
|
||||
String get proxyPortDesc {
|
||||
return Intl.message(
|
||||
'Set the clash listening port',
|
||||
name: 'proxyPortDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Port`
|
||||
String get port {
|
||||
return Intl.message(
|
||||
@@ -1629,6 +1639,256 @@ class AppLocalizations {
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Checking...`
|
||||
String get checking {
|
||||
return Intl.message(
|
||||
'Checking...',
|
||||
name: 'checking',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Country`
|
||||
String get country {
|
||||
return Intl.message(
|
||||
'Country',
|
||||
name: 'country',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Check error`
|
||||
String get checkError {
|
||||
return Intl.message(
|
||||
'Check error',
|
||||
name: 'checkError',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Ip check timeout`
|
||||
String get ipCheckTimeout {
|
||||
return Intl.message(
|
||||
'Ip check timeout',
|
||||
name: 'ipCheckTimeout',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Search`
|
||||
String get search {
|
||||
return Intl.message(
|
||||
'Search',
|
||||
name: 'search',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Allow applications to bypass VPN`
|
||||
String get allowBypass {
|
||||
return Intl.message(
|
||||
'Allow applications to bypass VPN',
|
||||
name: 'allowBypass',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Some apps can bypass VPN when turned on`
|
||||
String get allowBypassDesc {
|
||||
return Intl.message(
|
||||
'Some apps can bypass VPN when turned on',
|
||||
name: 'allowBypassDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `ExternalController`
|
||||
String get externalController {
|
||||
return Intl.message(
|
||||
'ExternalController',
|
||||
name: 'externalController',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Once enabled, the clash kernel can be controlled on port 9090`
|
||||
String get externalControllerDesc {
|
||||
return Intl.message(
|
||||
'Once enabled, the clash kernel can be controlled on port 9090',
|
||||
name: 'externalControllerDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `When turned on it will be able to receive ipv6 traffic`
|
||||
String get ipv6Desc {
|
||||
return Intl.message(
|
||||
'When turned on it will be able to receive ipv6 traffic',
|
||||
name: 'ipv6Desc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `App`
|
||||
String get app {
|
||||
return Intl.message(
|
||||
'App',
|
||||
name: 'app',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `General`
|
||||
String get general {
|
||||
return Intl.message(
|
||||
'General',
|
||||
name: 'general',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Attach HTTP proxy to VpnService`
|
||||
String get systemProxyDesc {
|
||||
return Intl.message(
|
||||
'Attach HTTP proxy to VpnService',
|
||||
name: 'systemProxyDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Unified delay`
|
||||
String get unifiedDelay {
|
||||
return Intl.message(
|
||||
'Unified delay',
|
||||
name: 'unifiedDelay',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Remove extra delays such as handshaking`
|
||||
String get unifiedDelayDesc {
|
||||
return Intl.message(
|
||||
'Remove extra delays such as handshaking',
|
||||
name: 'unifiedDelayDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Tcp concurrent`
|
||||
String get tcpConcurrent {
|
||||
return Intl.message(
|
||||
'Tcp concurrent',
|
||||
name: 'tcpConcurrent',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Enabling it will allow tcp concurrency`
|
||||
String get tcpConcurrentDesc {
|
||||
return Intl.message(
|
||||
'Enabling it will allow tcp concurrency',
|
||||
name: 'tcpConcurrentDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Geo Low Memory Mode`
|
||||
String get geodataLoader {
|
||||
return Intl.message(
|
||||
'Geo Low Memory Mode',
|
||||
name: 'geodataLoader',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Enabling will use the Geo low memory loader`
|
||||
String get geodataLoaderDesc {
|
||||
return Intl.message(
|
||||
'Enabling will use the Geo low memory loader',
|
||||
name: 'geodataLoaderDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Requests`
|
||||
String get requests {
|
||||
return Intl.message(
|
||||
'Requests',
|
||||
name: 'requests',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `View recently requested data`
|
||||
String get requestsDesc {
|
||||
return Intl.message(
|
||||
'View recently requested data',
|
||||
name: 'requestsDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `No proxy or no request`
|
||||
String get nullRequestsDesc {
|
||||
return Intl.message(
|
||||
'No proxy or no request',
|
||||
name: 'nullRequestsDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Find process`
|
||||
String get findProcessMode {
|
||||
return Intl.message(
|
||||
'Find process',
|
||||
name: 'findProcessMode',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `There is a risk of flashback after opening`
|
||||
String get findProcessModeDesc {
|
||||
return Intl.message(
|
||||
'There is a risk of flashback after opening',
|
||||
name: 'findProcessModeDesc',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Init`
|
||||
String get init {
|
||||
return Intl.message(
|
||||
'Init',
|
||||
name: 'init',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppLocalizationDelegate extends LocalizationsDelegate<AppLocalizations> {
|
||||
|
||||
@@ -22,12 +22,11 @@ Future<void> main() async {
|
||||
isCompatible: config.isCompatible,
|
||||
selectedMap: config.currentSelectedMap,
|
||||
);
|
||||
await globalState.init(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
appState.navigationItems = navigation.getItems(
|
||||
openLogs: config.openLogs,
|
||||
hasProxies: false,
|
||||
);
|
||||
globalState.updateNavigationItems(
|
||||
await globalState.init(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
@@ -55,12 +54,19 @@ Future<void> vpnService() async {
|
||||
int.parse(fd),
|
||||
);
|
||||
}));
|
||||
|
||||
await globalState.init(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
|
||||
await globalState.applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
|
||||
final appLocalizations = await AppLocalizations.load(
|
||||
other.getLocaleForString(config.locale) ??
|
||||
WidgetsBinding.instance.platformDispatcher.locale,
|
||||
@@ -80,19 +86,18 @@ Future<void> vpnService() async {
|
||||
];
|
||||
}
|
||||
|
||||
if (appState.isInit) {
|
||||
handleStart();
|
||||
tile?.addListener(
|
||||
TileListenerWithVpn(
|
||||
onStop: () async {
|
||||
await app?.tip(appLocalizations.stopVpn);
|
||||
await globalState.stopSystemProxy();
|
||||
clashCore.shutdown();
|
||||
exit(0);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
handleStart();
|
||||
|
||||
tile?.addListener(
|
||||
TileListenerWithVpn(
|
||||
onStop: () async {
|
||||
await app?.tip(appLocalizations.stopVpn);
|
||||
await globalState.stopSystemProxy();
|
||||
clashCore.shutdown();
|
||||
exit(0);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class ClashMessageListenerWithVpn with ClashMessageListener {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'connection.dart';
|
||||
import 'ffi.dart';
|
||||
import 'log.dart';
|
||||
import 'navigation.dart';
|
||||
@@ -29,6 +32,7 @@ class AppState with ChangeNotifier {
|
||||
bool _isCompatible;
|
||||
List<Group> _groups;
|
||||
double _viewWidth;
|
||||
List<Connection> _requests;
|
||||
|
||||
AppState({
|
||||
required Mode mode,
|
||||
@@ -42,6 +46,7 @@ class AppState with ChangeNotifier {
|
||||
_viewWidth = 0,
|
||||
_selectedMap = selectedMap,
|
||||
_sortNum = 0,
|
||||
_requests = [],
|
||||
_mode = mode,
|
||||
_delayMap = {},
|
||||
_groups = [],
|
||||
@@ -89,6 +94,8 @@ class AppState with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
bool get isStart => _runTime != null;
|
||||
|
||||
int? get runTime => _runTime;
|
||||
|
||||
set runTime(int? value) {
|
||||
@@ -105,7 +112,7 @@ class AppState with ChangeNotifier {
|
||||
} else {
|
||||
final index = groups.indexWhere((element) => element.name == proxyName);
|
||||
if (index == -1) return type;
|
||||
return "$type(${groups[index].now})";
|
||||
return "$type(${groups[index].now ?? '*'})";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,6 +162,24 @@ class AppState with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
List<Connection> get requests => _requests;
|
||||
|
||||
set requests(List<Connection> value) {
|
||||
if (_requests != value) {
|
||||
_requests = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
addRequest(Connection value) {
|
||||
_requests.add(value);
|
||||
final maxLength = Platform.isAndroid ? 1000 : 60;
|
||||
if (_requests.length > maxLength) {
|
||||
_requests = _requests.sublist(_requests.length - maxLength);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
List<Log> get logs => _logs;
|
||||
|
||||
set logs(List<Log> value) {
|
||||
@@ -166,8 +191,10 @@ class AppState with ChangeNotifier {
|
||||
|
||||
addLog(Log log) {
|
||||
_logs.add(log);
|
||||
if(_logs.length > 60){
|
||||
_logs = _logs.sublist(_logs.length - 60);
|
||||
if (!Platform.isAndroid) {
|
||||
if (_logs.length > 60) {
|
||||
_logs = _logs.sublist(_logs.length - 60);
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -108,29 +108,34 @@ class Dns {
|
||||
class ClashConfig extends ChangeNotifier {
|
||||
int _mixedPort;
|
||||
bool _allowLan;
|
||||
Mode _mode;
|
||||
bool _ipv6;
|
||||
String _geodataLoader;
|
||||
LogLevel _logLevel;
|
||||
String _externalController;
|
||||
Mode _mode;
|
||||
FindProcessMode _findProcessMode;
|
||||
bool _unifiedDelay;
|
||||
bool _tcpConcurrent;
|
||||
Tun _tun;
|
||||
Dns _dns;
|
||||
List<String> _rules;
|
||||
|
||||
ClashConfig({
|
||||
int? mixedPort,
|
||||
Mode? mode,
|
||||
bool? allowLan,
|
||||
LogLevel? logLevel,
|
||||
Tun? tun,
|
||||
Dns? dns,
|
||||
List<String>? rules,
|
||||
}) : _mixedPort = mixedPort ?? 7890,
|
||||
_mode = mode ?? Mode.rule,
|
||||
_allowLan = allowLan ?? false,
|
||||
_logLevel = logLevel ?? LogLevel.info,
|
||||
_tun = tun ?? const Tun(),
|
||||
_dns = dns ?? Dns(),
|
||||
_rules = rules ?? [];
|
||||
ClashConfig()
|
||||
: _mixedPort = 7890,
|
||||
_mode = Mode.rule,
|
||||
_ipv6 = false,
|
||||
_findProcessMode = FindProcessMode.off,
|
||||
_allowLan = false,
|
||||
_tcpConcurrent = false,
|
||||
_logLevel = LogLevel.info,
|
||||
_tun = const Tun(),
|
||||
_unifiedDelay = false,
|
||||
_geodataLoader = geodataLoaderMemconservative,
|
||||
_externalController = '',
|
||||
_dns = Dns(),
|
||||
_rules = [];
|
||||
|
||||
@JsonKey(name: "mixed-port")
|
||||
@JsonKey(name: "mixed-port", defaultValue: 7890)
|
||||
int get mixedPort => _mixedPort;
|
||||
|
||||
set mixedPort(int value) {
|
||||
@@ -140,6 +145,7 @@ class ClashConfig extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: Mode.rule)
|
||||
Mode get mode => _mode;
|
||||
|
||||
set mode(Mode value) {
|
||||
@@ -149,6 +155,16 @@ class ClashConfig extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "find-process-mode", defaultValue: FindProcessMode.off)
|
||||
FindProcessMode get findProcessMode => _findProcessMode;
|
||||
|
||||
set findProcessMode(FindProcessMode value) {
|
||||
if (_findProcessMode != value) {
|
||||
_findProcessMode = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "allow-lan")
|
||||
bool get allowLan => _allowLan;
|
||||
|
||||
@@ -159,7 +175,7 @@ class ClashConfig extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "log-level")
|
||||
@JsonKey(name: "log-level", defaultValue: LogLevel.info)
|
||||
LogLevel get logLevel => _logLevel;
|
||||
|
||||
set logLevel(LogLevel value) {
|
||||
@@ -169,6 +185,56 @@ class ClashConfig extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "external-controller", defaultValue: '')
|
||||
String get externalController => _externalController;
|
||||
|
||||
set externalController(String value) {
|
||||
if (_externalController != value) {
|
||||
_externalController = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
bool get ipv6 => _ipv6;
|
||||
|
||||
set ipv6(bool value) {
|
||||
if (_ipv6 != value) {
|
||||
_ipv6 = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "geodata-loader", defaultValue: geodataLoaderMemconservative)
|
||||
String get geodataLoader => _geodataLoader;
|
||||
|
||||
set geodataLoader(String value) {
|
||||
if (_geodataLoader != value) {
|
||||
_geodataLoader = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "unified-delay", defaultValue: false)
|
||||
bool get unifiedDelay => _unifiedDelay;
|
||||
|
||||
set unifiedDelay(bool value) {
|
||||
if (_unifiedDelay != value) {
|
||||
_unifiedDelay = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(name: "tcp-concurrent", defaultValue: false)
|
||||
bool get tcpConcurrent => _tcpConcurrent;
|
||||
|
||||
set tcpConcurrent(bool value) {
|
||||
if (_tcpConcurrent != value) {
|
||||
_tcpConcurrent = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Tun get tun => _tun;
|
||||
|
||||
set tun(Tun value) {
|
||||
@@ -217,17 +283,6 @@ class ClashConfig extends ChangeNotifier {
|
||||
return _$ClashConfigFromJson(json);
|
||||
}
|
||||
|
||||
ClashConfig copyWith({Tun? tun}) {
|
||||
return ClashConfig(
|
||||
mixedPort: mixedPort,
|
||||
mode: mode,
|
||||
logLevel: logLevel,
|
||||
tun: tun ?? this.tun,
|
||||
dns: dns,
|
||||
allowLan: allowLan,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ClashConfig{_mixedPort: $_mixedPort, _allowLan: $_allowLan, _mode: $_mode, _logLevel: $_logLevel, _tun: $_tun, _dns: $_dns, _rules: $_rules}';
|
||||
|
||||
@@ -8,6 +8,7 @@ import '../common/common.dart';
|
||||
import 'models.dart';
|
||||
|
||||
part 'generated/config.g.dart';
|
||||
|
||||
part 'generated/config.freezed.dart';
|
||||
|
||||
@freezed
|
||||
@@ -23,6 +24,17 @@ class AccessControl with _$AccessControl {
|
||||
_$AccessControlFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Props with _$Props {
|
||||
const factory Props({
|
||||
AccessControl? accessControl,
|
||||
bool? allowBypass,
|
||||
bool? systemProxy,
|
||||
}) = _Props;
|
||||
|
||||
factory Props.fromJson(Map<String, Object?> json) => _$PropsFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class Config extends ChangeNotifier {
|
||||
List<Profile> _profiles;
|
||||
@@ -41,6 +53,8 @@ class Config extends ChangeNotifier {
|
||||
AccessControl _accessControl;
|
||||
bool _isAnimateToPage;
|
||||
bool _autoCheckUpdate;
|
||||
bool _allowBypass;
|
||||
bool _systemProxy;
|
||||
DAV? _dav;
|
||||
|
||||
Config()
|
||||
@@ -56,8 +70,10 @@ class Config extends ChangeNotifier {
|
||||
_isMinimizeOnExit = true,
|
||||
_isAccessControl = false,
|
||||
_autoCheckUpdate = true,
|
||||
_systemProxy = true,
|
||||
_accessControl = const AccessControl(),
|
||||
_isAnimateToPage = true;
|
||||
_isAnimateToPage = true,
|
||||
_allowBypass = true;
|
||||
|
||||
deleteProfileById(String id) {
|
||||
_profiles = profiles.where((element) => element.id != id).toList();
|
||||
@@ -134,6 +150,15 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
String? get currentGroupName => currentProfile?.currentGroupName;
|
||||
|
||||
updateCurrentGroupName(String groupName) {
|
||||
if (currentProfile?.currentGroupName != groupName) {
|
||||
currentProfile?.currentGroupName = groupName;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
SelectedMap get currentSelectedMap {
|
||||
return currentProfile?.selectedMap ?? {};
|
||||
}
|
||||
@@ -305,8 +330,34 @@ class Config extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
update(
|
||||
[Config? config, RecoveryOption recoveryOptions = RecoveryOption.all]) {
|
||||
@JsonKey(defaultValue: true)
|
||||
bool get allowBypass {
|
||||
return _allowBypass;
|
||||
}
|
||||
|
||||
set allowBypass(bool value) {
|
||||
if (_allowBypass != value) {
|
||||
_allowBypass = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonKey(defaultValue: true)
|
||||
bool get systemProxy {
|
||||
return _systemProxy;
|
||||
}
|
||||
|
||||
set systemProxy(bool value) {
|
||||
if (_systemProxy != value) {
|
||||
_systemProxy = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
update([
|
||||
Config? config,
|
||||
RecoveryOption recoveryOptions = RecoveryOption.all,
|
||||
]) {
|
||||
if (config != null) {
|
||||
_profiles = config._profiles;
|
||||
for (final profile in config._profiles) {
|
||||
@@ -325,6 +376,7 @@ class Config extends ChangeNotifier {
|
||||
_openLog = config._openLog;
|
||||
_themeMode = config._themeMode;
|
||||
_locale = config._locale;
|
||||
_allowBypass = config._allowBypass;
|
||||
_primaryColor = config._primaryColor;
|
||||
_proxiesSortType = config._proxiesSortType;
|
||||
_isMinimizeOnExit = config._isMinimizeOnExit;
|
||||
|
||||
@@ -14,6 +14,7 @@ class Metadata with _$Metadata {
|
||||
required String destinationIP,
|
||||
required String destinationPort,
|
||||
required String host,
|
||||
required String process,
|
||||
required String remoteDestination,
|
||||
}) = _Metadata;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/clash_config.dart';
|
||||
import 'package:fl_clash/models/connection.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'generated/ffi.g.dart';
|
||||
@@ -66,16 +67,25 @@ class Now with _$Now {
|
||||
@freezed
|
||||
class Process with _$Process {
|
||||
const factory Process({
|
||||
required int uid,
|
||||
required String network,
|
||||
required String source,
|
||||
required String target,
|
||||
required int id,
|
||||
required Metadata metadata,
|
||||
}) = _Process;
|
||||
|
||||
factory Process.fromJson(Map<String, Object?> json) =>
|
||||
_$ProcessFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProcessMapItem with _$ProcessMapItem {
|
||||
const factory ProcessMapItem({
|
||||
required int id,
|
||||
required String value,
|
||||
}) = _ProcessMapItem;
|
||||
|
||||
factory ProcessMapItem.fromJson(Map<String, Object?> json) =>
|
||||
_$ProcessMapItemFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ExternalProvider with _$ExternalProvider {
|
||||
const factory ExternalProvider({
|
||||
|
||||
@@ -35,27 +35,36 @@ Map<String, dynamic> _$DnsToJson(Dns instance) => <String, dynamic>{
|
||||
'fake-ip-filter': instance.fakeIpFilter,
|
||||
};
|
||||
|
||||
ClashConfig _$ClashConfigFromJson(Map<String, dynamic> json) => ClashConfig(
|
||||
mixedPort: (json['mixed-port'] as num?)?.toInt(),
|
||||
mode: $enumDecodeNullable(_$ModeEnumMap, json['mode']),
|
||||
allowLan: json['allow-lan'] as bool?,
|
||||
logLevel: $enumDecodeNullable(_$LogLevelEnumMap, json['log-level']),
|
||||
tun: json['tun'] == null
|
||||
? null
|
||||
: Tun.fromJson(json['tun'] as Map<String, dynamic>),
|
||||
dns: json['dns'] == null
|
||||
? null
|
||||
: Dns.fromJson(json['dns'] as Map<String, dynamic>),
|
||||
rules:
|
||||
(json['rules'] as List<dynamic>?)?.map((e) => e as String).toList(),
|
||||
);
|
||||
ClashConfig _$ClashConfigFromJson(Map<String, dynamic> json) => ClashConfig()
|
||||
..mixedPort = (json['mixed-port'] as num?)?.toInt() ?? 7890
|
||||
..mode = $enumDecodeNullable(_$ModeEnumMap, json['mode']) ?? Mode.rule
|
||||
..findProcessMode = $enumDecodeNullable(
|
||||
_$FindProcessModeEnumMap, json['find-process-mode']) ??
|
||||
FindProcessMode.off
|
||||
..allowLan = json['allow-lan'] as bool
|
||||
..logLevel =
|
||||
$enumDecodeNullable(_$LogLevelEnumMap, json['log-level']) ?? LogLevel.info
|
||||
..externalController = json['external-controller'] as String? ?? ''
|
||||
..ipv6 = json['ipv6'] as bool? ?? false
|
||||
..geodataLoader = json['geodata-loader'] as String? ?? 'memconservative'
|
||||
..unifiedDelay = json['unified-delay'] as bool? ?? false
|
||||
..tcpConcurrent = json['tcp-concurrent'] as bool? ?? false
|
||||
..tun = Tun.fromJson(json['tun'] as Map<String, dynamic>)
|
||||
..dns = Dns.fromJson(json['dns'] as Map<String, dynamic>)
|
||||
..rules = (json['rules'] as List<dynamic>).map((e) => e as String).toList();
|
||||
|
||||
Map<String, dynamic> _$ClashConfigToJson(ClashConfig instance) =>
|
||||
<String, dynamic>{
|
||||
'mixed-port': instance.mixedPort,
|
||||
'mode': _$ModeEnumMap[instance.mode]!,
|
||||
'find-process-mode': _$FindProcessModeEnumMap[instance.findProcessMode]!,
|
||||
'allow-lan': instance.allowLan,
|
||||
'log-level': _$LogLevelEnumMap[instance.logLevel]!,
|
||||
'external-controller': instance.externalController,
|
||||
'ipv6': instance.ipv6,
|
||||
'geodata-loader': instance.geodataLoader,
|
||||
'unified-delay': instance.unifiedDelay,
|
||||
'tcp-concurrent': instance.tcpConcurrent,
|
||||
'tun': instance.tun,
|
||||
'dns': instance.dns,
|
||||
'rules': instance.rules,
|
||||
@@ -67,6 +76,11 @@ const _$ModeEnumMap = {
|
||||
Mode.direct: 'direct',
|
||||
};
|
||||
|
||||
const _$FindProcessModeEnumMap = {
|
||||
FindProcessMode.always: 'always',
|
||||
FindProcessMode.off: 'off',
|
||||
};
|
||||
|
||||
const _$LogLevelEnumMap = {
|
||||
LogLevel.debug: 'debug',
|
||||
LogLevel.info: 'info',
|
||||
|
||||
@@ -239,3 +239,193 @@ abstract class _AccessControl implements AccessControl {
|
||||
_$$AccessControlImplCopyWith<_$AccessControlImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
Props _$PropsFromJson(Map<String, dynamic> json) {
|
||||
return _Props.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Props {
|
||||
AccessControl? get accessControl => throw _privateConstructorUsedError;
|
||||
bool? get allowBypass => throw _privateConstructorUsedError;
|
||||
bool? get systemProxy => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$PropsCopyWith<Props> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PropsCopyWith<$Res> {
|
||||
factory $PropsCopyWith(Props value, $Res Function(Props) then) =
|
||||
_$PropsCopyWithImpl<$Res, Props>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{AccessControl? accessControl, bool? allowBypass, bool? systemProxy});
|
||||
|
||||
$AccessControlCopyWith<$Res>? get accessControl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PropsCopyWithImpl<$Res, $Val extends Props>
|
||||
implements $PropsCopyWith<$Res> {
|
||||
_$PropsCopyWithImpl(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? allowBypass = freezed,
|
||||
Object? systemProxy = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
accessControl: freezed == accessControl
|
||||
? _value.accessControl
|
||||
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||
as AccessControl?,
|
||||
allowBypass: freezed == allowBypass
|
||||
? _value.allowBypass
|
||||
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
systemProxy: freezed == systemProxy
|
||||
? _value.systemProxy
|
||||
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
) 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PropsImplCopyWith<$Res> implements $PropsCopyWith<$Res> {
|
||||
factory _$$PropsImplCopyWith(
|
||||
_$PropsImpl value, $Res Function(_$PropsImpl) then) =
|
||||
__$$PropsImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{AccessControl? accessControl, bool? allowBypass, bool? systemProxy});
|
||||
|
||||
@override
|
||||
$AccessControlCopyWith<$Res>? get accessControl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PropsImplCopyWithImpl<$Res>
|
||||
extends _$PropsCopyWithImpl<$Res, _$PropsImpl>
|
||||
implements _$$PropsImplCopyWith<$Res> {
|
||||
__$$PropsImplCopyWithImpl(
|
||||
_$PropsImpl _value, $Res Function(_$PropsImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? accessControl = freezed,
|
||||
Object? allowBypass = freezed,
|
||||
Object? systemProxy = freezed,
|
||||
}) {
|
||||
return _then(_$PropsImpl(
|
||||
accessControl: freezed == accessControl
|
||||
? _value.accessControl
|
||||
: accessControl // ignore: cast_nullable_to_non_nullable
|
||||
as AccessControl?,
|
||||
allowBypass: freezed == allowBypass
|
||||
? _value.allowBypass
|
||||
: allowBypass // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
systemProxy: freezed == systemProxy
|
||||
? _value.systemProxy
|
||||
: systemProxy // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$PropsImpl implements _Props {
|
||||
const _$PropsImpl({this.accessControl, this.allowBypass, this.systemProxy});
|
||||
|
||||
factory _$PropsImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$PropsImplFromJson(json);
|
||||
|
||||
@override
|
||||
final AccessControl? accessControl;
|
||||
@override
|
||||
final bool? allowBypass;
|
||||
@override
|
||||
final bool? systemProxy;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Props(accessControl: $accessControl, allowBypass: $allowBypass, systemProxy: $systemProxy)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PropsImpl &&
|
||||
(identical(other.accessControl, accessControl) ||
|
||||
other.accessControl == accessControl) &&
|
||||
(identical(other.allowBypass, allowBypass) ||
|
||||
other.allowBypass == allowBypass) &&
|
||||
(identical(other.systemProxy, systemProxy) ||
|
||||
other.systemProxy == systemProxy));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, accessControl, allowBypass, systemProxy);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PropsImplCopyWith<_$PropsImpl> get copyWith =>
|
||||
__$$PropsImplCopyWithImpl<_$PropsImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$PropsImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Props implements Props {
|
||||
const factory _Props(
|
||||
{final AccessControl? accessControl,
|
||||
final bool? allowBypass,
|
||||
final bool? systemProxy}) = _$PropsImpl;
|
||||
|
||||
factory _Props.fromJson(Map<String, dynamic> json) = _$PropsImpl.fromJson;
|
||||
|
||||
@override
|
||||
AccessControl? get accessControl;
|
||||
@override
|
||||
bool? get allowBypass;
|
||||
@override
|
||||
bool? get systemProxy;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$PropsImplCopyWith<_$PropsImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,10 @@ Config _$ConfigFromJson(Map<String, dynamic> json) => Config()
|
||||
? null
|
||||
: DAV.fromJson(json['dav'] as Map<String, dynamic>)
|
||||
..isAnimateToPage = json['isAnimateToPage'] as bool? ?? true
|
||||
..isCompatible = json['isCompatible'] as bool? ?? false
|
||||
..autoCheckUpdate = json['autoCheckUpdate'] as bool? ?? true;
|
||||
..isCompatible = json['isCompatible'] as bool? ?? true
|
||||
..autoCheckUpdate = json['autoCheckUpdate'] as bool? ?? true
|
||||
..allowBypass = json['allowBypass'] as bool? ?? true
|
||||
..systemProxy = json['systemProxy'] as bool? ?? true;
|
||||
|
||||
Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||
'profiles': instance.profiles,
|
||||
@@ -52,6 +54,8 @@ Map<String, dynamic> _$ConfigToJson(Config instance) => <String, dynamic>{
|
||||
'isAnimateToPage': instance.isAnimateToPage,
|
||||
'isCompatible': instance.isCompatible,
|
||||
'autoCheckUpdate': instance.autoCheckUpdate,
|
||||
'allowBypass': instance.allowBypass,
|
||||
'systemProxy': instance.systemProxy,
|
||||
};
|
||||
|
||||
const _$ThemeModeEnumMap = {
|
||||
@@ -93,3 +97,19 @@ const _$AccessControlModeEnumMap = {
|
||||
AccessControlMode.acceptSelected: 'acceptSelected',
|
||||
AccessControlMode.rejectSelected: 'rejectSelected',
|
||||
};
|
||||
|
||||
_$PropsImpl _$$PropsImplFromJson(Map<String, dynamic> json) => _$PropsImpl(
|
||||
accessControl: json['accessControl'] == null
|
||||
? null
|
||||
: AccessControl.fromJson(
|
||||
json['accessControl'] as Map<String, dynamic>),
|
||||
allowBypass: json['allowBypass'] as bool?,
|
||||
systemProxy: json['systemProxy'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$PropsImplToJson(_$PropsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'accessControl': instance.accessControl,
|
||||
'allowBypass': instance.allowBypass,
|
||||
'systemProxy': instance.systemProxy,
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@ mixin _$Metadata {
|
||||
String get destinationIP => throw _privateConstructorUsedError;
|
||||
String get destinationPort => throw _privateConstructorUsedError;
|
||||
String get host => throw _privateConstructorUsedError;
|
||||
String get process => throw _privateConstructorUsedError;
|
||||
String get remoteDestination => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@@ -48,6 +49,7 @@ abstract class $MetadataCopyWith<$Res> {
|
||||
String destinationIP,
|
||||
String destinationPort,
|
||||
String host,
|
||||
String process,
|
||||
String remoteDestination});
|
||||
}
|
||||
|
||||
@@ -71,6 +73,7 @@ class _$MetadataCopyWithImpl<$Res, $Val extends Metadata>
|
||||
Object? destinationIP = null,
|
||||
Object? destinationPort = null,
|
||||
Object? host = null,
|
||||
Object? process = null,
|
||||
Object? remoteDestination = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
@@ -102,6 +105,10 @@ class _$MetadataCopyWithImpl<$Res, $Val extends Metadata>
|
||||
? _value.host
|
||||
: host // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
process: null == process
|
||||
? _value.process
|
||||
: process // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
remoteDestination: null == remoteDestination
|
||||
? _value.remoteDestination
|
||||
: remoteDestination // ignore: cast_nullable_to_non_nullable
|
||||
@@ -126,6 +133,7 @@ abstract class _$$MetadataImplCopyWith<$Res>
|
||||
String destinationIP,
|
||||
String destinationPort,
|
||||
String host,
|
||||
String process,
|
||||
String remoteDestination});
|
||||
}
|
||||
|
||||
@@ -147,6 +155,7 @@ class __$$MetadataImplCopyWithImpl<$Res>
|
||||
Object? destinationIP = null,
|
||||
Object? destinationPort = null,
|
||||
Object? host = null,
|
||||
Object? process = null,
|
||||
Object? remoteDestination = null,
|
||||
}) {
|
||||
return _then(_$MetadataImpl(
|
||||
@@ -178,6 +187,10 @@ class __$$MetadataImplCopyWithImpl<$Res>
|
||||
? _value.host
|
||||
: host // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
process: null == process
|
||||
? _value.process
|
||||
: process // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
remoteDestination: null == remoteDestination
|
||||
? _value.remoteDestination
|
||||
: remoteDestination // ignore: cast_nullable_to_non_nullable
|
||||
@@ -197,6 +210,7 @@ class _$MetadataImpl implements _Metadata {
|
||||
required this.destinationIP,
|
||||
required this.destinationPort,
|
||||
required this.host,
|
||||
required this.process,
|
||||
required this.remoteDestination});
|
||||
|
||||
factory _$MetadataImpl.fromJson(Map<String, dynamic> json) =>
|
||||
@@ -217,11 +231,13 @@ class _$MetadataImpl implements _Metadata {
|
||||
@override
|
||||
final String host;
|
||||
@override
|
||||
final String process;
|
||||
@override
|
||||
final String remoteDestination;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Metadata(uid: $uid, network: $network, sourceIP: $sourceIP, sourcePort: $sourcePort, destinationIP: $destinationIP, destinationPort: $destinationPort, host: $host, remoteDestination: $remoteDestination)';
|
||||
return 'Metadata(uid: $uid, network: $network, sourceIP: $sourceIP, sourcePort: $sourcePort, destinationIP: $destinationIP, destinationPort: $destinationPort, host: $host, process: $process, remoteDestination: $remoteDestination)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -240,14 +256,24 @@ class _$MetadataImpl implements _Metadata {
|
||||
(identical(other.destinationPort, destinationPort) ||
|
||||
other.destinationPort == destinationPort) &&
|
||||
(identical(other.host, host) || other.host == host) &&
|
||||
(identical(other.process, process) || other.process == process) &&
|
||||
(identical(other.remoteDestination, remoteDestination) ||
|
||||
other.remoteDestination == remoteDestination));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, uid, network, sourceIP,
|
||||
sourcePort, destinationIP, destinationPort, host, remoteDestination);
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
uid,
|
||||
network,
|
||||
sourceIP,
|
||||
sourcePort,
|
||||
destinationIP,
|
||||
destinationPort,
|
||||
host,
|
||||
process,
|
||||
remoteDestination);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@@ -272,6 +298,7 @@ abstract class _Metadata implements Metadata {
|
||||
required final String destinationIP,
|
||||
required final String destinationPort,
|
||||
required final String host,
|
||||
required final String process,
|
||||
required final String remoteDestination}) = _$MetadataImpl;
|
||||
|
||||
factory _Metadata.fromJson(Map<String, dynamic> json) =
|
||||
@@ -292,6 +319,8 @@ abstract class _Metadata implements Metadata {
|
||||
@override
|
||||
String get host;
|
||||
@override
|
||||
String get process;
|
||||
@override
|
||||
String get remoteDestination;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
|
||||
@@ -15,6 +15,7 @@ _$MetadataImpl _$$MetadataImplFromJson(Map<String, dynamic> json) =>
|
||||
destinationIP: json['destinationIP'] as String,
|
||||
destinationPort: json['destinationPort'] as String,
|
||||
host: json['host'] as String,
|
||||
process: json['process'] as String,
|
||||
remoteDestination: json['remoteDestination'] as String,
|
||||
);
|
||||
|
||||
@@ -27,6 +28,7 @@ Map<String, dynamic> _$$MetadataImplToJson(_$MetadataImpl instance) =>
|
||||
'destinationIP': instance.destinationIP,
|
||||
'destinationPort': instance.destinationPort,
|
||||
'host': instance.host,
|
||||
'process': instance.process,
|
||||
'remoteDestination': instance.remoteDestination,
|
||||
};
|
||||
|
||||
|
||||
@@ -848,10 +848,8 @@ Process _$ProcessFromJson(Map<String, dynamic> json) {
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Process {
|
||||
int get uid => throw _privateConstructorUsedError;
|
||||
String get network => throw _privateConstructorUsedError;
|
||||
String get source => throw _privateConstructorUsedError;
|
||||
String get target => throw _privateConstructorUsedError;
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
Metadata get metadata => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
@@ -863,7 +861,9 @@ abstract class $ProcessCopyWith<$Res> {
|
||||
factory $ProcessCopyWith(Process value, $Res Function(Process) then) =
|
||||
_$ProcessCopyWithImpl<$Res, Process>;
|
||||
@useResult
|
||||
$Res call({int uid, String network, String source, String target});
|
||||
$Res call({int id, Metadata metadata});
|
||||
|
||||
$MetadataCopyWith<$Res> get metadata;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -879,30 +879,28 @@ class _$ProcessCopyWithImpl<$Res, $Val extends Process>
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? uid = null,
|
||||
Object? network = null,
|
||||
Object? source = null,
|
||||
Object? target = null,
|
||||
Object? id = null,
|
||||
Object? metadata = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
uid: null == uid
|
||||
? _value.uid
|
||||
: uid // ignore: cast_nullable_to_non_nullable
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
network: null == network
|
||||
? _value.network
|
||||
: network // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
source: null == source
|
||||
? _value.source
|
||||
: source // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
target: null == target
|
||||
? _value.target
|
||||
: target // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
metadata: null == metadata
|
||||
? _value.metadata
|
||||
: metadata // ignore: cast_nullable_to_non_nullable
|
||||
as Metadata,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$MetadataCopyWith<$Res> get metadata {
|
||||
return $MetadataCopyWith<$Res>(_value.metadata, (value) {
|
||||
return _then(_value.copyWith(metadata: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -912,7 +910,10 @@ abstract class _$$ProcessImplCopyWith<$Res> implements $ProcessCopyWith<$Res> {
|
||||
__$$ProcessImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({int uid, String network, String source, String target});
|
||||
$Res call({int id, Metadata metadata});
|
||||
|
||||
@override
|
||||
$MetadataCopyWith<$Res> get metadata;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -926,28 +927,18 @@ class __$$ProcessImplCopyWithImpl<$Res>
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? uid = null,
|
||||
Object? network = null,
|
||||
Object? source = null,
|
||||
Object? target = null,
|
||||
Object? id = null,
|
||||
Object? metadata = null,
|
||||
}) {
|
||||
return _then(_$ProcessImpl(
|
||||
uid: null == uid
|
||||
? _value.uid
|
||||
: uid // ignore: cast_nullable_to_non_nullable
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
network: null == network
|
||||
? _value.network
|
||||
: network // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
source: null == source
|
||||
? _value.source
|
||||
: source // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
target: null == target
|
||||
? _value.target
|
||||
: target // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
metadata: null == metadata
|
||||
? _value.metadata
|
||||
: metadata // ignore: cast_nullable_to_non_nullable
|
||||
as Metadata,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -955,27 +946,19 @@ class __$$ProcessImplCopyWithImpl<$Res>
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$ProcessImpl implements _Process {
|
||||
const _$ProcessImpl(
|
||||
{required this.uid,
|
||||
required this.network,
|
||||
required this.source,
|
||||
required this.target});
|
||||
const _$ProcessImpl({required this.id, required this.metadata});
|
||||
|
||||
factory _$ProcessImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$ProcessImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int uid;
|
||||
final int id;
|
||||
@override
|
||||
final String network;
|
||||
@override
|
||||
final String source;
|
||||
@override
|
||||
final String target;
|
||||
final Metadata metadata;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Process(uid: $uid, network: $network, source: $source, target: $target)';
|
||||
return 'Process(id: $id, metadata: $metadata)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -983,15 +966,14 @@ class _$ProcessImpl implements _Process {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ProcessImpl &&
|
||||
(identical(other.uid, uid) || other.uid == uid) &&
|
||||
(identical(other.network, network) || other.network == network) &&
|
||||
(identical(other.source, source) || other.source == source) &&
|
||||
(identical(other.target, target) || other.target == target));
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.metadata, metadata) ||
|
||||
other.metadata == metadata));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, uid, network, source, target);
|
||||
int get hashCode => Object.hash(runtimeType, id, metadata);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@@ -1009,27 +991,176 @@ class _$ProcessImpl implements _Process {
|
||||
|
||||
abstract class _Process implements Process {
|
||||
const factory _Process(
|
||||
{required final int uid,
|
||||
required final String network,
|
||||
required final String source,
|
||||
required final String target}) = _$ProcessImpl;
|
||||
{required final int id,
|
||||
required final Metadata metadata}) = _$ProcessImpl;
|
||||
|
||||
factory _Process.fromJson(Map<String, dynamic> json) = _$ProcessImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get uid;
|
||||
int get id;
|
||||
@override
|
||||
String get network;
|
||||
@override
|
||||
String get source;
|
||||
@override
|
||||
String get target;
|
||||
Metadata get metadata;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$ProcessImplCopyWith<_$ProcessImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
ProcessMapItem _$ProcessMapItemFromJson(Map<String, dynamic> json) {
|
||||
return _ProcessMapItem.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ProcessMapItem {
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
String get value => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$ProcessMapItemCopyWith<ProcessMapItem> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProcessMapItemCopyWith<$Res> {
|
||||
factory $ProcessMapItemCopyWith(
|
||||
ProcessMapItem value, $Res Function(ProcessMapItem) then) =
|
||||
_$ProcessMapItemCopyWithImpl<$Res, ProcessMapItem>;
|
||||
@useResult
|
||||
$Res call({int id, String value});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProcessMapItemCopyWithImpl<$Res, $Val extends ProcessMapItem>
|
||||
implements $ProcessMapItemCopyWith<$Res> {
|
||||
_$ProcessMapItemCopyWithImpl(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? id = null,
|
||||
Object? value = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
value: null == value
|
||||
? _value.value
|
||||
: value // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ProcessMapItemImplCopyWith<$Res>
|
||||
implements $ProcessMapItemCopyWith<$Res> {
|
||||
factory _$$ProcessMapItemImplCopyWith(_$ProcessMapItemImpl value,
|
||||
$Res Function(_$ProcessMapItemImpl) then) =
|
||||
__$$ProcessMapItemImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({int id, String value});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ProcessMapItemImplCopyWithImpl<$Res>
|
||||
extends _$ProcessMapItemCopyWithImpl<$Res, _$ProcessMapItemImpl>
|
||||
implements _$$ProcessMapItemImplCopyWith<$Res> {
|
||||
__$$ProcessMapItemImplCopyWithImpl(
|
||||
_$ProcessMapItemImpl _value, $Res Function(_$ProcessMapItemImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? value = null,
|
||||
}) {
|
||||
return _then(_$ProcessMapItemImpl(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
value: null == value
|
||||
? _value.value
|
||||
: value // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$ProcessMapItemImpl implements _ProcessMapItem {
|
||||
const _$ProcessMapItemImpl({required this.id, required this.value});
|
||||
|
||||
factory _$ProcessMapItemImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$ProcessMapItemImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final String value;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProcessMapItem(id: $id, value: $value)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ProcessMapItemImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.value, value) || other.value == value));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id, value);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ProcessMapItemImplCopyWith<_$ProcessMapItemImpl> get copyWith =>
|
||||
__$$ProcessMapItemImplCopyWithImpl<_$ProcessMapItemImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$ProcessMapItemImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _ProcessMapItem implements ProcessMapItem {
|
||||
const factory _ProcessMapItem(
|
||||
{required final int id,
|
||||
required final String value}) = _$ProcessMapItemImpl;
|
||||
|
||||
factory _ProcessMapItem.fromJson(Map<String, dynamic> json) =
|
||||
_$ProcessMapItemImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get id;
|
||||
@override
|
||||
String get value;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$ProcessMapItemImplCopyWith<_$ProcessMapItemImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
ExternalProvider _$ExternalProviderFromJson(Map<String, dynamic> json) {
|
||||
return _ExternalProvider.fromJson(json);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ const _$MessageTypeEnumMap = {
|
||||
MessageType.delay: 'delay',
|
||||
MessageType.process: 'process',
|
||||
MessageType.now: 'now',
|
||||
MessageType.request: 'request',
|
||||
MessageType.run: 'run',
|
||||
};
|
||||
|
||||
_$DelayImpl _$$DelayImplFromJson(Map<String, dynamic> json) => _$DelayImpl(
|
||||
@@ -81,18 +83,27 @@ Map<String, dynamic> _$$NowImplToJson(_$NowImpl instance) => <String, dynamic>{
|
||||
|
||||
_$ProcessImpl _$$ProcessImplFromJson(Map<String, dynamic> json) =>
|
||||
_$ProcessImpl(
|
||||
uid: (json['uid'] as num).toInt(),
|
||||
network: json['network'] as String,
|
||||
source: json['source'] as String,
|
||||
target: json['target'] as String,
|
||||
id: (json['id'] as num).toInt(),
|
||||
metadata: Metadata.fromJson(json['metadata'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ProcessImplToJson(_$ProcessImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'uid': instance.uid,
|
||||
'network': instance.network,
|
||||
'source': instance.source,
|
||||
'target': instance.target,
|
||||
'id': instance.id,
|
||||
'metadata': instance.metadata,
|
||||
};
|
||||
|
||||
_$ProcessMapItemImpl _$$ProcessMapItemImplFromJson(Map<String, dynamic> json) =>
|
||||
_$ProcessMapItemImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
value: json['value'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ProcessMapItemImplToJson(
|
||||
_$ProcessMapItemImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'value': instance.value,
|
||||
};
|
||||
|
||||
_$ExternalProviderImpl _$$ExternalProviderImplFromJson(
|
||||
|
||||
@@ -24,10 +24,10 @@ Profile _$ProfileFromJson(Map<String, dynamic> json) => Profile(
|
||||
id: json['id'] as String?,
|
||||
label: json['label'] as String?,
|
||||
url: json['url'] as String?,
|
||||
currentGroupName: json['currentGroupName'] as String?,
|
||||
userInfo: json['userInfo'] == null
|
||||
? null
|
||||
: UserInfo.fromJson(json['userInfo'] as Map<String, dynamic>),
|
||||
proxyName: json['proxyName'] as String?,
|
||||
lastUpdateDate: json['lastUpdateDate'] == null
|
||||
? null
|
||||
: DateTime.parse(json['lastUpdateDate'] as String),
|
||||
@@ -43,7 +43,7 @@ Profile _$ProfileFromJson(Map<String, dynamic> json) => Profile(
|
||||
Map<String, dynamic> _$ProfileToJson(Profile instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'label': instance.label,
|
||||
'proxyName': instance.proxyName,
|
||||
'currentGroupName': instance.currentGroupName,
|
||||
'url': instance.url,
|
||||
'lastUpdateDate': instance.lastUpdateDate?.toIso8601String(),
|
||||
'autoUpdateDuration': instance.autoUpdateDuration.inMicroseconds,
|
||||
|
||||
@@ -28,6 +28,8 @@ const _$GroupTypeEnumMap = {
|
||||
GroupType.Selector: 'Selector',
|
||||
GroupType.URLTest: 'URLTest',
|
||||
GroupType.Fallback: 'Fallback',
|
||||
GroupType.LoadBalance: 'LoadBalance',
|
||||
GroupType.Relay: 'Relay',
|
||||
};
|
||||
|
||||
_$ProxyImpl _$$ProxyImplFromJson(Map<String, dynamic> json) => _$ProxyImpl(
|
||||
|
||||
@@ -157,34 +157,30 @@ abstract class _StartButtonSelectorState implements StartButtonSelectorState {
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UpdateCurrentDelaySelectorState {
|
||||
String? get currentProxyName => throw _privateConstructorUsedError;
|
||||
bool get isCurrent => throw _privateConstructorUsedError;
|
||||
int? get delay => throw _privateConstructorUsedError;
|
||||
mixin _$CheckIpSelectorState {
|
||||
bool get isInit => throw _privateConstructorUsedError;
|
||||
bool get isStart => throw _privateConstructorUsedError;
|
||||
Map<String, String> get selectedMap => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$UpdateCurrentDelaySelectorStateCopyWith<UpdateCurrentDelaySelectorState>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
$CheckIpSelectorStateCopyWith<CheckIpSelectorState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $UpdateCurrentDelaySelectorStateCopyWith<$Res> {
|
||||
factory $UpdateCurrentDelaySelectorStateCopyWith(
|
||||
UpdateCurrentDelaySelectorState value,
|
||||
$Res Function(UpdateCurrentDelaySelectorState) then) =
|
||||
_$UpdateCurrentDelaySelectorStateCopyWithImpl<$Res,
|
||||
UpdateCurrentDelaySelectorState>;
|
||||
abstract class $CheckIpSelectorStateCopyWith<$Res> {
|
||||
factory $CheckIpSelectorStateCopyWith(CheckIpSelectorState value,
|
||||
$Res Function(CheckIpSelectorState) then) =
|
||||
_$CheckIpSelectorStateCopyWithImpl<$Res, CheckIpSelectorState>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{String? currentProxyName, bool isCurrent, int? delay, bool isInit});
|
||||
$Res call({bool isInit, bool isStart, Map<String, String> selectedMap});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$UpdateCurrentDelaySelectorStateCopyWithImpl<$Res,
|
||||
$Val extends UpdateCurrentDelaySelectorState>
|
||||
implements $UpdateCurrentDelaySelectorStateCopyWith<$Res> {
|
||||
_$UpdateCurrentDelaySelectorStateCopyWithImpl(this._value, this._then);
|
||||
class _$CheckIpSelectorStateCopyWithImpl<$Res,
|
||||
$Val extends CheckIpSelectorState>
|
||||
implements $CheckIpSelectorStateCopyWith<$Res> {
|
||||
_$CheckIpSelectorStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
@@ -194,154 +190,136 @@ class _$UpdateCurrentDelaySelectorStateCopyWithImpl<$Res,
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? currentProxyName = freezed,
|
||||
Object? isCurrent = null,
|
||||
Object? delay = freezed,
|
||||
Object? isInit = null,
|
||||
Object? isStart = null,
|
||||
Object? selectedMap = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
currentProxyName: freezed == currentProxyName
|
||||
? _value.currentProxyName
|
||||
: currentProxyName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
isCurrent: null == isCurrent
|
||||
? _value.isCurrent
|
||||
: isCurrent // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
delay: freezed == delay
|
||||
? _value.delay
|
||||
: delay // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
isInit: null == isInit
|
||||
? _value.isInit
|
||||
: isInit // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
isStart: null == isStart
|
||||
? _value.isStart
|
||||
: isStart // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
selectedMap: null == selectedMap
|
||||
? _value.selectedMap
|
||||
: selectedMap // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, String>,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$UpdateCurrentDelaySelectorStateImplCopyWith<$Res>
|
||||
implements $UpdateCurrentDelaySelectorStateCopyWith<$Res> {
|
||||
factory _$$UpdateCurrentDelaySelectorStateImplCopyWith(
|
||||
_$UpdateCurrentDelaySelectorStateImpl value,
|
||||
$Res Function(_$UpdateCurrentDelaySelectorStateImpl) then) =
|
||||
__$$UpdateCurrentDelaySelectorStateImplCopyWithImpl<$Res>;
|
||||
abstract class _$$CheckIpSelectorStateImplCopyWith<$Res>
|
||||
implements $CheckIpSelectorStateCopyWith<$Res> {
|
||||
factory _$$CheckIpSelectorStateImplCopyWith(_$CheckIpSelectorStateImpl value,
|
||||
$Res Function(_$CheckIpSelectorStateImpl) then) =
|
||||
__$$CheckIpSelectorStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{String? currentProxyName, bool isCurrent, int? delay, bool isInit});
|
||||
$Res call({bool isInit, bool isStart, Map<String, String> selectedMap});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$UpdateCurrentDelaySelectorStateImplCopyWithImpl<$Res>
|
||||
extends _$UpdateCurrentDelaySelectorStateCopyWithImpl<$Res,
|
||||
_$UpdateCurrentDelaySelectorStateImpl>
|
||||
implements _$$UpdateCurrentDelaySelectorStateImplCopyWith<$Res> {
|
||||
__$$UpdateCurrentDelaySelectorStateImplCopyWithImpl(
|
||||
_$UpdateCurrentDelaySelectorStateImpl _value,
|
||||
$Res Function(_$UpdateCurrentDelaySelectorStateImpl) _then)
|
||||
class __$$CheckIpSelectorStateImplCopyWithImpl<$Res>
|
||||
extends _$CheckIpSelectorStateCopyWithImpl<$Res, _$CheckIpSelectorStateImpl>
|
||||
implements _$$CheckIpSelectorStateImplCopyWith<$Res> {
|
||||
__$$CheckIpSelectorStateImplCopyWithImpl(_$CheckIpSelectorStateImpl _value,
|
||||
$Res Function(_$CheckIpSelectorStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? currentProxyName = freezed,
|
||||
Object? isCurrent = null,
|
||||
Object? delay = freezed,
|
||||
Object? isInit = null,
|
||||
Object? isStart = null,
|
||||
Object? selectedMap = null,
|
||||
}) {
|
||||
return _then(_$UpdateCurrentDelaySelectorStateImpl(
|
||||
currentProxyName: freezed == currentProxyName
|
||||
? _value.currentProxyName
|
||||
: currentProxyName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
isCurrent: null == isCurrent
|
||||
? _value.isCurrent
|
||||
: isCurrent // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
delay: freezed == delay
|
||||
? _value.delay
|
||||
: delay // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
return _then(_$CheckIpSelectorStateImpl(
|
||||
isInit: null == isInit
|
||||
? _value.isInit
|
||||
: isInit // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
isStart: null == isStart
|
||||
? _value.isStart
|
||||
: isStart // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
selectedMap: null == selectedMap
|
||||
? _value._selectedMap
|
||||
: selectedMap // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, String>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$UpdateCurrentDelaySelectorStateImpl
|
||||
implements _UpdateCurrentDelaySelectorState {
|
||||
const _$UpdateCurrentDelaySelectorStateImpl(
|
||||
{required this.currentProxyName,
|
||||
required this.isCurrent,
|
||||
required this.delay,
|
||||
required this.isInit});
|
||||
class _$CheckIpSelectorStateImpl implements _CheckIpSelectorState {
|
||||
const _$CheckIpSelectorStateImpl(
|
||||
{required this.isInit,
|
||||
required this.isStart,
|
||||
required final Map<String, String> selectedMap})
|
||||
: _selectedMap = selectedMap;
|
||||
|
||||
@override
|
||||
final String? currentProxyName;
|
||||
@override
|
||||
final bool isCurrent;
|
||||
@override
|
||||
final int? delay;
|
||||
@override
|
||||
final bool isInit;
|
||||
@override
|
||||
final bool isStart;
|
||||
final Map<String, String> _selectedMap;
|
||||
@override
|
||||
Map<String, String> get selectedMap {
|
||||
if (_selectedMap is EqualUnmodifiableMapView) return _selectedMap;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(_selectedMap);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateCurrentDelaySelectorState(currentProxyName: $currentProxyName, isCurrent: $isCurrent, delay: $delay, isInit: $isInit)';
|
||||
return 'CheckIpSelectorState(isInit: $isInit, isStart: $isStart, selectedMap: $selectedMap)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$UpdateCurrentDelaySelectorStateImpl &&
|
||||
(identical(other.currentProxyName, currentProxyName) ||
|
||||
other.currentProxyName == currentProxyName) &&
|
||||
(identical(other.isCurrent, isCurrent) ||
|
||||
other.isCurrent == isCurrent) &&
|
||||
(identical(other.delay, delay) || other.delay == delay) &&
|
||||
(identical(other.isInit, isInit) || other.isInit == isInit));
|
||||
other is _$CheckIpSelectorStateImpl &&
|
||||
(identical(other.isInit, isInit) || other.isInit == isInit) &&
|
||||
(identical(other.isStart, isStart) || other.isStart == isStart) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._selectedMap, _selectedMap));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, currentProxyName, isCurrent, delay, isInit);
|
||||
int get hashCode => Object.hash(runtimeType, isInit, isStart,
|
||||
const DeepCollectionEquality().hash(_selectedMap));
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$UpdateCurrentDelaySelectorStateImplCopyWith<
|
||||
_$UpdateCurrentDelaySelectorStateImpl>
|
||||
get copyWith => __$$UpdateCurrentDelaySelectorStateImplCopyWithImpl<
|
||||
_$UpdateCurrentDelaySelectorStateImpl>(this, _$identity);
|
||||
_$$CheckIpSelectorStateImplCopyWith<_$CheckIpSelectorStateImpl>
|
||||
get copyWith =>
|
||||
__$$CheckIpSelectorStateImplCopyWithImpl<_$CheckIpSelectorStateImpl>(
|
||||
this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _UpdateCurrentDelaySelectorState
|
||||
implements UpdateCurrentDelaySelectorState {
|
||||
const factory _UpdateCurrentDelaySelectorState(
|
||||
{required final String? currentProxyName,
|
||||
required final bool isCurrent,
|
||||
required final int? delay,
|
||||
required final bool isInit}) = _$UpdateCurrentDelaySelectorStateImpl;
|
||||
abstract class _CheckIpSelectorState implements CheckIpSelectorState {
|
||||
const factory _CheckIpSelectorState(
|
||||
{required final bool isInit,
|
||||
required final bool isStart,
|
||||
required final Map<String, String> selectedMap}) =
|
||||
_$CheckIpSelectorStateImpl;
|
||||
|
||||
@override
|
||||
String? get currentProxyName;
|
||||
@override
|
||||
bool get isCurrent;
|
||||
@override
|
||||
int? get delay;
|
||||
@override
|
||||
bool get isInit;
|
||||
@override
|
||||
bool get isStart;
|
||||
@override
|
||||
Map<String, String> get selectedMap;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$UpdateCurrentDelaySelectorStateImplCopyWith<
|
||||
_$UpdateCurrentDelaySelectorStateImpl>
|
||||
_$$CheckIpSelectorStateImplCopyWith<_$CheckIpSelectorStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
@@ -1605,6 +1583,7 @@ abstract class _ProxiesCardSelectorState implements ProxiesCardSelectorState {
|
||||
/// @nodoc
|
||||
mixin _$ProxiesSelectorState {
|
||||
List<String> get groupNames => throw _privateConstructorUsedError;
|
||||
String? get currentGroupName => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$ProxiesSelectorStateCopyWith<ProxiesSelectorState> get copyWith =>
|
||||
@@ -1617,7 +1596,7 @@ abstract class $ProxiesSelectorStateCopyWith<$Res> {
|
||||
$Res Function(ProxiesSelectorState) then) =
|
||||
_$ProxiesSelectorStateCopyWithImpl<$Res, ProxiesSelectorState>;
|
||||
@useResult
|
||||
$Res call({List<String> groupNames});
|
||||
$Res call({List<String> groupNames, String? currentGroupName});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -1635,12 +1614,17 @@ class _$ProxiesSelectorStateCopyWithImpl<$Res,
|
||||
@override
|
||||
$Res call({
|
||||
Object? groupNames = null,
|
||||
Object? currentGroupName = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
groupNames: null == groupNames
|
||||
? _value.groupNames
|
||||
: groupNames // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
currentGroupName: freezed == currentGroupName
|
||||
? _value.currentGroupName
|
||||
: currentGroupName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
@@ -1653,7 +1637,7 @@ abstract class _$$ProxiesSelectorStateImplCopyWith<$Res>
|
||||
__$$ProxiesSelectorStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({List<String> groupNames});
|
||||
$Res call({List<String> groupNames, String? currentGroupName});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -1668,12 +1652,17 @@ class __$$ProxiesSelectorStateImplCopyWithImpl<$Res>
|
||||
@override
|
||||
$Res call({
|
||||
Object? groupNames = null,
|
||||
Object? currentGroupName = freezed,
|
||||
}) {
|
||||
return _then(_$ProxiesSelectorStateImpl(
|
||||
groupNames: null == groupNames
|
||||
? _value._groupNames
|
||||
: groupNames // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
currentGroupName: freezed == currentGroupName
|
||||
? _value.currentGroupName
|
||||
: currentGroupName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1681,7 +1670,8 @@ class __$$ProxiesSelectorStateImplCopyWithImpl<$Res>
|
||||
/// @nodoc
|
||||
|
||||
class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
|
||||
const _$ProxiesSelectorStateImpl({required final List<String> groupNames})
|
||||
const _$ProxiesSelectorStateImpl(
|
||||
{required final List<String> groupNames, required this.currentGroupName})
|
||||
: _groupNames = groupNames;
|
||||
|
||||
final List<String> _groupNames;
|
||||
@@ -1692,9 +1682,12 @@ class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
|
||||
return EqualUnmodifiableListView(_groupNames);
|
||||
}
|
||||
|
||||
@override
|
||||
final String? currentGroupName;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProxiesSelectorState(groupNames: $groupNames)';
|
||||
return 'ProxiesSelectorState(groupNames: $groupNames, currentGroupName: $currentGroupName)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1703,12 +1696,14 @@ class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ProxiesSelectorStateImpl &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._groupNames, _groupNames));
|
||||
.equals(other._groupNames, _groupNames) &&
|
||||
(identical(other.currentGroupName, currentGroupName) ||
|
||||
other.currentGroupName == currentGroupName));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType, const DeepCollectionEquality().hash(_groupNames));
|
||||
int get hashCode => Object.hash(runtimeType,
|
||||
const DeepCollectionEquality().hash(_groupNames), currentGroupName);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@@ -1721,11 +1716,14 @@ class _$ProxiesSelectorStateImpl implements _ProxiesSelectorState {
|
||||
|
||||
abstract class _ProxiesSelectorState implements ProxiesSelectorState {
|
||||
const factory _ProxiesSelectorState(
|
||||
{required final List<String> groupNames}) = _$ProxiesSelectorStateImpl;
|
||||
{required final List<String> groupNames,
|
||||
required final String? currentGroupName}) = _$ProxiesSelectorStateImpl;
|
||||
|
||||
@override
|
||||
List<String> get groupNames;
|
||||
@override
|
||||
String? get currentGroupName;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$ProxiesSelectorStateImplCopyWith<_$ProxiesSelectorStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
|
||||
@@ -62,4 +62,9 @@ class IpInfo {
|
||||
_ => throw const FormatException("invalid json"),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'IpInfo{ip: $ip, countryCode: $countryCode}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,16 +16,17 @@ class UserInfo {
|
||||
int upload;
|
||||
int download;
|
||||
int total;
|
||||
int? expire;
|
||||
int expire;
|
||||
|
||||
UserInfo({
|
||||
int? upload,
|
||||
int? download,
|
||||
int? total,
|
||||
this.expire,
|
||||
int? expire,
|
||||
}) : upload = upload ?? 0,
|
||||
download = download ?? 0,
|
||||
total = total ?? 0;
|
||||
total = total ?? 0,
|
||||
expire = expire ?? 0;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$UserInfoToJson(this);
|
||||
@@ -37,10 +38,10 @@ class UserInfo {
|
||||
|
||||
factory UserInfo.formHString(String? info) {
|
||||
if (info == null) return UserInfo();
|
||||
var list = info.split(";");
|
||||
final list = info.split(";");
|
||||
Map<String, int?> map = {};
|
||||
for (var i in list) {
|
||||
var keyValue = i.trim().split("=");
|
||||
for (final i in list) {
|
||||
final keyValue = i.trim().split("=");
|
||||
map[keyValue[0]] = int.tryParse(keyValue[1]);
|
||||
}
|
||||
return UserInfo(
|
||||
@@ -61,7 +62,7 @@ class UserInfo {
|
||||
class Profile {
|
||||
String id;
|
||||
String? label;
|
||||
String? proxyName;
|
||||
String? currentGroupName;
|
||||
String? url;
|
||||
DateTime? lastUpdateDate;
|
||||
Duration autoUpdateDuration;
|
||||
@@ -73,8 +74,8 @@ class Profile {
|
||||
String? id,
|
||||
this.label,
|
||||
this.url,
|
||||
this.currentGroupName,
|
||||
this.userInfo,
|
||||
this.proxyName,
|
||||
this.lastUpdateDate,
|
||||
SelectedMap? selectedMap,
|
||||
Duration? autoUpdateDuration,
|
||||
@@ -83,7 +84,8 @@ class Profile {
|
||||
autoUpdateDuration = autoUpdateDuration ?? defaultUpdateDuration,
|
||||
selectedMap = selectedMap ?? {};
|
||||
|
||||
ProfileType get type => url == null ? ProfileType.file : ProfileType.url;
|
||||
ProfileType get type =>
|
||||
url == null || url?.isEmpty == true ? ProfileType.file : ProfileType.url;
|
||||
|
||||
Future<void> checkAndUpdate() async {
|
||||
final isExists = await check();
|
||||
@@ -95,9 +97,6 @@ class Profile {
|
||||
}
|
||||
|
||||
Future<void> update() async {
|
||||
if (url == null) {
|
||||
throw appLocalizations.unableToUpdateCurrentProfileDesc;
|
||||
}
|
||||
final response = await request.getFileResponseForUrl(url!);
|
||||
final disposition = response.headers.value("content-disposition");
|
||||
label ??= other.getFileNameForDisposition(disposition) ?? id;
|
||||
@@ -135,6 +134,7 @@ class Profile {
|
||||
return _$ProfileFromJson(json);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
@@ -142,34 +142,31 @@ class Profile {
|
||||
runtimeType == other.runtimeType &&
|
||||
id == other.id &&
|
||||
label == other.label &&
|
||||
proxyName == other.proxyName &&
|
||||
currentGroupName == other.currentGroupName &&
|
||||
url == other.url &&
|
||||
lastUpdateDate == other.lastUpdateDate &&
|
||||
autoUpdateDuration == other.autoUpdateDuration &&
|
||||
userInfo == other.userInfo &&
|
||||
autoUpdate == other.autoUpdate;
|
||||
autoUpdate == other.autoUpdate &&
|
||||
selectedMap == other.selectedMap;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
id.hashCode ^
|
||||
label.hashCode ^
|
||||
proxyName.hashCode ^
|
||||
currentGroupName.hashCode ^
|
||||
url.hashCode ^
|
||||
lastUpdateDate.hashCode ^
|
||||
autoUpdateDuration.hashCode ^
|
||||
userInfo.hashCode ^
|
||||
autoUpdate.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Profile{id: $id, label: $label, proxyName: $proxyName, url: $url, lastUpdateDate: $lastUpdateDate, autoUpdateDuration: $autoUpdateDuration, userInfo: $userInfo, autoUpdate: $autoUpdate}';
|
||||
}
|
||||
autoUpdate.hashCode ^
|
||||
selectedMap.hashCode;
|
||||
|
||||
Profile copyWith({
|
||||
String? label,
|
||||
String? url,
|
||||
UserInfo? userInfo,
|
||||
String? groupName,
|
||||
String? currentGroupName,
|
||||
String? proxyName,
|
||||
DateTime? lastUpdateDate,
|
||||
Duration? autoUpdateDuration,
|
||||
@@ -180,7 +177,7 @@ class Profile {
|
||||
id: id,
|
||||
label: label ?? this.label,
|
||||
url: url ?? this.url,
|
||||
proxyName: proxyName ?? this.proxyName,
|
||||
currentGroupName: currentGroupName ?? this.currentGroupName,
|
||||
userInfo: userInfo ?? this.userInfo,
|
||||
selectedMap: selectedMap ?? this.selectedMap,
|
||||
lastUpdateDate: lastUpdateDate ?? this.lastUpdateDate,
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'config.dart';
|
||||
import 'navigation.dart';
|
||||
import 'profile.dart';
|
||||
import 'proxy.dart';
|
||||
|
||||
part 'generated/selector.freezed.dart';
|
||||
|
||||
@@ -17,13 +14,12 @@ class StartButtonSelectorState with _$StartButtonSelectorState {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class UpdateCurrentDelaySelectorState with _$UpdateCurrentDelaySelectorState {
|
||||
const factory UpdateCurrentDelaySelectorState({
|
||||
required String? currentProxyName,
|
||||
required bool isCurrent,
|
||||
required int? delay,
|
||||
class CheckIpSelectorState with _$CheckIpSelectorState {
|
||||
const factory CheckIpSelectorState({
|
||||
required bool isInit,
|
||||
}) = _UpdateCurrentDelaySelectorState;
|
||||
required bool isStart,
|
||||
required SelectedMap selectedMap,
|
||||
}) = _CheckIpSelectorState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -53,24 +49,23 @@ class ApplicationSelectorState with _$ApplicationSelectorState {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class TrayContainerSelectorState with _$TrayContainerSelectorState{
|
||||
class TrayContainerSelectorState with _$TrayContainerSelectorState {
|
||||
const factory TrayContainerSelectorState({
|
||||
required Mode mode,
|
||||
required bool autoLaunch,
|
||||
required bool isRun,
|
||||
required String? locale,
|
||||
})=_TrayContainerSelectorState;
|
||||
}) = _TrayContainerSelectorState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class UpdateNavigationsSelector with _$UpdateNavigationsSelector{
|
||||
class UpdateNavigationsSelector with _$UpdateNavigationsSelector {
|
||||
const factory UpdateNavigationsSelector({
|
||||
required bool openLogs,
|
||||
required bool hasProxies,
|
||||
}) = _UpdateNavigationsSelector;
|
||||
}
|
||||
|
||||
|
||||
@freezed
|
||||
class HomeSelectorState with _$HomeSelectorState {
|
||||
const factory HomeSelectorState({
|
||||
@@ -89,21 +84,22 @@ class HomeBodySelectorState with _$HomeBodySelectorState {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProxiesCardSelectorState with _$ProxiesCardSelectorState{
|
||||
class ProxiesCardSelectorState with _$ProxiesCardSelectorState {
|
||||
const factory ProxiesCardSelectorState({
|
||||
required bool isSelected,
|
||||
}) = _ProxiesCardSelectorState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProxiesSelectorState with _$ProxiesSelectorState{
|
||||
class ProxiesSelectorState with _$ProxiesSelectorState {
|
||||
const factory ProxiesSelectorState({
|
||||
required List<String> groupNames,
|
||||
required String? currentGroupName,
|
||||
}) = _ProxiesSelectorState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProxiesTabViewSelectorState with _$ProxiesTabViewSelectorState{
|
||||
class ProxiesTabViewSelectorState with _$ProxiesTabViewSelectorState {
|
||||
const factory ProxiesTabViewSelectorState({
|
||||
required ProxiesSortType proxiesSortType,
|
||||
required num sortNum,
|
||||
@@ -125,4 +121,4 @@ class PackageListSelectorState with _$PackageListSelectorState {
|
||||
required AccessControl accessControl,
|
||||
required bool isAccessControl,
|
||||
}) = _PackageListSelectorState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,9 @@ class _ScanPageState extends State<ScanPage> with WidgetsBindingObserver {
|
||||
case TorchState.unavailable:
|
||||
icon = const Icon(Icons.flash_off);
|
||||
backgroundColor = Colors.transparent;
|
||||
case TorchState.auto:
|
||||
icon = const Icon(Icons.flash_auto);
|
||||
backgroundColor = Colors.orange;
|
||||
}
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
|
||||
import 'package:fl_clash/clash/clash.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -22,6 +23,9 @@ class App {
|
||||
await onExit!();
|
||||
}
|
||||
break;
|
||||
case "gc":
|
||||
clashCore.requestGc();
|
||||
break;
|
||||
default:
|
||||
throw MissingPluginException();
|
||||
}
|
||||
@@ -29,10 +33,6 @@ class App {
|
||||
}
|
||||
}
|
||||
|
||||
setOnExit(Function() onExit) {
|
||||
this.onExit = onExit;
|
||||
}
|
||||
|
||||
factory App() {
|
||||
_instance ??= App._internal();
|
||||
return _instance!;
|
||||
@@ -68,9 +68,9 @@ class App {
|
||||
});
|
||||
}
|
||||
|
||||
Future<String?> getPackageName(Metadata metadata) async {
|
||||
return await methodChannel?.invokeMethod<String>("getPackageName", {
|
||||
"data": json.encode(metadata),
|
||||
Future<String?> resolverProcess(Process process) async {
|
||||
return await methodChannel?.invokeMethod<String>("resolverProcess", {
|
||||
"data": json.encode(process),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,10 @@ class Proxy extends ProxyPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
// updateStartTime() async {
|
||||
// startTime = clashCore.getRunTime();
|
||||
// }
|
||||
|
||||
updateStartTime() async {
|
||||
startTime = await getRunTime();
|
||||
}
|
||||
|
||||
@@ -13,16 +13,13 @@ import 'common/common.dart';
|
||||
|
||||
class GlobalState {
|
||||
Timer? timer;
|
||||
Function? healthcheckLockDebounce;
|
||||
Timer? groupsUpdateTimer;
|
||||
Function? updateCurrentDelayDebounce;
|
||||
PageController? pageController;
|
||||
final navigatorKey = GlobalKey<NavigatorState>();
|
||||
final Map<int, String?> packageNameMap = {};
|
||||
late AppController appController;
|
||||
GlobalKey<CommonScaffoldState> homeScaffoldKey = GlobalKey();
|
||||
List<Function> updateFunctionLists = [];
|
||||
bool healthcheckLock = false;
|
||||
|
||||
startListenUpdate() {
|
||||
if (timer != null && timer!.isActive == true) return;
|
||||
@@ -63,8 +60,14 @@ class GlobalState {
|
||||
required Config config,
|
||||
required ClashConfig clashConfig,
|
||||
}) async {
|
||||
final args =
|
||||
config.isAccessControl ? json.encode(config.accessControl) : null;
|
||||
final args = config.isAccessControl
|
||||
? json.encode(
|
||||
Props(
|
||||
accessControl: config.accessControl,
|
||||
allowBypass: config.allowBypass,
|
||||
),
|
||||
)
|
||||
: null;
|
||||
await proxyManager.startProxy(
|
||||
port: clashConfig.mixedPort,
|
||||
args: args,
|
||||
@@ -107,12 +110,6 @@ class GlobalState {
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
}
|
||||
if (!appState.isInit) return;
|
||||
await applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
updateCoreVersionInfo(appState);
|
||||
}
|
||||
|
||||
@@ -135,19 +132,6 @@ class GlobalState {
|
||||
});
|
||||
}
|
||||
|
||||
updateNavigationItems({
|
||||
required AppState appState,
|
||||
required Config config,
|
||||
required ClashConfig clashConfig,
|
||||
}) {
|
||||
final group = appState.currentGroups;
|
||||
final hasProfile = config.profiles.isNotEmpty;
|
||||
appState.navigationItems = navigation.getItems(
|
||||
openLogs: config.openLogs,
|
||||
hasProxies: group.isNotEmpty && hasProfile,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> updateGroups(AppState appState) async {
|
||||
appState.groups = await clashCore.getProxiesGroups();
|
||||
}
|
||||
@@ -227,44 +211,30 @@ class GlobalState {
|
||||
required String message,
|
||||
SnackBarAction? action,
|
||||
}) {
|
||||
final width = context.width;
|
||||
EdgeInsets margin;
|
||||
if (width < 600) {
|
||||
margin = const EdgeInsets.only(
|
||||
bottom: 96,
|
||||
right: 16,
|
||||
left: 16,
|
||||
);
|
||||
} else {
|
||||
margin = EdgeInsets.only(
|
||||
bottom: 16,
|
||||
left: 16,
|
||||
right: width - 316,
|
||||
);
|
||||
}
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
action: action,
|
||||
content: Text(message),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
duration: const Duration(milliseconds: 1500),
|
||||
margin: margin,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void updateCurrentDelay(
|
||||
String? proxyName,
|
||||
) {
|
||||
updateCurrentDelayDebounce ??= debounce<Function(String?)>((proxyName) {
|
||||
if (proxyName != null) {
|
||||
debugPrint("[delay]=====> $proxyName");
|
||||
clashCore.delay(
|
||||
proxyName,
|
||||
);
|
||||
}
|
||||
});
|
||||
updateCurrentDelayDebounce!([proxyName]);
|
||||
// final width = context.width;
|
||||
// EdgeInsets margin;
|
||||
// if (width < 600) {
|
||||
// margin = const EdgeInsets.only(
|
||||
// bottom: 96,
|
||||
// right: 16,
|
||||
// left: 16,
|
||||
// );
|
||||
// } else {
|
||||
// margin = EdgeInsets.only(
|
||||
// bottom: 16,
|
||||
// left: 16,
|
||||
// right: width - 316,
|
||||
// );
|
||||
// }
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(
|
||||
// action: action,
|
||||
// content: Text(message),
|
||||
// behavior: SnackBarBehavior.floating,
|
||||
// duration: const Duration(milliseconds: 1500),
|
||||
// margin: margin,
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
|
||||
Future<T?> safeRun<T>(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:fl_clash/clash/clash.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
import 'package:fl_clash/plugins/proxy.dart';
|
||||
import 'package:fl_clash/state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fl_clash/plugins/app.dart';
|
||||
@@ -38,16 +39,8 @@ class _ClashMessageContainerState extends State<ClashMessageContainer>
|
||||
|
||||
@override
|
||||
void onDelay(Delay delay) {
|
||||
globalState.healthcheckLock = true;
|
||||
final appController = globalState.appController;
|
||||
appController.setDelay(delay);
|
||||
globalState.healthcheckLockDebounce ??= debounce<Function()>(
|
||||
() async {
|
||||
globalState.healthcheckLock = false;
|
||||
},
|
||||
milliseconds: 5000,
|
||||
);
|
||||
globalState.healthcheckLockDebounce!();
|
||||
super.onDelay(delay);
|
||||
}
|
||||
|
||||
@@ -64,9 +57,26 @@ class _ClashMessageContainerState extends State<ClashMessageContainer>
|
||||
}
|
||||
|
||||
@override
|
||||
void onProcess(Metadata metadata) async {
|
||||
var packageName = await app?.getPackageName(metadata);
|
||||
globalState.packageNameMap[metadata.uid] = packageName;
|
||||
super.onProcess(metadata);
|
||||
void onProcess(Process process) async {
|
||||
var packageName = await app?.resolverProcess(process);
|
||||
clashCore.setProcessMap(
|
||||
ProcessMapItem(
|
||||
id: process.id,
|
||||
value: packageName ?? "",
|
||||
),
|
||||
);
|
||||
super.onProcess(process);
|
||||
}
|
||||
|
||||
@override
|
||||
void onRequest(Connection connection) async {
|
||||
globalState.appController.appState.addRequest(connection);
|
||||
super.onRequest(connection);
|
||||
}
|
||||
|
||||
@override
|
||||
void onRun(String runTime) async {
|
||||
// proxy?.updateStartTime();
|
||||
super.onRun(runTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
final Widget title;
|
||||
final Widget? subtitle;
|
||||
final EdgeInsets padding;
|
||||
final ListTileTitleAlignment tileTitleAlignment;
|
||||
final bool? prue;
|
||||
final Widget? trailing;
|
||||
final Delegate delegate;
|
||||
@@ -87,6 +88,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.onTab,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : delegate = const Delegate();
|
||||
|
||||
const ListItem.open({
|
||||
@@ -99,6 +101,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
required OpenDelegate this.delegate,
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : onTab = null;
|
||||
|
||||
const ListItem.next({
|
||||
@@ -111,6 +114,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
required NextDelegate this.delegate,
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : onTab = null;
|
||||
|
||||
const ListItem.checkbox({
|
||||
@@ -122,6 +126,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
required CheckboxDelegate this.delegate,
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : trailing = null,
|
||||
onTab = null;
|
||||
|
||||
@@ -134,6 +139,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
required SwitchDelegate this.delegate,
|
||||
this.horizontalTitleGap,
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : trailing = null,
|
||||
onTab = null;
|
||||
|
||||
@@ -146,6 +152,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
required RadioDelegate<T> this.delegate,
|
||||
this.horizontalTitleGap = 8,
|
||||
this.prue,
|
||||
this.tileTitleAlignment = ListTileTitleAlignment.center,
|
||||
}) : leading = null,
|
||||
onTab = null;
|
||||
|
||||
@@ -193,6 +200,7 @@ class ListItem<T> extends StatelessWidget {
|
||||
horizontalTitleGap: horizontalTitleGap,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
titleAlignment: tileTitleAlignment,
|
||||
onTap: onTab,
|
||||
trailing: trailing ?? this.trailing,
|
||||
contentPadding: padding,
|
||||
|
||||
@@ -49,6 +49,7 @@ class CommonScaffold extends StatefulWidget {
|
||||
|
||||
class CommonScaffoldState extends State<CommonScaffold> {
|
||||
final ValueNotifier<List<Widget>> _actions = ValueNotifier([]);
|
||||
final ValueNotifier<Widget?> _floatingActionButton = ValueNotifier(null);
|
||||
|
||||
final ValueNotifier<bool> _loading = ValueNotifier(false);
|
||||
|
||||
@@ -58,11 +59,16 @@ class CommonScaffoldState extends State<CommonScaffold> {
|
||||
}
|
||||
}
|
||||
|
||||
set floatingActionButton(Widget? actions) {
|
||||
if (_floatingActionButton.value != actions) {
|
||||
_floatingActionButton.value = actions;
|
||||
}
|
||||
}
|
||||
|
||||
Future<T?> loadingRun<T>(
|
||||
Future<T> Function() futureFunction, {
|
||||
String? title,
|
||||
}) async {
|
||||
if (_loading.value == true) return null;
|
||||
_loading.value = true;
|
||||
try {
|
||||
final res = await futureFunction();
|
||||
@@ -85,6 +91,7 @@ class CommonScaffoldState extends State<CommonScaffold> {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.title != widget.title) {
|
||||
_actions.value = [];
|
||||
_floatingActionButton.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +116,13 @@ class CommonScaffoldState extends State<CommonScaffold> {
|
||||
Widget build(BuildContext context) {
|
||||
return _platformContainer(
|
||||
child: Scaffold(
|
||||
floatingActionButton: ValueListenableBuilder(
|
||||
valueListenable: _floatingActionButton,
|
||||
builder: (_, floatingActionButton, __) {
|
||||
return floatingActionButton ?? Container();
|
||||
},
|
||||
),
|
||||
resizeToAvoidBottomInset: true,
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(kToolbarHeight),
|
||||
child: Stack(
|
||||
|
||||
160
pubspec.lock
@@ -37,10 +37,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: archive
|
||||
sha256: ecf4273855368121b1caed0d10d4513c7241dfc813f7d3c8933b36622ae9b265
|
||||
sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.5.1"
|
||||
version: "3.6.1"
|
||||
args:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -85,10 +85,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build_daemon
|
||||
sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1"
|
||||
sha256: "79b2aef6ac2ed00046867ed354c88778c9c0f029df8a20fe10b5436826721ef9"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.0.1"
|
||||
version: "4.0.2"
|
||||
build_resolvers:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -101,18 +101,18 @@ packages:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: build_runner
|
||||
sha256: "3ac61a79bfb6f6cc11f693591063a7f19a7af628dc52f141743edac5c16e8c22"
|
||||
sha256: "644dc98a0f179b872f612d3eb627924b578897c629788e858157fa5e704ca0c7"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.4.9"
|
||||
version: "2.4.11"
|
||||
build_runner_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build_runner_core
|
||||
sha256: "4ae8ffe5ac758da294ecf1802f2aff01558d8b1b00616aa7538ea9a8a5d50799"
|
||||
sha256: e3c79f69a64bdfcd8a776a3c28db4eb6e3fb5356d013ae5eb2e52007706d5dbe
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "7.3.0"
|
||||
version: "7.3.1"
|
||||
built_collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -193,6 +193,14 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
country_flags:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: country_flags
|
||||
sha256: dbc4f76e7c801619b2d841023e0327191ba00663f1f1b4770394e9bc6632c444
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
cross_file:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -269,10 +277,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: file_picker
|
||||
sha256: "29c90806ac5f5fb896547720b73b17ee9aed9bba540dc5d91fe29f8c5745b10a"
|
||||
sha256: "2ca051989f69d1b2ca012b2cf3ccf78c70d40144f0861ff2c063493f7c8c3d45"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "8.0.3"
|
||||
version: "8.0.5"
|
||||
file_selector_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -335,10 +343,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_plugin_android_lifecycle
|
||||
sha256: "592dc01a18961a51c24ae5d963b724b2b7fa4a95c100fe8eb6ca8a5a4732cadf"
|
||||
sha256: c6b0b4c05c458e1c01ad9bcc14041dd7b1f6783d487be4386f793f47a8a4d03e
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.0.18"
|
||||
version: "2.0.20"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@@ -353,10 +361,10 @@ packages:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: freezed
|
||||
sha256: "91bce569d4805ea5bad6619a3e8690df8ad062a235165af4c0c5d928dda15eaf"
|
||||
sha256: a434911f643466d78462625df76fd9eb13e57348ff43fe1f77bbe909522c67a1
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.5.1"
|
||||
version: "2.5.2"
|
||||
freezed_annotation:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -425,10 +433,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: image
|
||||
sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e"
|
||||
sha256: "2237616a36c0d69aef7549ab439b833fb7f9fb9fc861af2cc9ac3eedddd69ca8"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.1.7"
|
||||
version: "4.2.0"
|
||||
image_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -441,26 +449,26 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_android
|
||||
sha256: "79455f6cff4cbef583b2b524bbf0d4ec424e5959f4d464e36ef5323715b98370"
|
||||
sha256: "4161e1f843d8480d2e9025ee22411778c3c9eb7e40076dcf2da23d8242b7b51c"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.8.12"
|
||||
version: "0.8.12+3"
|
||||
image_picker_for_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_for_web
|
||||
sha256: "6a1704fdd75022272e7e7a897a9068e9c2ff3cd6a66820bf3ded810633eac954"
|
||||
sha256: "5d6eb13048cd47b60dbf1a5495424dea226c5faf3950e20bf8120a58efb5b5f3"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
version: "3.0.4"
|
||||
image_picker_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_ios
|
||||
sha256: cb0db0ec0d3e2cd49674f2e6053be25ccdb959832607c1cbd215dd6cf10fb0dd
|
||||
sha256: "6703696ad49f5c3c8356d576d7ace84d1faf459afb07accbb0fae780753ff447"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.8.11"
|
||||
version: "0.8.12"
|
||||
image_picker_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -509,6 +517,22 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
jovial_misc:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: jovial_misc
|
||||
sha256: f6e64f789ee311025bb367be9c9afe9759f76dd8209070b7f38e735b5f529eb1
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.8.5"
|
||||
jovial_svg:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: jovial_svg
|
||||
sha256: "000cafe183bdeba28f76d65bf93fc9b636d6f7eaa7e2a33e80c4345a28866ea8"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.21"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -625,10 +649,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: mobile_scanner
|
||||
sha256: f34c83198d9381f6c100dfaec647c275630840cbcda5d6c5eb6ba264beb96be4
|
||||
sha256: b8c0e9afcfd52534f85ec666f3d52156f560b5e6c25b1e3d4fe2087763607926
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "5.0.1"
|
||||
version: "5.1.1"
|
||||
nested:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -681,18 +705,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
sha256: "51f0d2c554cfbc9d6a312ab35152fc77e2f0b758ce9f1a444a3a1e5b8f3c6b7f"
|
||||
sha256: "9c96da072b421e98183f9ea7464898428e764bc0ce5567f27ec8693442e72514"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.2.3"
|
||||
version: "2.2.5"
|
||||
path_provider_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_foundation
|
||||
sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f"
|
||||
sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.3.2"
|
||||
version: "2.4.0"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -729,10 +753,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
|
||||
sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.1.4"
|
||||
version: "3.1.5"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -741,6 +765,14 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.8"
|
||||
pointycastle:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pointycastle
|
||||
sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.9.1"
|
||||
pool:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -776,10 +808,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pubspec_parse
|
||||
sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367
|
||||
sha256: c799b721d79eb6ee6fa56f00c04b472dcd44a30d258fac2174a6ec57302678f8
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.2.3"
|
||||
version: "1.3.0"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -808,18 +840,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_android
|
||||
sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06"
|
||||
sha256: "93d0ec9dd902d85f326068e6a899487d1f65ffcd5798721a95330b26c8131577"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
version: "2.2.3"
|
||||
shared_preferences_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_foundation
|
||||
sha256: "7708d83064f38060c7b39db12aefe449cb8cdc031d6062280087bc4cdb988f5c"
|
||||
sha256: "0a8a893bf4fd1152f93fec03a415d11c27c74454d96e2318a7ac38dd18683ab7"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.3.5"
|
||||
version: "2.4.0"
|
||||
shared_preferences_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -864,10 +896,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_web_socket
|
||||
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
|
||||
sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
version: "2.0.0"
|
||||
shortid:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -965,10 +997,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: tray_manager
|
||||
sha256: e0ac9a88b2700f366b8629b97e8663b6ef450a2f169560a685dc167bfe9c9c29
|
||||
sha256: c9a63fd88bd3546287a7eb8ccc978d707eef82c775397af17dda3a4f4c039e64
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.2.2"
|
||||
version: "0.2.3"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -981,26 +1013,26 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: url_launcher
|
||||
sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e"
|
||||
sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "6.2.6"
|
||||
version: "6.3.0"
|
||||
url_launcher_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_android
|
||||
sha256: d4ed0711849dd8e33eb2dd69c25db0d0d3fdc37e0a62e629fe32f57a22db2745
|
||||
sha256: ceb2625f0c24ade6ef6778d1de0b2e44f2db71fded235eb52295247feba8c5cf
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "6.3.0"
|
||||
version: "6.3.3"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_ios
|
||||
sha256: "9149d493b075ed740901f3ee844a38a00b33116c7c5c10d7fb27df8987fb51d5"
|
||||
sha256: "7068716403343f6ba4969b4173cbf3b84fc768042124bc2c011e5d782b24fe89"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "6.2.5"
|
||||
version: "6.3.0"
|
||||
url_launcher_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1013,10 +1045,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_macos
|
||||
sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234
|
||||
sha256: "9a1a42d5d2d95400c795b2914c36fdcb525870c752569438e4ebb09a2b5d90de"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
version: "3.2.0"
|
||||
url_launcher_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1029,10 +1061,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_web
|
||||
sha256: "3692a459204a33e04bc94f5fb91158faf4f2c8903281ddd82915adecdb1a901d"
|
||||
sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
version: "2.3.1"
|
||||
url_launcher_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1073,14 +1105,22 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.5.1"
|
||||
web_socket:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web_socket
|
||||
sha256: "24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.5"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web_socket_channel
|
||||
sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42"
|
||||
sha256: a2d56211ee4d35d9b344d9d4ce60f362e4f5d1aafb988302906bd732bc731276
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.4.5"
|
||||
version: "3.0.0"
|
||||
webdav_client:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -1093,26 +1133,26 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb"
|
||||
sha256: a79dbe579cb51ecd6d30b17e0cae4e0ea15e2c0e66f69ad4198f22a6789e94f4
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "5.5.0"
|
||||
version: "5.5.1"
|
||||
win32_registry:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: win32_registry
|
||||
sha256: "41fd8a189940d8696b1b810efb9abcf60827b6cbfab90b0c43e8439e3a39d85a"
|
||||
sha256: "10589e0d7f4e053f2c61023a31c9ce01146656a70b7b7f0828c0b46d7da2a9bb"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.2"
|
||||
version: "1.1.3"
|
||||
window_manager:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: window_manager
|
||||
sha256: b3c895bdf936c77b83c5254bec2e6b3f066710c1f89c38b20b8acc382b525494
|
||||
sha256: "8699323b30da4cdbe2aa2e7c9de567a6abd8a97d9a5c850a3c86dcd0b34bbfbf"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.3.8"
|
||||
version: "0.3.9"
|
||||
windows_single_instance:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -1162,5 +1202,5 @@ packages:
|
||||
source: hosted
|
||||
version: "0.2.3"
|
||||
sdks:
|
||||
dart: ">=3.3.0 <4.0.0"
|
||||
flutter: ">=3.19.0"
|
||||
dart: ">=3.4.0 <4.0.0"
|
||||
flutter: ">=3.22.0"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: fl_clash
|
||||
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
|
||||
publish_to: 'none'
|
||||
version: 0.8.11
|
||||
version: 0.8.24
|
||||
environment:
|
||||
sdk: '>=3.1.0 <4.0.0'
|
||||
|
||||
@@ -17,14 +17,14 @@ dependencies:
|
||||
provider: ^6.0.5
|
||||
window_manager: ^0.3.8
|
||||
ffi: ^2.1.0
|
||||
dynamic_color: ^1.7.0
|
||||
dynamic_color: ^1.6.0
|
||||
proxy:
|
||||
path: plugins/proxy
|
||||
launch_at_startup: ^0.2.2
|
||||
windows_single_instance: ^1.0.1
|
||||
json_annotation: ^4.9.0
|
||||
file_picker: ^8.0.3
|
||||
mobile_scanner: 5.0.1
|
||||
mobile_scanner: ^5.1.1
|
||||
app_links: ^3.5.0
|
||||
win32_registry: ^1.1.2
|
||||
tray_manager: ^0.2.1
|
||||
@@ -38,6 +38,7 @@ dependencies:
|
||||
image: ^4.1.7
|
||||
webdav_client: ^1.2.2
|
||||
dio: ^5.4.3+1
|
||||
country_flags: ^2.2.0
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
17
setup.dart
@@ -12,10 +12,7 @@ enum PlatformType {
|
||||
macos,
|
||||
}
|
||||
|
||||
enum Arch {
|
||||
amd64,
|
||||
arm64,
|
||||
}
|
||||
enum Arch { amd64, arm64, arm }
|
||||
|
||||
class BuildLibItem {
|
||||
PlatformType platform;
|
||||
@@ -64,6 +61,11 @@ class Build {
|
||||
arch: Arch.amd64,
|
||||
archName: 'amd64',
|
||||
),
|
||||
BuildLibItem(
|
||||
platform: PlatformType.android,
|
||||
arch: Arch.arm,
|
||||
archName: 'armeabi-v7a',
|
||||
),
|
||||
BuildLibItem(
|
||||
platform: PlatformType.android,
|
||||
arch: Arch.arm64,
|
||||
@@ -334,7 +336,7 @@ class BuildCommand extends Command {
|
||||
final archName = argResults?['arch'];
|
||||
final currentArches =
|
||||
arches.where((element) => element.name == archName).toList();
|
||||
final arch = currentArches.isEmpty ? null : arches.first;
|
||||
final arch = currentArches.isEmpty ? null : currentArches.first;
|
||||
await _buildLib(arch);
|
||||
if (build != "all") {
|
||||
return;
|
||||
@@ -357,10 +359,11 @@ class BuildCommand extends Command {
|
||||
break;
|
||||
case PlatformType.android:
|
||||
final targetMap = {
|
||||
Arch.arm: "android-arm",
|
||||
Arch.arm64: "android-arm64",
|
||||
Arch.amd64: "android-x64",
|
||||
Arch.arm64: "android-arm64"
|
||||
};
|
||||
final defaultArches = [Arch.amd64, Arch.arm64];
|
||||
final defaultArches = [Arch.arm, Arch.arm64, Arch.amd64];
|
||||
final defaultTargets = defaultArches
|
||||
.where((element) => arch == null ? true : element == arch)
|
||||
.map((e) => targetMap[e])
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// ignore_for_file: avoid_print
|
||||
|
||||
void main() async {
|
||||
String input = """
|
||||
您
|
||||
|
||||