build: vendor pinned flutter_vless Android runtime (#10)
Replace build-time pub-cache mutation with a repository-owned pinned runtime so reviewed native source is the source compiled into the app.
This commit was merged in pull request #10.
This commit is contained in:
1 parent
e818d54b0e
commit
5f851f3485
29 files changed
+2742
-1147
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import java.util.Properties
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
|
||||
plugins {
|
||||
@@ -7,128 +6,6 @@ plugins {
|
||||
id("dev.flutter.flutter-gradle-plugin")
|
||||
}
|
||||
|
||||
val projectRootDir = rootProject.projectDir.parentFile
|
||||
val localPropertiesFile = rootProject.file("local.properties")
|
||||
val localProperties = Properties().apply {
|
||||
if (localPropertiesFile.exists()) {
|
||||
localPropertiesFile.inputStream().use { load(it) }
|
||||
}
|
||||
}
|
||||
val flutterSdkPath = localProperties.getProperty("flutter.sdk")
|
||||
?: throw GradleException("flutter.sdk not set in android/local.properties")
|
||||
val dartExecutable = File(
|
||||
flutterSdkPath,
|
||||
if (System.getProperty("os.name").lowercase().contains("windows")) {
|
||||
"bin/cache/dart-sdk/bin/dart.exe"
|
||||
} else {
|
||||
"bin/cache/dart-sdk/bin/dart"
|
||||
},
|
||||
)
|
||||
val flutterVlessRecoveryPatchScript = File(
|
||||
projectRootDir,
|
||||
"tool/patch_flutter_vless_runtime_recovery.dart",
|
||||
)
|
||||
val flutterVlessSecureSocksPatchScript = File(
|
||||
projectRootDir,
|
||||
"tool/patch_flutter_vless_secure_socks_v2.dart",
|
||||
)
|
||||
val flutterVlessSecureSocksScopeFixScript = File(
|
||||
projectRootDir,
|
||||
"tool/patch_flutter_vless_secure_socks_scope_fix.dart",
|
||||
)
|
||||
|
||||
val patchFlutterVlessRuntimeRecovery = tasks.register<Exec>("patchFlutterVlessRuntimeRecovery") {
|
||||
group = "build setup"
|
||||
description = "Recover stale Xray core and tun2socks socket before restart"
|
||||
workingDir(projectRootDir)
|
||||
|
||||
doFirst {
|
||||
if (!dartExecutable.isFile) {
|
||||
throw GradleException("Flutter Dart executable not found: ${dartExecutable.absolutePath}")
|
||||
}
|
||||
if (!flutterVlessRecoveryPatchScript.isFile) {
|
||||
throw GradleException("flutter_vless recovery patch script missing: ${flutterVlessRecoveryPatchScript.absolutePath}")
|
||||
}
|
||||
if (!File(projectRootDir, ".dart_tool/package_config.json").isFile) {
|
||||
throw GradleException("Flutter package metadata missing. Run `flutter pub get` before Android compilation.")
|
||||
}
|
||||
}
|
||||
|
||||
commandLine(
|
||||
dartExecutable.absolutePath,
|
||||
"run",
|
||||
flutterVlessRecoveryPatchScript.absolutePath,
|
||||
)
|
||||
}
|
||||
|
||||
val patchFlutterVlessSecureSocks = tasks.register<Exec>("patchFlutterVlessSecureSocks") {
|
||||
group = "build setup"
|
||||
description = "Add authenticated ephemeral SOCKS5 and fail-closed process recovery to pinned flutter_vless_android 1.1.5"
|
||||
workingDir(projectRootDir)
|
||||
dependsOn(patchFlutterVlessRuntimeRecovery)
|
||||
|
||||
doFirst {
|
||||
if (!dartExecutable.isFile) {
|
||||
throw GradleException("Flutter Dart executable not found: ${dartExecutable.absolutePath}")
|
||||
}
|
||||
if (!flutterVlessSecureSocksPatchScript.isFile) {
|
||||
throw GradleException("secure SOCKS patch script missing: ${flutterVlessSecureSocksPatchScript.absolutePath}")
|
||||
}
|
||||
if (!File(projectRootDir, ".dart_tool/package_config.json").isFile) {
|
||||
throw GradleException("Flutter package metadata missing. Run `flutter pub get` before Android compilation.")
|
||||
}
|
||||
}
|
||||
|
||||
commandLine(
|
||||
dartExecutable.absolutePath,
|
||||
"run",
|
||||
flutterVlessSecureSocksPatchScript.absolutePath,
|
||||
)
|
||||
}
|
||||
|
||||
val patchFlutterVlessSecureSocksScopeFix = tasks.register<Exec>("patchFlutterVlessSecureSocksScopeFix") {
|
||||
group = "build setup"
|
||||
description = "Repair the secure Xray process monitor capture without changing stock 1.1.5 runtime sequencing"
|
||||
workingDir(projectRootDir)
|
||||
dependsOn(patchFlutterVlessSecureSocks)
|
||||
|
||||
doFirst {
|
||||
if (!dartExecutable.isFile) {
|
||||
throw GradleException("Flutter Dart executable not found: ${dartExecutable.absolutePath}")
|
||||
}
|
||||
if (!flutterVlessSecureSocksScopeFixScript.isFile) {
|
||||
throw GradleException("secure SOCKS scope fix script missing: ${flutterVlessSecureSocksScopeFixScript.absolutePath}")
|
||||
}
|
||||
if (!File(projectRootDir, ".dart_tool/package_config.json").isFile) {
|
||||
throw GradleException("Flutter package metadata missing. Run `flutter pub get` before Android compilation.")
|
||||
}
|
||||
}
|
||||
|
||||
commandLine(
|
||||
dartExecutable.absolutePath,
|
||||
"run",
|
||||
flutterVlessSecureSocksScopeFixScript.absolutePath,
|
||||
)
|
||||
}
|
||||
|
||||
// App compilation and the transitive Android plugin compilation must both wait
|
||||
// for the pinned runtime patches. Plain `flutter build apk` must behave like CI
|
||||
// instead of relying on a hidden manual pre-build step.
|
||||
tasks.configureEach {
|
||||
if (name == "preBuild") {
|
||||
dependsOn(patchFlutterVlessSecureSocksScopeFix)
|
||||
}
|
||||
}
|
||||
|
||||
gradle.projectsEvaluated {
|
||||
rootProject.findProject(":flutter_vless_android")
|
||||
?.tasks
|
||||
?.matching { it.name == "preBuild" }
|
||||
?.configureEach {
|
||||
dependsOn(patchFlutterVlessSecureSocksScopeFix)
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.paladinvpn.app"
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
|
||||
Reference in new issue
Block a user