Skip to content

Commit 262a6b5

Browse files
committed
remove geoip embed and sideload
we had geoip.metadb and geosite.dat in asserts
1 parent a1d838a commit 262a6b5

File tree

26 files changed

+3
-411
lines changed

26 files changed

+3
-411
lines changed

.github/workflows/update-dependencies.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ jobs:
2121
distribution: 'zulu'
2222
java-version: 17
2323

24-
- name: Setup Gradle
25-
uses: gradle/actions/setup-gradle@v4
26-
2724
- name: Setup Go
2825
uses: actions/setup-go@v5
2926
with:
@@ -37,10 +34,6 @@ jobs:
3734
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
3835
restore-keys: |
3936
${{ runner.os }}-go-
40-
41-
- name: Download GeoIP Database
42-
run: |
43-
./gradlew :core:downloadGeoipDatabase
4437
4538
- name: Install update-go-mod-replace
4639
run: |

app/src/main/java/com/github/kr328/clash/OverrideSettingsActivity.kt

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,45 +45,14 @@ class OverrideSettingsActivity : BaseActivity<OverrideSettingsDesign>() {
4545
withClash {
4646
clearOverride(Clash.OverrideSlot.Persist)
4747
}
48-
49-
service.sideloadGeoip = ""
5048
}
5149

5250
finish()
5351
}
5452
}
55-
OverrideSettingsDesign.Request.EditSideloadGeoip -> {
56-
withContext(Dispatchers.IO) {
57-
val list = querySideloadProviders()
58-
val initial = service.sideloadGeoip
59-
val exist = list.any { info -> info.packageName == initial }
60-
61-
service.sideloadGeoip =
62-
design.requestSelectSideload(if (exist) initial else "", list)
63-
}
64-
}
6553
}
6654
}
6755
}
6856
}
6957
}
70-
71-
private fun querySideloadProviders(): List<AppInfo> {
72-
val apps = packageManager.getInstalledPackages(PackageManager.GET_META_DATA)
73-
.filter {
74-
it.applicationInfo.metaData?.containsKey(Metadata.GEOIP_FILE_NAME)
75-
?: false
76-
}
77-
.map { it.toAppInfo(packageManager) }
78-
79-
return listOf(
80-
AppInfo(
81-
packageName = "",
82-
label = getString(R.string.use_built_in),
83-
icon = getDrawableCompat(R.drawable.ic_baseline_work)!!,
84-
installTime = 0,
85-
updateDate = 0,
86-
)
87-
) + apps
88-
}
8958
}

core/build.gradle.kts

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ plugins {
1111
id("golang-android")
1212
}
1313

14-
val geoipDatabaseUrl =
15-
"https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb"
16-
val geoipInvalidate = Duration.ofDays(7)!!
17-
val geoipOutput = buildDir.resolve("intermediates/golang_blob")
1814
val golangSource = file("src/main/golang/native")
1915

2016
golang {
@@ -66,52 +62,4 @@ afterEvaluate {
6662
tasks.withType(GolangBuildTask::class.java).forEach {
6763
it.inputs.dir(golangSource)
6864
}
69-
}
70-
71-
task("downloadGeoipDatabase") {
72-
val databaseFile = geoipOutput.resolve("Country.mmdb")
73-
val moduleFile = geoipOutput.resolve("go.mod")
74-
val sourceFile = geoipOutput.resolve("blob.go")
75-
76-
val moduleContent = """
77-
module "cfa/blob"
78-
""".trimIndent()
79-
80-
val sourceContent = """
81-
package blob
82-
83-
import _ "embed"
84-
85-
//go:embed Country.mmdb
86-
var GeoipDatabase []byte
87-
""".trimIndent()
88-
89-
outputs.dir(geoipOutput)
90-
91-
onlyIf {
92-
System.currentTimeMillis() - databaseFile.lastModified() > geoipInvalidate.toMillis()
93-
}
94-
95-
doLast {
96-
geoipOutput.mkdirs()
97-
98-
moduleFile.writeText(moduleContent)
99-
sourceFile.writeText(sourceContent)
100-
101-
URL(geoipDatabaseUrl).openConnection().getInputStream().use { input ->
102-
FileOutputStream(databaseFile).use { output ->
103-
input.copyTo(output)
104-
}
105-
}
106-
}
107-
}
108-
109-
afterEvaluate {
110-
val downloadTask = tasks["downloadGeoipDatabase"]
111-
112-
tasks.forEach {
113-
if (it.name.startsWith("externalGolangBuild")) {
114-
it.dependsOn(downloadTask)
115-
}
116-
}
117-
}
65+
}

core/src/foss/golang/go.mod

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ go 1.20
44

55
require cfa v0.0.0
66

7-
require cfa/blob v0.0.0-00010101000000-000000000000 // indirect
8-
97
require (
108
github.com/3andne/restls-client-go v0.1.6 // indirect
119
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
115113
replace cfa => ../../main/golang
116114

117115
replace github.com/metacubex/mihomo => ./clash
118-
119-
replace cfa/blob => ../../../build/intermediates/golang_blob

core/src/main/cpp/main.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -287,33 +287,6 @@ Java_com_github_kr328_clash_core_bridge_Bridge_nativeClearOverride(JNIEnv *env,
287287
clearOverride(slot);
288288
}
289289

290-
JNIEXPORT void JNICALL
291-
Java_com_github_kr328_clash_core_bridge_Bridge_nativeInstallSideloadGeoip(JNIEnv *env, jobject thiz,
292-
jbyteArray data) {
293-
TRACE_METHOD();
294-
295-
if (data == NULL) {
296-
installSideloadGeoip(NULL, 0);
297-
298-
return;
299-
}
300-
301-
jbyte *bytes = (*env)->GetByteArrayElements(env, data, NULL);
302-
int size = (*env)->GetArrayLength(env, data);
303-
304-
scoped_string err = installSideloadGeoip(bytes, size);
305-
306-
(*env)->ReleaseByteArrayElements(env, data, bytes, JNI_ABORT);
307-
308-
if (err != NULL) {
309-
(*env)->ThrowNew(
310-
env,
311-
find_class("com/github/kr328/clash/core/bridge/ClashException"),
312-
err
313-
);
314-
}
315-
}
316-
317290
JNIEXPORT jstring JNICALL
318291
Java_com_github_kr328_clash_core_bridge_Bridge_nativeQueryConfiguration(JNIEnv *env, jobject thiz) {
319292
TRACE_METHOD();

core/src/main/golang/.idea/codeStyles/Project.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/main/golang/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.20
55
require (
66
github.com/dlclark/regexp2 v1.11.4
77
github.com/metacubex/mihomo v1.7.0
8-
github.com/oschwald/maxminddb-golang v1.12.0
98
golang.org/x/sync v0.8.0
109
gopkg.in/yaml.v3 v3.0.1
1110
)
@@ -71,6 +70,7 @@ require (
7170
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7 // indirect
7271
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
7372
github.com/openacid/low v0.1.21 // indirect
73+
github.com/oschwald/maxminddb-golang v1.12.0 // indirect
7474
github.com/pierrec/lz4/v4 v4.1.14 // indirect
7575
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
7676
github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect

core/src/main/golang/native/delegate/init.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,19 @@ import (
44
"errors"
55
"syscall"
66

7-
"cfa/blob"
8-
97
"github.com/metacubex/mihomo/component/process"
108
"github.com/metacubex/mihomo/log"
119

1210
"cfa/native/app"
1311
"cfa/native/platform"
1412

1513
"github.com/metacubex/mihomo/component/dialer"
16-
"github.com/metacubex/mihomo/component/mmdb"
1714
"github.com/metacubex/mihomo/constant"
1815
)
1916

2017
var errBlocked = errors.New("blocked")
2118

2219
func Init(home, versionName string, platformVersion int) {
23-
mmdb.LoadFromBytes(blob.GeoipDatabase)
2420
constant.SetHomeDir(home)
2521
app.ApplyVersionName(versionName)
2622
app.ApplyPlatformVersion(platformVersion)

core/src/main/golang/native/tunnel.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,3 @@ func updateProvider(completable unsafe.Pointer, pType C.c_string, name C.c_strin
109109
func suspend(suspended C.int) {
110110
tunnel.Suspend(suspended != 0)
111111
}
112-
113-
//export installSideloadGeoip
114-
func installSideloadGeoip(block unsafe.Pointer, blockSize C.int) *C.char {
115-
if block == nil {
116-
_ = tunnel.InstallSideloadGeoip(nil)
117-
118-
return nil
119-
}
120-
121-
bytes := C.GoBytes(block, blockSize)
122-
123-
return marshalString(tunnel.InstallSideloadGeoip(bytes))
124-
}

core/src/main/golang/native/tunnel/geoip.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)