From 262a6b563c7ec7eedbc321a02408a313ea80d0e3 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Wed, 11 Sep 2024 14:41:22 +0800 Subject: [PATCH] remove geoip embed and sideload we had geoip.metadb and geosite.dat in asserts --- .github/workflows/update-dependencies.yaml | 7 -- .../kr328/clash/OverrideSettingsActivity.kt | 31 ------- core/build.gradle.kts | 54 +----------- core/src/foss/golang/go.mod | 4 - core/src/main/cpp/main.c | 27 ------ .../main/golang/.idea/codeStyles/Project.xml | 1 - core/src/main/golang/go.mod | 2 +- core/src/main/golang/native/delegate/init.go | 4 - core/src/main/golang/native/tunnel.go | 13 --- core/src/main/golang/native/tunnel/geoip.go | 24 ----- .../java/com/github/kr328/clash/core/Clash.kt | 4 - .../github/kr328/clash/core/bridge/Bridge.kt | 1 - .../clash/design/OverrideSettingsDesign.kt | 55 +----------- .../design/adapter/SideloadProviderAdapter.kt | 48 ---------- design/src/main/res/values-ja-rJP/strings.xml | 2 - design/src/main/res/values-ko-rKR/strings.xml | 2 - design/src/main/res/values-ru/strings.xml | 2 - design/src/main/res/values-zh-rHK/strings.xml | 2 - design/src/main/res/values-zh-rTW/strings.xml | 2 - design/src/main/res/values-zh/strings.xml | 2 - design/src/main/res/values/strings.xml | 2 - .../kr328/clash/service/ClashService.kt | 6 -- .../github/kr328/clash/service/TunService.kt | 6 -- .../clash/module/SideloadDatabaseModule.kt | 87 ------------------- .../clash/service/sideload/ExternalGeoip.kt | 21 ----- .../kr328/clash/service/store/ServiceStore.kt | 5 -- 26 files changed, 3 insertions(+), 411 deletions(-) delete mode 100644 core/src/main/golang/native/tunnel/geoip.go delete mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/SideloadProviderAdapter.kt delete mode 100644 service/src/main/java/com/github/kr328/clash/service/clash/module/SideloadDatabaseModule.kt delete mode 100644 service/src/main/java/com/github/kr328/clash/service/sideload/ExternalGeoip.kt diff --git a/.github/workflows/update-dependencies.yaml b/.github/workflows/update-dependencies.yaml index dc87d26e..476489f6 100644 --- a/.github/workflows/update-dependencies.yaml +++ b/.github/workflows/update-dependencies.yaml @@ -21,9 +21,6 @@ jobs: distribution: 'zulu' java-version: 17 - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 - - name: Setup Go uses: actions/setup-go@v5 with: @@ -37,10 +34,6 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - - - name: Download GeoIP Database - run: | - ./gradlew :core:downloadGeoipDatabase - name: Install update-go-mod-replace run: | diff --git a/app/src/main/java/com/github/kr328/clash/OverrideSettingsActivity.kt b/app/src/main/java/com/github/kr328/clash/OverrideSettingsActivity.kt index c1636c86..b4641ed0 100644 --- a/app/src/main/java/com/github/kr328/clash/OverrideSettingsActivity.kt +++ b/app/src/main/java/com/github/kr328/clash/OverrideSettingsActivity.kt @@ -45,45 +45,14 @@ class OverrideSettingsActivity : BaseActivity() { withClash { clearOverride(Clash.OverrideSlot.Persist) } - - service.sideloadGeoip = "" } finish() } } - OverrideSettingsDesign.Request.EditSideloadGeoip -> { - withContext(Dispatchers.IO) { - val list = querySideloadProviders() - val initial = service.sideloadGeoip - val exist = list.any { info -> info.packageName == initial } - - service.sideloadGeoip = - design.requestSelectSideload(if (exist) initial else "", list) - } - } } } } } } - - private fun querySideloadProviders(): List { - val apps = packageManager.getInstalledPackages(PackageManager.GET_META_DATA) - .filter { - it.applicationInfo.metaData?.containsKey(Metadata.GEOIP_FILE_NAME) - ?: false - } - .map { it.toAppInfo(packageManager) } - - return listOf( - AppInfo( - packageName = "", - label = getString(R.string.use_built_in), - icon = getDrawableCompat(R.drawable.ic_baseline_work)!!, - installTime = 0, - updateDate = 0, - ) - ) + apps - } } \ No newline at end of file diff --git a/core/build.gradle.kts b/core/build.gradle.kts index ed6dd2ad..e50230aa 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -11,10 +11,6 @@ plugins { id("golang-android") } -val geoipDatabaseUrl = - "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb" -val geoipInvalidate = Duration.ofDays(7)!! -val geoipOutput = buildDir.resolve("intermediates/golang_blob") val golangSource = file("src/main/golang/native") golang { @@ -66,52 +62,4 @@ afterEvaluate { tasks.withType(GolangBuildTask::class.java).forEach { it.inputs.dir(golangSource) } -} - -task("downloadGeoipDatabase") { - val databaseFile = geoipOutput.resolve("Country.mmdb") - val moduleFile = geoipOutput.resolve("go.mod") - val sourceFile = geoipOutput.resolve("blob.go") - - val moduleContent = """ - module "cfa/blob" - """.trimIndent() - - val sourceContent = """ - package blob - - import _ "embed" - - //go:embed Country.mmdb - var GeoipDatabase []byte - """.trimIndent() - - outputs.dir(geoipOutput) - - onlyIf { - System.currentTimeMillis() - databaseFile.lastModified() > geoipInvalidate.toMillis() - } - - doLast { - geoipOutput.mkdirs() - - moduleFile.writeText(moduleContent) - sourceFile.writeText(sourceContent) - - URL(geoipDatabaseUrl).openConnection().getInputStream().use { input -> - FileOutputStream(databaseFile).use { output -> - input.copyTo(output) - } - } - } -} - -afterEvaluate { - val downloadTask = tasks["downloadGeoipDatabase"] - - tasks.forEach { - if (it.name.startsWith("externalGolangBuild")) { - it.dependsOn(downloadTask) - } - } -} +} \ No newline at end of file diff --git a/core/src/foss/golang/go.mod b/core/src/foss/golang/go.mod index a4af5078..6a00af12 100644 --- a/core/src/foss/golang/go.mod +++ b/core/src/foss/golang/go.mod @@ -4,8 +4,6 @@ go 1.20 require cfa v0.0.0 -require cfa/blob v0.0.0-00010101000000-000000000000 // indirect - require ( github.com/3andne/restls-client-go v0.1.6 // indirect github.com/RyuaNerin/go-krypto v1.2.4 // indirect @@ -115,5 +113,3 @@ replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20240724044 replace cfa => ../../main/golang replace github.com/metacubex/mihomo => ./clash - -replace cfa/blob => ../../../build/intermediates/golang_blob diff --git a/core/src/main/cpp/main.c b/core/src/main/cpp/main.c index a836a0e1..0a2c8b51 100644 --- a/core/src/main/cpp/main.c +++ b/core/src/main/cpp/main.c @@ -287,33 +287,6 @@ Java_com_github_kr328_clash_core_bridge_Bridge_nativeClearOverride(JNIEnv *env, clearOverride(slot); } -JNIEXPORT void JNICALL -Java_com_github_kr328_clash_core_bridge_Bridge_nativeInstallSideloadGeoip(JNIEnv *env, jobject thiz, - jbyteArray data) { - TRACE_METHOD(); - - if (data == NULL) { - installSideloadGeoip(NULL, 0); - - return; - } - - jbyte *bytes = (*env)->GetByteArrayElements(env, data, NULL); - int size = (*env)->GetArrayLength(env, data); - - scoped_string err = installSideloadGeoip(bytes, size); - - (*env)->ReleaseByteArrayElements(env, data, bytes, JNI_ABORT); - - if (err != NULL) { - (*env)->ThrowNew( - env, - find_class("com/github/kr328/clash/core/bridge/ClashException"), - err - ); - } -} - JNIEXPORT jstring JNICALL Java_com_github_kr328_clash_core_bridge_Bridge_nativeQueryConfiguration(JNIEnv *env, jobject thiz) { TRACE_METHOD(); diff --git a/core/src/main/golang/.idea/codeStyles/Project.xml b/core/src/main/golang/.idea/codeStyles/Project.xml index bbba885f..235439ed 100644 --- a/core/src/main/golang/.idea/codeStyles/Project.xml +++ b/core/src/main/golang/.idea/codeStyles/Project.xml @@ -5,7 +5,6 @@