Compare commits

..

40 Commits

Author SHA1 Message Date
Kr328
c78431a0fb Chore: bump version 2021-10-15 11:07:10 +08:00
Kr328
3b33216961 Chore: update dependencies 2021-10-15 11:07:00 +08:00
Kr328
6373636d57 Chore: update clash core 2021-10-15 10:42:00 +08:00
Kr328
04a1f9987e Chore: update tun2socket 2021-10-15 10:41:54 +08:00
Kr328
90d286cd5a Chore: update gitignore 2021-09-26 10:04:35 +08:00
Kr328
1826d108a5 Chore: bump version 2021-09-24 11:24:05 +08:00
Goooler
a5619bb0ee Chore: add cache action in CI (#1201) 2021-09-24 11:15:07 +08:00
Goooler
5c1fadaba2 Chore: update dependencies (#1198) 2021-09-24 11:13:10 +08:00
Kr328
7928f4321a Chore: update clash core 2021-09-24 11:11:47 +08:00
Kr328
3b62367003 Chore: bump version 2021-09-17 11:21:21 +08:00
Kr328
c8994d8488 Chore: add version to output apks name 2021-09-17 11:19:03 +08:00
kr328
4033994111 Chore: bump version 2021-09-14 01:50:06 +08:00
kr328
2050fb56d0 Chore: update clash core 2021-09-14 01:49:45 +08:00
kr328
eeea9d0fce Fix: add zhihu to http proxy black list 2021-09-14 01:07:55 +08:00
kr328
4b1f7a76c7 Chore: update dependencies 2021-09-13 22:44:01 +08:00
kr328
db2a7feb34 Chore: remove dependencies update detect plugin 2021-09-13 22:41:19 +08:00
Goooler
8b91b2eeb1 Chore: add .gitattributes (#1191)
* Add .editorconfig

* Add .gitattributes

* Remove indent_style

* Remove .editorconfig
2021-09-13 18:34:34 +08:00
Goooler
899803739b Chore: remove unused dependencies & improve gradle properties & code style (#1189)
* Inline version strings

* Optimize gradle

* Remove kotlin-stdlib-jdk7

* Add jvmargs in gradle.properties

* Revert "Inline version strings"

This reverts commit ad2ab2bb

* Revert asserts
2021-09-13 17:49:23 +08:00
Goooler
1ea3a5b682 Chore: bump setup-java action & Remove setup-android action (#1188)
* Bump setup-java action to v2

* Remove setup-android action

* Remove ignore rules under github folder
2021-09-13 17:45:46 +08:00
kr328
f21cf86cc4 Chore: allow run workflow only main branch 2021-09-12 18:31:16 +08:00
kr328
bb1052bbc7 Chore: update README.md 2021-09-12 18:25:09 +08:00
kr328
7dad08346c Chore: update dependencies 2021-09-12 18:02:30 +08:00
kr328
b7c56e58ae Chore: add hideapi to app module to avoid r8 class missing 2021-09-12 17:50:48 +08:00
kr328
a6f6da5bc5 Chore: remove unused check 2021-09-12 17:39:04 +08:00
kr328
f271ba3d97 Feature: add dns.geoip-code support 2021-09-12 17:38:52 +08:00
kr328
66d02c7e2d Chore: bump version 2021-09-12 13:19:55 +08:00
kr328
0406573317 Refactor: refactor properties 2021-09-12 13:19:40 +08:00
kr328
4a8b6b2704 Refactor: refactor design structure 2021-09-12 13:01:08 +08:00
kr328
603cec113c Chore: update clash patch 2021-09-12 12:40:15 +08:00
kr328
a579c7bb86 Fix: should not delay before patch system dns 2021-09-12 12:24:09 +08:00
kr328
654c488ed8 Fix: fix time zone 2021-09-12 11:46:20 +08:00
kr328
ecfb339680 Chore: fix code style 2021-09-12 11:26:27 +08:00
kr328
ecbe222a50 Chore: update dependencies 2021-09-12 11:14:45 +08:00
kr328
aacf62c259 Chore: update dependencies 2021-09-12 11:04:26 +08:00
kr328
3973fb2706 Fix: fix premium build 2021-09-12 01:33:52 +08:00
kr328
07ff81f4db Fix: should add main golang source as input 2021-09-12 00:43:32 +08:00
kr328
c0e1e45b72 Refactor: refactor clash core building 2021-09-12 00:39:59 +08:00
Kr328
b07f70ab0b Improve: should not reload profile on network changed 2021-09-11 23:37:54 +08:00
Kr328
e1a35f8b2d Chore: bump go version to 1.17 2021-09-11 19:49:26 +08:00
kr328
e364af393a Refactor: refactor golang flavor 2021-09-11 18:29:05 +08:00
94 changed files with 1665 additions and 857 deletions

4
.gitattributes vendored Normal file
View File

@@ -0,0 +1,4 @@
* text=auto eol=lf
*.bat text eol=crlf
*.jar binary

View File

@@ -4,8 +4,8 @@ on:
branches:
- main
paths-ignore:
- '.github/**'
- '.idea/**'
- '.gitattributes'
- '.gitignore'
- '.gitmodules'
- '**.md'
@@ -13,8 +13,8 @@ on:
- 'NOTICE'
pull_request:
paths-ignore:
- '.github/**'
- '.idea/**'
- '.gitattributes'
- '.gitignore'
- '.gitmodules'
- '**.md'
@@ -29,14 +29,18 @@ jobs:
with:
submodules: recursive
- name: Setup Java
uses: actions/setup-java@v1
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 11
- name: Gradle cache
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties', '**/buildSrc/src/main/kotlin/**.kt') }}
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Build
run: ./gradlew --no-daemon app:assembleFossRelease
run: ./gradlew --no-daemon app:assembleFossRelease

20
.gitignore vendored
View File

@@ -20,12 +20,15 @@ gradle-app.setting
*.iml
/.idea/*
!/.idea/codeStyles
/core/src/foss/go/.idea/*
!/core/src/foss/go/.idea/codeStyles
/core/src/premium/go/.idea/*
!/core/src/premium/go/.idea/codeStyles
/core/src/main/golang/.idea/*
!/core/src/main/golang/.idea/codeStyles
/core/src/foss/golang/.idea/*
!/core/src/foss/golang/.idea/codeStyles
/core/src/premium/golang/.idea/*
!/core/src/premium/golang/.idea/codeStyles
# KeyStore
signing.properties
*.keystore
*.jks
@@ -35,8 +38,9 @@ cmake-build-*
# local.properties
local.properties
# keystore
keystore.properties
# tracker
tracker.properties
# vscode
.vscode
@@ -55,5 +59,5 @@ google-services.json
# logs
*.log
# Ignore sum
/core/src/main/golang/go.sum
# MacOS
.DS_Store

5
.gitmodules vendored
View File

@@ -1,3 +1,6 @@
[submodule "clash-foss"]
path = core/src/foss/go/clash
path = core/src/foss/golang/clash
url = https://github.com/Kr328/clash.git
[submodule "clash-premium"]
path = core/src/premium/golang/clash
url = https://github.com/Kr328/clash.git

View File

@@ -38,13 +38,13 @@ See also [PRIVACY_POLICY.md](./PRIVACY_POLICY.md)
sdk.dir=/path/to/android-sdk
```
4. Create `keystore.properties` in project root with
4. Create `signing.properties` in project root with
```properties
storeFile=/path/to/keystore/file
storePassword=<key store password>
keyAlias=<key alias>
keyPassword=<key password>
keystore.path=/path/to/keystore/file
keystore.password=<key store password>
key.alias=<key alias>
key.password=<key password>
```
5. Build
@@ -53,4 +53,4 @@ See also [PRIVACY_POLICY.md](./PRIVACY_POLICY.md)
./gradlew app:assembleFossRelease
```
6. Pick `app-foss-<arch>-release-signed.apk` in `app/build/outputs/apk/foss/release/`
6. Pick `app-foss-<arch>-release.apk` in `app/build/outputs/apk/foss/release/`

View File

@@ -5,12 +5,13 @@ plugins {
}
dependencies {
compileOnly(project(":hideapi"))
implementation(project(":core"))
implementation(project(":service"))
implementation(project(":design"))
implementation(project(":common"))
implementation(kotlin("stdlib-jdk7"))
implementation(deps.kotlin.coroutine)
implementation(deps.androidx.core)
implementation(deps.androidx.activity)

View File

@@ -8,7 +8,7 @@ import com.microsoft.appcenter.crashes.ingestion.models.ErrorAttachmentLog
object Tracker {
fun initialize(application: Application) {
if (BuildConfig.APP_CENTER_KEY != null && !BuildConfig.DEBUG) {
if (!BuildConfig.DEBUG) {
AppCenter.start(
application,
BuildConfig.APP_CENTER_KEY,
@@ -18,7 +18,7 @@ object Tracker {
}
fun uploadLogcat(logcat: String) {
if (BuildConfig.APP_CENTER_KEY != null && !BuildConfig.DEBUG) {
if (!BuildConfig.DEBUG) {
if (logcat.isNotBlank()) {
Crashes.trackError(
RuntimeException(),

View File

@@ -1,12 +1,13 @@
@file:Suppress("UNUSED_VARIABLE")
import com.android.build.gradle.AppExtension
import com.android.build.gradle.BaseExtension
import java.net.URL
import java.util.*
buildscript {
repositories {
mavenCentral()
mavenLocal()
google()
maven("https://maven.kr328.app/releases")
}
@@ -21,8 +22,8 @@ buildscript {
allprojects {
repositories {
google()
mavenCentral()
google()
maven("https://maven.kr328.app/releases")
}
}
@@ -32,11 +33,11 @@ subprojects {
apply(plugin = if (isApp) "com.android.application" else "com.android.library")
extensions.configure(BaseExtension::class) {
extensions.configure<BaseExtension> {
val minSdkVersion = 21
val targetSdkVersion = 30
val buildVersionCode = 204009
val buildVersionName = "2.4.9"
val buildVersionCode = 204014
val buildVersionName = "2.4.14"
val defaultDimension = "feature"
ndkVersion = "23.0.7599858"
@@ -54,10 +55,6 @@ subprojects {
versionName = buildVersionName
versionCode = buildVersionCode
if (!isApp) {
consumerProguardFiles("consumer-rules.pro")
}
resValue("string", "release_name", "v$buildVersionName")
resValue("integer", "release_code", "$buildVersionCode")
@@ -66,11 +63,11 @@ subprojects {
abiFilters("arm64-v8a", "armeabi-v7a", "x86", "x86_64")
}
}
}
externalNativeBuild {
cmake {
version = "3.18.1"
if (!isApp) {
consumerProguardFiles("consumer-rules.pro")
} else {
setProperty("archivesBaseName", "cfa-$versionName")
}
}
@@ -80,17 +77,6 @@ subprojects {
}
}
buildTypes {
named("release") {
isMinifyEnabled = isApp
isShrinkResources = isApp
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
productFlavors {
flavorDimensions(defaultDimension)
@@ -98,6 +84,8 @@ subprojects {
dimension = defaultDimension
versionNameSuffix = ".foss"
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")")
if (isApp) {
applicationIdSuffix = ".foss"
}
@@ -105,6 +93,52 @@ subprojects {
create("premium") {
dimension = defaultDimension
versionNameSuffix = ".premium"
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"true\")")
val tracker = rootProject.file("tracker.properties")
if (tracker.exists()) {
val prop = Properties().apply {
tracker.inputStream().use(this::load)
}
buildConfigField(
"String",
"APP_CENTER_KEY",
"\"${prop.getProperty("appcenter.key")!!}\""
)
}
}
}
signingConfigs {
val keystore = rootProject.file("signing.properties")
if (keystore.exists()) {
create("release") {
val prop = Properties().apply {
keystore.inputStream().use(this::load)
}
storeFile = rootProject.file(prop.getProperty("keystore.path")!!)
storePassword = prop.getProperty("keystore.password")!!
keyAlias = prop.getProperty("key.alias")!!
keyPassword = prop.getProperty("key.password")!!
}
}
}
buildTypes {
named("release") {
isMinifyEnabled = isApp
isShrinkResources = isApp
signingConfig = signingConfigs.findByName("release")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
named("debug") {
versionNameSuffix = ".debug"
}
}
@@ -115,6 +149,8 @@ subprojects {
}
if (isApp) {
this as AppExtension
splits {
abi {
isEnable = true
@@ -129,7 +165,7 @@ task("clean", type = Delete::class) {
delete(rootProject.buildDir)
}
tasks.named<Wrapper>("wrapper") {
tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
doLast {

View File

@@ -6,7 +6,6 @@ plugins {
dependencies {
compileOnly(project(":hideapi"))
implementation(kotlin("stdlib-jdk7"))
implementation(deps.kotlin.coroutine)
implementation(deps.androidx.core)
}

View File

@@ -1,3 +1,4 @@
import com.github.kr328.golang.GolangBuildTask
import com.github.kr328.golang.GolangPlugin
import java.io.FileOutputStream
import java.net.URL
@@ -14,17 +15,21 @@ val geoipDatabaseUrl =
"https://github.com/Dreamacro/maxmind-geoip/releases/latest/download/Country.mmdb"
val geoipInvalidate = Duration.ofDays(7)!!
val geoipOutput = buildDir.resolve("intermediates/golang_blob")
val golangSource = file("src/main/golang/native")
golang {
sourceSets {
create("foss") {
srcDir.set(file("src/foss/go"))
tags.set(listOf("foss"))
srcDir.set(file("src/foss/golang"))
}
create("premium") {
srcDir.set(file("src/premium/go"))
tags.set(listOf("premium", "without_gvisor", "without_system"))
srcDir.set(file("src/premium/golang"))
}
all {
fileName.set("libclash.so")
packageName.set("cfa/native")
}
}
}
@@ -34,7 +39,7 @@ android {
all {
externalNativeBuild {
cmake {
arguments("-DGO_SOURCE:STRING=${golang.sourceSets.getByName(name).srcDir.asFile.get()}")
arguments("-DGO_SOURCE:STRING=${golangSource}")
arguments("-DGO_OUTPUT:STRING=${GolangPlugin.outputDirOf(project, null, null)}")
arguments("-DFLAVOR_NAME:STRING=$name")
}
@@ -52,14 +57,15 @@ android {
dependencies {
implementation(project(":common"))
implementation(kotlin("stdlib-jdk7"))
implementation(deps.androidx.core)
implementation(deps.kotlin.coroutine)
implementation(deps.kotlin.serialization.json)
}
repositories {
mavenCentral()
afterEvaluate {
tasks.withType(GolangBuildTask::class.java).forEach {
it.inputs.dir(golangSource)
}
}
task("downloadGeoipDatabase") {

View File

@@ -1,15 +0,0 @@
package app
import "strings"
var systemDns []string
func NotifyDnsChanged(dnsList string) {
dns := strings.Split(dnsList, ",")
systemDns = dns
}
func SystemDns() []string {
return systemDns
}

View File

@@ -1,18 +0,0 @@
module cfa
go 1.16
require (
cfa/blob v0.0.0 // local generated
github.com/Dreamacro/clash v0.0.0 // local
github.com/dlclark/regexp2 v1.4.0
github.com/kr328/tun2socket-lwip v0.0.0-20210911023118-0b4947e2a9c1
github.com/miekg/dns v1.1.43
github.com/oschwald/geoip2-golang v1.5.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
gopkg.in/yaml.v2 v2.4.0
)
replace github.com/Dreamacro/clash => ./clash
replace cfa/blob => ../../../build/intermediates/golang_blob

View File

@@ -0,0 +1,35 @@
module foss
go 1.17
require cfa v0.0.0
require (
cfa/blob v0.0.0 // indirect
github.com/Dreamacro/clash v1.7.1 // indirect
github.com/Dreamacro/go-shadowsocks2 v0.1.7 // indirect
github.com/dlclark/regexp2 v1.4.0 // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/insomniacslk/dhcp v0.0.0-20210827173440-b95caade3eac // indirect
github.com/kr328/tun2socket-lwip v0.0.0-20211015022349-94b5374d46e5 // indirect
github.com/miekg/dns v1.1.43 // indirect
github.com/oschwald/geoip2-golang v1.5.0 // indirect
github.com/oschwald/maxminddb-golang v1.8.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/u-root/uio v0.0.0-20210528114334-82958018845c // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34 // indirect
golang.org/x/text v0.3.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
replace cfa => ../../main/golang
replace github.com/Dreamacro/clash => ./clash
replace cfa/blob => ../../../build/intermediates/golang_blob

120
core/src/foss/golang/go.sum Normal file
View File

@@ -0,0 +1,120 @@
github.com/Dreamacro/go-shadowsocks2 v0.1.7 h1:8CtbE1HoPPMfrQZGXmlluq6dO2lL31W6WRRE8fabc4Q=
github.com/Dreamacro/go-shadowsocks2 v0.1.7/go.mod h1:8p5G4cAj5ZlXwUR+Ww63gfSikr8kvw8uw3TDwLAJpUc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/fanliao/go-promise v0.0.0-20141029170127-1890db352a72/go.mod h1:PjfxuH4FZdUyfMdtBio2lsRr1AKEaVPwelzuHuh8Lqc=
github.com/go-chi/chi/v5 v5.0.4/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/cors v1.2.0/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
github.com/go-chi/render v1.0.1/go.mod h1:pq4Rr7HbnsdaeHagklXub+p6Wd16Af5l9koip1OvJns=
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hugelgupf/socketpair v0.0.0-20190730060125-05d35a94e714/go.mod h1:2Goc3h8EklBH5mspfHFxBnEoURQCGzQQH1ga9Myjvis=
github.com/insomniacslk/dhcp v0.0.0-20210827173440-b95caade3eac h1:IO6EfdRnPhxgKOsk9DbewdtQZHKZKnGlW7QCUttvNys=
github.com/insomniacslk/dhcp v0.0.0-20210827173440-b95caade3eac/go.mod h1:h+MxyHxRg9NH3terB1nfRIUaQEcI0XOVkdR9LNBlp8E=
github.com/jsimonetti/rtnetlink v0.0.0-20190606172950-9527aa82566a/go.mod h1:Oz+70psSo5OFh8DBl0Zv2ACw7Esh6pPUphlvZG9x7uw=
github.com/jsimonetti/rtnetlink v0.0.0-20200117123717-f846d4f6c1f4/go.mod h1:WGuG/smIU4J/54PblvSbh+xvCZmpJnFgr3ds6Z55XMQ=
github.com/jsimonetti/rtnetlink v0.0.0-20201009170750-9c6f07d100c1/go.mod h1:hqoO/u39cqLeBLebZ8fWdE96O7FxrAsRYhnVOdgHxok=
github.com/jsimonetti/rtnetlink v0.0.0-20201110080708-d2c240429e6c/go.mod h1:huN4d1phzjhlOsNIjFsw2SVRbwIHj3fJDMEU2SDPTmg=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kr328/tun2socket-lwip v0.0.0-20211011111457-aee61f59119e/go.mod h1:JFkXLCpLkNVvLMRkq3gexTlRHfzbqcP5HfFOoq5Mj+g=
github.com/kr328/tun2socket-lwip v0.0.0-20211015020707-5db8ce531486 h1:vr7UW621Q53YUKUlsXojehQ4dtKXwyzin0hjwegC7gw=
github.com/kr328/tun2socket-lwip v0.0.0-20211015020707-5db8ce531486/go.mod h1:JFkXLCpLkNVvLMRkq3gexTlRHfzbqcP5HfFOoq5Mj+g=
github.com/kr328/tun2socket-lwip v0.0.0-20211015022349-94b5374d46e5 h1:Hsz4nGstXCWTLjf3mFDytJ0u1HfbrOfvbWRfphsLvBg=
github.com/kr328/tun2socket-lwip v0.0.0-20211015022349-94b5374d46e5/go.mod h1:JFkXLCpLkNVvLMRkq3gexTlRHfzbqcP5HfFOoq5Mj+g=
github.com/mdlayher/ethernet v0.0.0-20190606142754-0394541c37b7/go.mod h1:U6ZQobyTjI/tJyq2HG+i/dfSoFUt8/aZCM+GKtmFk/Y=
github.com/mdlayher/netlink v0.0.0-20190409211403-11939a169225/go.mod h1:eQB3mZE4aiYnlUsyGGCOpPETfdQq4Jhsgf1fk3cwQaA=
github.com/mdlayher/netlink v1.0.0/go.mod h1:KxeJAFOFLG6AjpyDkQ/iIhxygIUKD+vcwqcnu43w/+M=
github.com/mdlayher/netlink v1.1.0/go.mod h1:H4WCitaheIsdF9yOYu8CFmCgQthAPIWZmcKp9uZHgmY=
github.com/mdlayher/netlink v1.1.1/go.mod h1:WTYpFb/WTvlRJAyKhZL5/uy69TDDpHHu2VZmb2XgV7o=
github.com/mdlayher/raw v0.0.0-20190606142536-fef19f00fc18/go.mod h1:7EpbotpCmVZcu+KCX4g9WaRNuu11uyhiW7+Le1dKawg=
github.com/mdlayher/raw v0.0.0-20191009151244-50f2db8cc065/go.mod h1:7EpbotpCmVZcu+KCX4g9WaRNuu11uyhiW7+Le1dKawg=
github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg=
github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4=
github.com/oschwald/geoip2-golang v1.5.0 h1:igg2yQIrrcRccB1ytFXqBfOHCjXWIoMv85lVJ1ONZzw=
github.com/oschwald/geoip2-golang v1.5.0/go.mod h1:xdvYt5xQzB8ORWFqPnqMwZpCpgNagttWdoZLlJQzg7s=
github.com/oschwald/maxminddb-golang v1.8.0 h1:Uh/DSnGoxsyp/KYbY1AuP0tYEwfs0sCph9p/UMXK/Hk=
github.com/oschwald/maxminddb-golang v1.8.0/go.mod h1:RXZtst0N6+FY/3qCNmZMBApR19cdQj43/NM9VkrNAis=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/u-root/uio v0.0.0-20210528114334-82958018845c h1:BFvcl34IGnw8yvJi8hlqLFo9EshRInwWBs2M5fGWzQA=
github.com/u-root/uio v0.0.0-20210528114334-82958018845c/go.mod h1:LpEX5FO/cB+WF4TYGY1V5qktpaZLkKkSegbr0V4eYXA=
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210317152858-513c2a44f670/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190419010253-1f3472d942ba/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191007182048-72f939374954/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f h1:w6wWR0H+nyVpbSAQbzVEIACVyr/h8l/BEkY6Sokc7Eg=
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190411185658-b44545bcd369/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190418153312-f0ce4c0180be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606122018-79a91cf218c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191224085550-c709ea063b76/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34 h1:GkvMjFtXUmahfDtashnc1mnrCtuBVcwse5QV2lUk/tI=
golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@@ -0,0 +1,5 @@
package golang
import (
_ "cfa/native/all"
)

View File

@@ -84,6 +84,16 @@ Java_com_github_kr328_clash_core_bridge_Bridge_nativeNotifyDnsChanged(JNIEnv *en
notifyDnsChanged(_dns_list);
}
JNIEXPORT void JNICALL
Java_com_github_kr328_clash_core_bridge_Bridge_nativeNotifyTimeZoneChanged(JNIEnv *env, jobject thiz,
jstring name, jint offset) {
TRACE_METHOD();
scoped_string _name = get_string(name);
notifyTimeZoneChanged(_name, offset);
}
JNIEXPORT void JNICALL
Java_com_github_kr328_clash_core_bridge_Bridge_nativeNotifyInstalledAppChanged(JNIEnv *env,
jobject thiz,

View File

@@ -0,0 +1,28 @@
module cfa
go 1.17
require (
github.com/Dreamacro/clash v1.7.1
github.com/dlclark/regexp2 v1.4.0
github.com/kr328/tun2socket-lwip v0.0.0-20211011111457-aee61f59119e
github.com/miekg/dns v1.1.43
github.com/oschwald/geoip2-golang v1.5.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
gopkg.in/yaml.v2 v2.4.0
)
require (
github.com/Dreamacro/go-shadowsocks2 v0.1.7 // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/insomniacslk/dhcp v0.0.0-20210827173440-b95caade3eac // indirect
github.com/oschwald/maxminddb-golang v1.8.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/u-root/uio v0.0.0-20210528114334-82958018845c // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect
golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34 // indirect
golang.org/x/text v0.3.6 // indirect
)

View File

@@ -1,3 +1,5 @@
github.com/Dreamacro/clash v1.7.1 h1:8iYYiyVf7ZAztwoFeTFihs5rI9Jjic0ZKmf05vQxzFU=
github.com/Dreamacro/clash v1.7.1/go.mod h1:C9eLMAlDZSLrkdzGQdOHyeldwRjDbcGR2kaL80KdzGw=
github.com/Dreamacro/go-shadowsocks2 v0.1.7 h1:8CtbE1HoPPMfrQZGXmlluq6dO2lL31W6WRRE8fabc4Q=
github.com/Dreamacro/go-shadowsocks2 v0.1.7/go.mod h1:8p5G4cAj5ZlXwUR+Ww63gfSikr8kvw8uw3TDwLAJpUc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -27,8 +29,8 @@ github.com/jsimonetti/rtnetlink v0.0.0-20200117123717-f846d4f6c1f4/go.mod h1:WGu
github.com/jsimonetti/rtnetlink v0.0.0-20201009170750-9c6f07d100c1/go.mod h1:hqoO/u39cqLeBLebZ8fWdE96O7FxrAsRYhnVOdgHxok=
github.com/jsimonetti/rtnetlink v0.0.0-20201110080708-d2c240429e6c/go.mod h1:huN4d1phzjhlOsNIjFsw2SVRbwIHj3fJDMEU2SDPTmg=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kr328/tun2socket-lwip v0.0.0-20210911023118-0b4947e2a9c1 h1:NJ5NyPHIok6hqdELvrI4bps5lLyfJtFmm0K4c9CB/WM=
github.com/kr328/tun2socket-lwip v0.0.0-20210911023118-0b4947e2a9c1/go.mod h1:JFkXLCpLkNVvLMRkq3gexTlRHfzbqcP5HfFOoq5Mj+g=
github.com/kr328/tun2socket-lwip v0.0.0-20211011111457-aee61f59119e h1:Q3VT9AKP8hLyR7gAhU0Wnt21kIXcgdt8dMbSOjfEd98=
github.com/kr328/tun2socket-lwip v0.0.0-20211011111457-aee61f59119e/go.mod h1:JFkXLCpLkNVvLMRkq3gexTlRHfzbqcP5HfFOoq5Mj+g=
github.com/mdlayher/ethernet v0.0.0-20190606142754-0394541c37b7/go.mod h1:U6ZQobyTjI/tJyq2HG+i/dfSoFUt8/aZCM+GKtmFk/Y=
github.com/mdlayher/netlink v0.0.0-20190409211403-11939a169225/go.mod h1:eQB3mZE4aiYnlUsyGGCOpPETfdQq4Jhsgf1fk3cwQaA=
github.com/mdlayher/netlink v1.0.0/go.mod h1:KxeJAFOFLG6AjpyDkQ/iIhxygIUKD+vcwqcnu43w/+M=

View File

@@ -0,0 +1,16 @@
package all
import (
_ "cfa/native/app"
_ "cfa/native/common"
_ "cfa/native/config"
_ "cfa/native/delegate"
_ "cfa/native/platform"
_ "cfa/native/proxy"
_ "cfa/native/tun"
_ "cfa/native/tunnel"
_ "golang.org/x/sync/semaphore"
_ "github.com/Dreamacro/clash/log"
)

View File

@@ -7,7 +7,7 @@ import (
"errors"
"unsafe"
"cfa/app"
"cfa/native/app"
"github.com/Dreamacro/clash/log"
)
@@ -43,6 +43,12 @@ func notifyInstalledAppsChanged(uids C.c_string) {
app.NotifyInstallAppsChanged(u)
}
//export notifyTimeZoneChanged
func notifyTimeZoneChanged(name C.c_string, offset C.int) {
app.NotifyTimeZoneChanged(C.GoString(name), int(offset))
}
//export queryConfiguration
func queryConfiguration() *C.char {
response := &struct{}{}

View File

@@ -3,6 +3,7 @@ package app
import (
"strconv"
"strings"
"time"
)
var appVersionName string
@@ -46,3 +47,7 @@ func NotifyInstallAppsChanged(uidList string) {
func QueryAppByUid(uid int) string {
return installedAppsUid[uid]
}
func NotifyTimeZoneChanged(name string, offset int) {
time.Local = time.FixedZone(name, offset)
}

View File

@@ -0,0 +1,20 @@
package app
import (
"strings"
"github.com/Dreamacro/clash/dns"
)
func NotifyDnsChanged(dnsList string) {
dL := strings.Split(dnsList, ",")
ns := make([]dns.NameServer, 0, len(dnsList))
for _, d := range dL {
ns = append(ns, dns.NameServer{Addr: d})
}
dns.UpdateSystemDNS(dL)
dns.FlushCacheWithDefaultResolver()
}

View File

@@ -1,10 +1,11 @@
package app
import (
"cfa/platform"
"net"
"strings"
"syscall"
"cfa/native/platform"
)
var markSocketImpl func(fd int)

View File

@@ -7,7 +7,7 @@ import (
"runtime"
"unsafe"
"cfa/config"
"cfa/native/config"
)
type remoteValidCallback struct {

View File

@@ -11,8 +11,7 @@ import (
"runtime"
"time"
"cfa/app"
"cfa/native/app"
"github.com/Dreamacro/clash/component/dialer"
)

View File

@@ -3,12 +3,12 @@ package config
import (
"io/ioutil"
P "path"
"runtime"
"strings"
"gopkg.in/yaml.v2"
"cfa/app"
"cfa/native/app"
"github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/log"
@@ -81,6 +81,8 @@ func Load(path string) error {
app.ApplySubtitlePattern(rawCfg.ClashForAndroid.UiSubtitlePattern)
runtime.GC()
return nil
}

View File

@@ -7,11 +7,10 @@ import (
"strings"
"time"
"github.com/Dreamacro/clash/log"
"github.com/dlclark/regexp2"
"cfa/app"
"cfa/common"
"cfa/native/common"
"github.com/Dreamacro/clash/log"
"github.com/Dreamacro/clash/config"
"github.com/Dreamacro/clash/dns"
@@ -76,7 +75,7 @@ func patchDns(cfg *config.RawConfig, _ string) error {
}
if cfg.ClashForAndroid.AppendSystemDNS {
cfg.DNS.NameServer = append(cfg.DNS.NameServer, app.SystemDns()...)
cfg.DNS.NameServer = append(cfg.DNS.NameServer, "dhcp://" + dns.SystemDNSPlaceholder)
}
return nil

View File

@@ -2,7 +2,11 @@
package config
import "github.com/Dreamacro/clash/config"
import (
"io"
"github.com/Dreamacro/clash/config"
)
func forEachProviders(rawCfg *config.RawConfig, fun func(index int, total int, key string, provider map[string]interface{})) {
total := len(rawCfg.ProxyProvider) + len(rawCfg.RuleProvider)
@@ -23,10 +27,10 @@ func forEachProviders(rawCfg *config.RawConfig, fun func(index int, total int, k
func destroyProviders(cfg *config.Config) {
for _, p := range cfg.ProxyProviders {
_ = p.Destroy()
_ = p.(io.Closer).Close()
}
for _, p := range cfg.RuleProviders {
_ = p.Destroy()
_ = p.(io.Closer).Close()
}
}

View File

@@ -1,4 +1,4 @@
package core
package delegate
import (
"errors"
@@ -6,9 +6,8 @@ import (
"cfa/blob"
"cfa/app"
"cfa/platform"
"cfa/native/app"
"cfa/native/platform"
"github.com/Dreamacro/clash/component/process"
"github.com/Dreamacro/clash/log"

View File

@@ -10,9 +10,9 @@ import "C"
import (
"runtime"
"cfa/config"
"cfa/core"
"cfa/tunnel"
"cfa/native/config"
"cfa/native/delegate"
"cfa/native/tunnel"
"github.com/Dreamacro/clash/log"
)
@@ -27,7 +27,7 @@ func coreInit(home, versionName C.c_string, sdkVersion C.int) {
v := C.GoString(versionName)
s := int(sdkVersion)
core.Init(h, v, s)
delegate.Init(h, v, s)
reset()
}

View File

@@ -3,7 +3,9 @@ package main
//#include "bridge.h"
import "C"
import "cfa/proxy"
import (
"cfa/native/proxy"
)
//export startHttp
func startHttp(listenAt C.c_string) *C.char {

View File

@@ -7,10 +7,10 @@ import (
"context"
"unsafe"
"cfa/app"
"cfa/tun"
"golang.org/x/sync/semaphore"
"cfa/native/app"
"cfa/native/tun"
)
type remoteTun struct {

View File

@@ -3,7 +3,8 @@ package tun
import (
"net"
"github.com/Dreamacro/clash/component/resolver"
"github.com/Dreamacro/clash/dns"
D "github.com/miekg/dns"
)
@@ -21,7 +22,7 @@ func relayDns(payload []byte) ([]byte, error) {
return nil, err
}
r, err := resolver.ServeMsg(msg)
r, err := dns.ServeDNSWithDefaultServer(msg)
if err != nil {
return nil, err
}

View File

@@ -6,8 +6,8 @@ import "C"
import (
"unsafe"
"cfa/app"
"cfa/tunnel"
"cfa/native/app"
"cfa/native/tunnel"
)
//export queryTunnelState

View File

@@ -7,7 +7,8 @@ import (
"fmt"
"time"
"github.com/Dreamacro/clash/adapter/provider"
P "github.com/Dreamacro/clash/adapter/provider"
"github.com/Dreamacro/clash/constant/provider"
"github.com/Dreamacro/clash/log"
"github.com/Dreamacro/clash/tunnel"
)
@@ -48,7 +49,7 @@ func QueryProviders() []*Provider {
for _, p := range providers {
updatedAt := time.Time{}
if s, ok := p.(provider.UpdatableProvider); ok {
if s, ok := p.(P.UpdatableProvider); ok {
updatedAt = s.UpdatedAt()
}

View File

@@ -4,9 +4,10 @@ import (
"sort"
"strings"
"github.com/Dreamacro/clash/adapter"
"github.com/dlclark/regexp2"
"github.com/Dreamacro/clash/adapter"
"github.com/Dreamacro/clash/adapter/outboundgroup"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/constant/provider"

View File

@@ -52,6 +52,10 @@ object Clash {
Bridge.nativeNotifyDnsChanged(dns.joinToString(separator = ","))
}
fun notifyTimeZoneChanged(name: String, offset: Int) {
Bridge.nativeNotifyTimeZoneChanged(name, offset)
}
fun notifyInstalledAppsChanged(uids: List<Pair<Int, String>>) {
val uidList = uids.joinToString(separator = ",") { "${it.first}:${it.second}" }

View File

@@ -16,6 +16,7 @@ object Bridge {
external fun nativeQueryTrafficNow(): Long
external fun nativeQueryTrafficTotal(): Long
external fun nativeNotifyDnsChanged(dnsList: String)
external fun nativeNotifyTimeZoneChanged(name: String, offset: Int)
external fun nativeNotifyInstalledAppChanged(uidList: String)
external fun nativeStartTun(fd: Int, mtu: Int, dns: String, blocking: String, cb: TunInterface)
external fun nativeStopTun()

View File

@@ -91,6 +91,9 @@ data class ConfigurationOverride(
@SerialName("geoip")
var geoIp: Boolean? = null,
@SerialName("geoip-code")
var geoIpCode: String? = null,
@SerialName("ipcidr")
var ipcidr: List<String>? = null,

View File

@@ -14,8 +14,7 @@ import kotlinx.serialization.modules.SerializersModule
object Parcelizer {
private class ParcelDecoder(private val parcel: Parcel) : Decoder, CompositeDecoder {
@ExperimentalSerializationApi
override val serializersModule: SerializersModule = EmptySerializersModule
override val serializersModule: SerializersModule = SerializersModule {}
@ExperimentalSerializationApi
override fun decodeSequentially(): Boolean = true
@@ -122,8 +121,7 @@ object Parcelizer {
}
private class ParcelEncoder(private val parcel: Parcel) : Encoder, CompositeEncoder {
@ExperimentalSerializationApi
override val serializersModule: SerializersModule = EmptySerializersModule
override val serializersModule: SerializersModule = SerializersModule {}
override fun encodeBooleanElement(
descriptor: SerialDescriptor,

View File

@@ -0,0 +1,45 @@
module premium
go 1.17
require cfa v0.0.0
require (
cfa/blob v0.0.0 // indirect
github.com/Dreamacro/clash v1.7.1 // indirect
github.com/Dreamacro/go-shadowsocks2 v0.1.7 // indirect
github.com/avast/apkparser v0.0.0-20210223100516-186f320f9bfc // indirect
github.com/avast/apkverifier v0.0.0-20210916093748-2146ff7c4b7f // indirect
github.com/dlclark/regexp2 v1.4.0 // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/google/btree v1.0.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/insomniacslk/dhcp v0.0.0-20210827173440-b95caade3eac // indirect
github.com/klauspost/compress v1.11.13 // indirect
github.com/kr328/tun2socket-lwip v0.0.0-20211015022349-94b5374d46e5 // indirect
github.com/miekg/dns v1.1.43 // indirect
github.com/oschwald/geoip2-golang v1.5.0 // indirect
github.com/oschwald/maxminddb-golang v1.8.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/u-root/uio v0.0.0-20210528114334-82958018845c // indirect
go.etcd.io/bbolt v1.3.5 // indirect
go.starlark.net v0.0.0-20210901212718-87f333178d59 // indirect
go.uber.org/atomic v1.9.0 // indirect
go4.org/intern v0.0.0-20210108033219-3eb7198706b2 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20201222180813-1025295fd063 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34 // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gvisor.dev/gvisor v0.0.0-20210904021812-0d58674c658a // indirect
inet.af/netaddr v0.0.0-20210903134321-85fa6c94624e // indirect
)
replace cfa => ../../main/golang
replace github.com/Dreamacro/clash => ./clash
replace cfa/blob => ../../../build/intermediates/golang_blob

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
package main
import _ "cfa/native/all"

View File

@@ -9,7 +9,6 @@ dependencies {
implementation(project(":core"))
implementation(project(":service"))
implementation(kotlin("stdlib-jdk7"))
implementation(deps.kotlin.coroutine)
implementation(deps.androidx.core)
implementation(deps.androidx.appcompat)

View File

@@ -1,399 +0,0 @@
package com.github.kr328.clash.design
import android.content.Context
import android.view.View
import com.github.kr328.clash.core.model.ConfigurationOverride
import com.github.kr328.clash.core.model.LogMessage
import com.github.kr328.clash.core.model.TunnelState
import com.github.kr328.clash.design.adapter.SideloadProviderAdapter
import com.github.kr328.clash.design.databinding.DesignSettingsOverideBinding
import com.github.kr328.clash.design.databinding.DialogPreferenceListBinding
import com.github.kr328.clash.design.dialog.FullScreenDialog
import com.github.kr328.clash.design.model.AppInfo
import com.github.kr328.clash.design.preference.*
import com.github.kr328.clash.design.util.*
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.withContext
import kotlin.coroutines.resume
class OverrideSettingsDesign(
context: Context,
configuration: ConfigurationOverride
) : Design<OverrideSettingsDesign.Request>(context) {
enum class Request {
ResetOverride, EditSideloadGeoip
}
private val binding = DesignSettingsOverideBinding
.inflate(context.layoutInflater, context.root, false)
override val root: View
get() = binding.root
suspend fun requestResetConfirm(): Boolean {
return suspendCancellableCoroutine { ctx ->
val dialog = MaterialAlertDialogBuilder(context)
.setTitle(R.string.reset_override_settings)
.setMessage(R.string.reset_override_settings_message)
.setPositiveButton(R.string.ok) { _, _ -> ctx.resume(true) }
.setNegativeButton(R.string.cancel) { _, _ -> }
.show()
dialog.setOnDismissListener {
if (!ctx.isCompleted)
ctx.resume(false)
}
ctx.invokeOnCancellation {
dialog.dismiss()
}
}
}
suspend fun requestSelectSideload(initial: String, apps: List<AppInfo>): String =
withContext(Dispatchers.Main) {
suspendCancellableCoroutine { ctx ->
val binding = DialogPreferenceListBinding
.inflate(context.layoutInflater, context.root, false)
val adapter = SideloadProviderAdapter(context, apps, initial)
val dialog = FullScreenDialog(context)
dialog.setContentView(binding.root)
binding.surface = dialog.surface
binding.titleView.text = context.getString(R.string.sideload_geoip)
binding.newView.visibility = View.INVISIBLE
binding.mainList.applyLinearAdapter(context, adapter)
binding.resetView.setOnClickListener {
ctx.resume("")
dialog.dismiss()
}
binding.cancelView.setOnClickListener {
dialog.dismiss()
}
binding.okView.setOnClickListener {
ctx.resume(adapter.selectedPackageName)
dialog.dismiss()
}
dialog.setOnDismissListener {
if (!ctx.isCompleted)
ctx.resume(initial)
}
dialog.show()
}
}
init {
binding.self = this
binding.activityBarLayout.applyFrom(context)
binding.scrollRoot.bindAppBarElevation(binding.activityBarLayout)
val booleanValues: Array<Boolean?> = arrayOf(
null,
true,
false
)
val booleanValuesText: Array<Int> = arrayOf(
R.string.dont_modify,
R.string.enabled,
R.string.disabled
)
val screen = preferenceScreen(context) {
category(R.string.general)
editableText(
value = configuration::httpPort,
adapter = NullableTextAdapter.Port,
title = R.string.http_port,
placeholder = R.string.dont_modify,
empty = R.string.disabled,
)
editableText(
value = configuration::socksPort,
adapter = NullableTextAdapter.Port,
title = R.string.socks_port,
placeholder = R.string.dont_modify,
empty = R.string.disabled,
)
editableText(
value = configuration::redirectPort,
adapter = NullableTextAdapter.Port,
title = R.string.redirect_port,
placeholder = R.string.dont_modify,
empty = R.string.disabled,
)
editableText(
value = configuration::tproxyPort,
adapter = NullableTextAdapter.Port,
title = R.string.tproxy_port,
placeholder = R.string.dont_modify,
empty = R.string.disabled,
)
editableText(
value = configuration::mixedPort,
adapter = NullableTextAdapter.Port,
title = R.string.mixed_port,
placeholder = R.string.dont_modify,
empty = R.string.disabled,
)
editableTextList(
value = configuration::authentication,
adapter = TextAdapter.String,
title = R.string.authentication,
placeholder = R.string.dont_modify,
)
selectableList(
value = configuration::allowLan,
values = booleanValues,
valuesText = booleanValuesText,
title = R.string.allow_lan,
)
selectableList(
value = configuration::ipv6,
values = booleanValues,
valuesText = booleanValuesText,
title = R.string.ipv6,
)
editableText(
value = configuration::bindAddress,
adapter = NullableTextAdapter.String,
title = R.string.bind_address,
placeholder = R.string.dont_modify,
empty = R.string.default_
)
selectableList(
value = configuration::mode,
values = arrayOf(
null,
TunnelState.Mode.Direct,
TunnelState.Mode.Global,
TunnelState.Mode.Rule,
),
valuesText = arrayOf(
R.string.dont_modify,
R.string.direct_mode,
R.string.global_mode,
R.string.rule_mode,
),
title = R.string.mode
)
selectableList(
value = configuration::logLevel,
values = arrayOf(
null,
LogMessage.Level.Info,
LogMessage.Level.Warning,
LogMessage.Level.Error,
LogMessage.Level.Debug,
LogMessage.Level.Silent,
),
valuesText = arrayOf(
R.string.dont_modify,
R.string.info,
R.string.warning,
R.string.error,
R.string.debug,
R.string.silent,
),
title = R.string.log_level,
)
editableTextMap(
value = configuration::hosts,
keyAdapter = TextAdapter.String,
valueAdapter = TextAdapter.String,
title = R.string.hosts,
placeholder = R.string.dont_modify,
)
clickable(
title = R.string.sideload_geoip,
summary = R.string.sideload_geoip_summary
) {
clicked {
requests.trySend(Request.EditSideloadGeoip)
}
}
category(R.string.dns)
val dnsDependencies: MutableList<Preference> = mutableListOf()
val dns = selectableList(
value = configuration.dns::enable,
values = arrayOf(
null,
true,
false
),
valuesText = arrayOf(
R.string.dont_modify,
R.string.force_enable,
R.string.use_built_in,
),
title = R.string.strategy
) {
listener = OnChangedListener {
if (configuration.dns.enable == false) {
dnsDependencies.forEach {
it.enabled = false
}
} else {
dnsDependencies.forEach {
it.enabled = true
}
}
}
}
editableText(
value = configuration.dns::listen,
adapter = NullableTextAdapter.String,
title = R.string.listen,
placeholder = R.string.dont_modify,
empty = R.string.disabled,
configure = dnsDependencies::add,
)
selectableList(
value = configuration.app::appendSystemDns,
values = booleanValues,
valuesText = booleanValuesText,
title = R.string.append_system_dns,
configure = dnsDependencies::add,
)
selectableList(
value = configuration.dns::ipv6,
values = booleanValues,
valuesText = booleanValuesText,
title = R.string.ipv6,
configure = dnsDependencies::add,
)
selectableList(
value = configuration.dns::useHosts,
values = booleanValues,
valuesText = booleanValuesText,
title = R.string.use_hosts,
configure = dnsDependencies::add,
)
selectableList(
value = configuration.dns::enhancedMode,
values = arrayOf(
null,
ConfigurationOverride.DnsEnhancedMode.None,
ConfigurationOverride.DnsEnhancedMode.FakeIp,
ConfigurationOverride.DnsEnhancedMode.Mapping
),
valuesText = arrayOf(
R.string.dont_modify,
R.string.disabled,
R.string.fakeip,
R.string.mapping
),
title = R.string.enhanced_mode,
configure = dnsDependencies::add,
)
editableTextList(
value = configuration.dns::nameServer,
adapter = TextAdapter.String,
title = R.string.name_server,
placeholder = R.string.dont_modify,
configure = dnsDependencies::add,
)
editableTextList(
value = configuration.dns::fallback,
adapter = TextAdapter.String,
title = R.string.fallback,
placeholder = R.string.dont_modify,
configure = dnsDependencies::add,
)
editableTextList(
value = configuration.dns::defaultServer,
adapter = TextAdapter.String,
title = R.string.default_name_server,
placeholder = R.string.dont_modify,
configure = dnsDependencies::add,
)
editableTextList(
value = configuration.dns::fakeIpFilter,
adapter = TextAdapter.String,
title = R.string.fakeip_filter,
placeholder = R.string.dont_modify,
configure = dnsDependencies::add,
)
selectableList(
value = configuration.dns.fallbackFilter::geoIp,
values = booleanValues,
valuesText = booleanValuesText,
title = R.string.geoip_fallback,
configure = dnsDependencies::add,
)
editableTextList(
value = configuration.dns.fallbackFilter::domain,
adapter = TextAdapter.String,
title = R.string.domain_fallback,
placeholder = R.string.dont_modify,
configure = dnsDependencies::add,
)
editableTextList(
value = configuration.dns.fallbackFilter::ipcidr,
adapter = TextAdapter.String,
title = R.string.ipcidr_fallback,
placeholder = R.string.dont_modify,
configure = dnsDependencies::add,
)
editableTextMap(
value = configuration.dns::nameserverPolicy,
keyAdapter = TextAdapter.String,
valueAdapter = TextAdapter.String,
title = R.string.name_server_policy,
placeholder = R.string.dont_modify,
configure = dnsDependencies::add,
)
dns.listener?.onChanged()
}
binding.content.addView(screen.root)
}
fun requestClear() {
requests.trySend(Request.ResetOverride)
}
}

View File

@@ -1,113 +0,0 @@
package com.github.kr328.clash.design.component
import android.content.Context
import android.view.MenuItem
import android.view.View
import androidx.appcompat.widget.PopupMenu
import com.github.kr328.clash.core.model.ProxySort
import com.github.kr328.clash.core.model.TunnelState
import com.github.kr328.clash.design.ProxyDesign
import com.github.kr328.clash.design.R
import com.github.kr328.clash.design.store.UiStore
import kotlinx.coroutines.channels.Channel
class ProxyMenu(
context: Context,
menuView: View,
mode: TunnelState.Mode?,
private val uiStore: UiStore,
private val requests: Channel<ProxyDesign.Request>,
private val updateConfig: () -> Unit,
) : PopupMenu.OnMenuItemClickListener {
private val menu = PopupMenu(context, menuView)
fun show() {
menu.show()
}
override fun onMenuItemClick(item: MenuItem): Boolean {
item.isChecked = !item.isChecked
when (item.itemId) {
R.id.not_selectable -> {
uiStore.proxyExcludeNotSelectable = item.isChecked
requests.trySend(ProxyDesign.Request.ReLaunch)
}
R.id.single -> {
uiStore.proxySingleLine = true
updateConfig()
requests.trySend(ProxyDesign.Request.ReloadAll)
}
R.id.multiple -> {
uiStore.proxySingleLine = false
updateConfig()
requests.trySend(ProxyDesign.Request.ReloadAll)
}
R.id.default_ -> {
uiStore.proxySort = ProxySort.Default
requests.trySend(ProxyDesign.Request.ReloadAll)
}
R.id.name -> {
uiStore.proxySort = ProxySort.Title
requests.trySend(ProxyDesign.Request.ReloadAll)
}
R.id.delay -> {
uiStore.proxySort = ProxySort.Delay
requests.trySend(ProxyDesign.Request.ReloadAll)
}
R.id.dont_modify -> {
requests.trySend(ProxyDesign.Request.PatchMode(null))
}
R.id.direct_mode -> {
requests.trySend(ProxyDesign.Request.PatchMode(TunnelState.Mode.Direct))
}
R.id.global_mode -> {
requests.trySend(ProxyDesign.Request.PatchMode(TunnelState.Mode.Global))
}
R.id.rule_mode -> {
requests.trySend(ProxyDesign.Request.PatchMode(TunnelState.Mode.Rule))
}
else -> return false
}
return true
}
init {
menu.menuInflater.inflate(R.menu.menu_proxy, menu.menu)
menu.menu.apply {
findItem(R.id.not_selectable).isChecked = uiStore.proxyExcludeNotSelectable
if (uiStore.proxySingleLine) {
findItem(R.id.single).isChecked = true
} else {
findItem(R.id.multiple).isChecked = true
}
when (uiStore.proxySort) {
ProxySort.Default -> findItem(R.id.default_).isChecked = true
ProxySort.Title -> findItem(R.id.name).isChecked = true
ProxySort.Delay -> findItem(R.id.delay).isChecked = true
}
when (mode) {
null -> findItem(R.id.dont_modify).isChecked = true
TunnelState.Mode.Direct -> findItem(R.id.direct_mode).isChecked = true
TunnelState.Mode.Global -> findItem(R.id.global_mode).isChecked = true
TunnelState.Mode.Rule -> findItem(R.id.rule_mode).isChecked = true
TunnelState.Mode.Script -> throw IllegalStateException("invalid mode")
}
}
menu.setOnMenuItemClickListener(this)
}
}

View File

@@ -1,56 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="@string/filter">
<menu>
<item
android:id="@+id/not_selectable"
android:checkable="true"
android:title="@string/not_selectable" />
</menu>
</item>
<item android:title="@string/mode">
<menu>
<group android:checkableBehavior="single">
<item
android:id="@+id/dont_modify"
android:title="@string/dont_modify" />
<item
android:id="@+id/direct_mode"
android:title="@string/direct_mode" />
<item
android:id="@+id/global_mode"
android:title="@string/global_mode" />
<item
android:id="@+id/rule_mode"
android:title="@string/rule_mode" />
</group>
</menu>
</item>
<item android:title="@string/layout">
<menu>
<group android:checkableBehavior="single">
<item
android:id="@+id/single"
android:title="@string/single" />
<item
android:id="@+id/multiple"
android:title="@string/multiple" />
</group>
</menu>
</item>
<item android:title="@string/sort">
<menu>
<group android:checkableBehavior="single">
<item
android:id="@+id/default_"
android:title="@string/default_" />
<item
android:id="@+id/name"
android:title="@string/name" />
<item
android:id="@+id/delay"
android:title="@string/delay" />
</group>
</menu>
</item>
</menu>

View File

@@ -47,6 +47,17 @@ class HelpDesign(
category(R.string.feedback)
if (BuildConfig.PREMIUM) {
clickable(
title = R.string.google_play,
summary = R.string.google_play_url
) {
clicked {
openLink(Uri.parse(context.getString(R.string.google_play_url)))
}
}
}
clickable(
title = R.string.github_issues,
summary = R.string.github_issues_url
@@ -56,23 +67,25 @@ class HelpDesign(
}
}
category(R.string.sources)
if (!BuildConfig.PREMIUM) {
category(R.string.sources)
clickable(
title = R.string.clash_for_android,
summary = R.string.github_url
) {
clicked {
openLink(Uri.parse(context.getString(R.string.github_url)))
clickable(
title = R.string.clash_for_android,
summary = R.string.github_url
) {
clicked {
openLink(Uri.parse(context.getString(R.string.github_url)))
}
}
}
clickable(
title = R.string.clash_core,
summary = R.string.clash_core_url
) {
clicked {
openLink(Uri.parse(context.getString(R.string.clash_core_url)))
clickable(
title = R.string.clash_core,
summary = R.string.clash_core_url
) {
clicked {
openLink(Uri.parse(context.getString(R.string.clash_core_url)))
}
}
}

View File

@@ -185,24 +185,43 @@ class OverrideSettingsDesign(
empty = R.string.default_
)
selectableList(
value = configuration::mode,
values = arrayOf(
null,
TunnelState.Mode.Direct,
TunnelState.Mode.Global,
TunnelState.Mode.Rule,
TunnelState.Mode.Script
),
valuesText = arrayOf(
R.string.dont_modify,
R.string.direct_mode,
R.string.global_mode,
R.string.rule_mode,
R.string.script_mode
),
title = R.string.mode
)
if (BuildConfig.PREMIUM) {
selectableList(
value = configuration::mode,
values = arrayOf(
null,
TunnelState.Mode.Direct,
TunnelState.Mode.Global,
TunnelState.Mode.Rule,
TunnelState.Mode.Script
),
valuesText = arrayOf(
R.string.dont_modify,
R.string.direct_mode,
R.string.global_mode,
R.string.rule_mode,
R.string.script_mode
),
title = R.string.mode
)
} else {
selectableList(
value = configuration::mode,
values = arrayOf(
null,
TunnelState.Mode.Direct,
TunnelState.Mode.Global,
TunnelState.Mode.Rule
),
valuesText = arrayOf(
R.string.dont_modify,
R.string.direct_mode,
R.string.global_mode,
R.string.rule_mode
),
title = R.string.mode
)
}
selectableList(
value = configuration::logLevel,
@@ -364,6 +383,15 @@ class OverrideSettingsDesign(
configure = dnsDependencies::add,
)
editableText(
value = configuration.dns.fallbackFilter::geoIpCode,
adapter = NullableTextAdapter.String,
title = R.string.geoip_fallback_code,
placeholder = R.string.dont_modify,
empty = R.string.raw_cn,
configure = dnsDependencies::add,
)
editableTextList(
value = configuration.dns.fallbackFilter::domain,
adapter = TextAdapter.String,

View File

@@ -6,6 +6,7 @@ import android.view.View
import androidx.appcompat.widget.PopupMenu
import com.github.kr328.clash.core.model.ProxySort
import com.github.kr328.clash.core.model.TunnelState
import com.github.kr328.clash.design.BuildConfig
import com.github.kr328.clash.design.ProxyDesign
import com.github.kr328.clash.design.R
import com.github.kr328.clash.design.store.UiStore
@@ -88,6 +89,8 @@ class ProxyMenu(
menu.menuInflater.inflate(R.menu.menu_proxy, menu.menu)
menu.menu.apply {
findItem(R.id.script_mode).isVisible = BuildConfig.PREMIUM
findItem(R.id.not_selectable).isChecked = uiStore.proxyExcludeNotSelectable
if (uiStore.proxySingleLine) {

View File

@@ -213,4 +213,5 @@
<string name="name_server_policy">Name Server 策略</string>
<string name="block_loopback">阻止本地回环</string>
<string name="block_loopback_summary">阻止本地回环连接</string>
<string name="geoip_fallback_code">GeoIP Fallback 区域代码</string>
</resources>

View File

@@ -74,6 +74,7 @@
<string name="exit_without_save">Exit without Save</string>
<string name="exit_without_save_warning">All changed will *LOST*</string>
<string name="raw_cn" translatable="false">cn</string>
<string name="disabled">Disabled</string>
<string name="unavailable">Unavailable</string>
<string name="empty_name">Empty Name</string>
@@ -159,6 +160,7 @@
<string name="default_name_server">Default Name Server</string>
<string name="fakeip_filter">Fake-IP Filter</string>
<string name="geoip_fallback">GeoIP Fallback</string>
<string name="geoip_fallback_code">GeoIP Fallback Code</string>
<string name="ipcidr_fallback">IPCIDR Fallback</string>
<string name="domain_fallback">Domain Fallback</string>
<string name="name_server_policy">Name Server Policy</string>

View File

@@ -1,84 +0,0 @@
package com.github.kr328.clash.design
import android.content.Context
import android.net.Uri
import android.view.View
import com.github.kr328.clash.common.compat.preferredLocale
import com.github.kr328.clash.design.databinding.DesignSettingsCommonBinding
import com.github.kr328.clash.design.preference.category
import com.github.kr328.clash.design.preference.clickable
import com.github.kr328.clash.design.preference.preferenceScreen
import com.github.kr328.clash.design.preference.tips
import com.github.kr328.clash.design.util.applyFrom
import com.github.kr328.clash.design.util.bindAppBarElevation
import com.github.kr328.clash.design.util.layoutInflater
import com.github.kr328.clash.design.util.root
class HelpDesign(
context: Context,
openLink: (Uri) -> Unit,
) : Design<Unit>(context) {
private val binding = DesignSettingsCommonBinding
.inflate(context.layoutInflater, context.root, false)
override val root: View
get() = binding.root
init {
binding.surface = surface
binding.activityBarLayout.applyFrom(context)
binding.scrollRoot.bindAppBarElevation(binding.activityBarLayout)
val screen = preferenceScreen(context) {
tips(R.string.tips_help)
category(R.string.document)
clickable(
title = R.string.clash_wiki,
summary = R.string.clash_wiki_url
) {
clicked {
openLink(Uri.parse(context.getString(R.string.clash_wiki_url)))
}
}
category(R.string.feedback)
clickable(
title = R.string.github_issues,
summary = R.string.github_issues_url
) {
clicked {
openLink(Uri.parse(context.getString(R.string.github_issues_url)))
}
}
clickable(
title = R.string.google_play,
summary = R.string.google_play_url
) {
clicked {
openLink(Uri.parse(context.getString(R.string.google_play_url)))
}
}
if (context.resources.configuration.preferredLocale.language == "zh") {
category(R.string.donate)
clickable(
title = R.string.donate,
summary = R.string.donate_url
) {
clicked {
openLink(Uri.parse(context.getString(R.string.donate_url)))
}
}
}
}
binding.content.addView(screen.root)
}
}

View File

@@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx4608m
org.gradle.jvmargs=-Xmx4g -XX:+UseParallelGC -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects

View File

@@ -13,7 +13,6 @@ dependencies {
implementation(project(":core"))
implementation(project(":common"))
implementation(kotlin("stdlib-jdk7"))
implementation(deps.kotlin.coroutine)
implementation(deps.kotlin.serialization.json)
implementation(deps.androidx.core)

View File

@@ -35,6 +35,7 @@ class ClashService : BaseService() {
install(StaticNotificationModule(self))
install(AppListCacheModule(self))
install(TimeZoneModule(self))
install(SuspendModule(self))
try {
@@ -54,8 +55,6 @@ class ClashService : BaseService() {
true
}
network.onEvent {
config.reload()
false
}
}

View File

@@ -40,6 +40,7 @@ class TunService : VpnService(), CoroutineScope by CoroutineScope(Dispatchers.De
install(StaticNotificationModule(self))
install(AppListCacheModule(self))
install(TimeZoneModule(self))
install(SuspendModule(self))
try {
@@ -65,8 +66,6 @@ class TunService : VpnService(), CoroutineScope by CoroutineScope(Dispatchers.De
setUnderlyingNetworks(e.network?.let { arrayOf(it) })
}
config.reload()
false
}
}
@@ -194,23 +193,7 @@ class TunService : VpnService(), CoroutineScope by CoroutineScope(Dispatchers.De
ProxyInfo.buildDirectProxy(
it.address.hostAddress,
it.port,
if (store.bypassPrivateNetwork)
listOf(
"localhost",
"*.local",
"127.*",
"10.*",
"172.16.*",
"172.17.*",
"172.18.*",
"172.19.*",
"172.2*",
"172.30.*",
"172.31.*",
"192.168.*"
)
else
emptyList()
HTTP_PROXY_BLACK_LIST + if (store.bypassPrivateNetwork) HTTP_PROXY_LOCAL_LIST else emptyList()
)
)
}
@@ -240,5 +223,21 @@ class TunService : VpnService(), CoroutineScope by CoroutineScope(Dispatchers.De
private const val TUN_DNS = "172.19.0.2"
private const val NET_ANY = "0.0.0.0"
private const val NET_SUBNET_LOOPBACK = "127.0.0.0/8"
private val HTTP_PROXY_LOCAL_LIST: List<String> = listOf(
"localhost",
"*.local",
"127.*",
"10.*",
"172.16.*",
"172.17.*",
"172.18.*",
"172.19.*",
"172.2*",
"172.30.*",
"172.31.*",
"192.168.*"
)
private val HTTP_PROXY_BLACK_LIST: List<String> = listOf("*zhihu.com", "*zhimg.com")
}
}
}

View File

@@ -73,8 +73,4 @@ class ConfigurationModule(service: Service) : Module<ConfigurationModule.LoadExc
}
}
}
fun reload() {
reload.trySend(Unit)
}
}

View File

@@ -80,8 +80,6 @@ class NetworkObserveModule(service: Service) :
}
try {
delay(TimeUnit.SECONDS.toMillis(10))
while (true) {
val network = networks.receive()

View File

@@ -0,0 +1,22 @@
package com.github.kr328.clash.service.clash.module
import android.app.Service
import android.content.Intent
import com.github.kr328.clash.core.Clash
import java.util.*
class TimeZoneModule(service: Service) : Module<Unit>(service) {
override suspend fun run() {
val timeZones = receiveBroadcast {
addAction(Intent.ACTION_TIMEZONE_CHANGED)
}
while (true) {
val timeZone = TimeZone.getDefault()
Clash.notifyTimeZoneChanged(timeZone.id, timeZone.rawOffset)
timeZones.receive()
}
}
}

View File

@@ -14,22 +14,22 @@ include(":hideapi")
dependencyResolutionManagement {
versionCatalogs {
create("deps") {
val agp = "7.0.2"
val ksp = "1.5.30-1.0.0-beta09"
val kotlin = "1.5.30"
val golang = "1.0.1"
val coroutine = "1.5.0"
val coreKtx = "1.5.0"
val activity = "1.2.3"
val fragment = "1.3.4"
val appcompat = "1.3.0"
val agp = "7.0.3"
val ksp = "1.5.31-1.0.0"
val kotlin = "1.5.31"
val golang = "1.0.4"
val coroutine = "1.5.2"
val coreKtx = "1.6.0"
val activity = "1.3.1"
val fragment = "1.3.6"
val appcompat = "1.3.1"
val coordinator = "1.1.0"
val recyclerview = "1.2.1"
val viewpager = "1.0.0"
val material = "1.3.0"
val appcenter = "4.2.0"
val serialization = "1.2.1"
val kaidl = "1.14"
val material = "1.4.0"
val appcenter = "4.3.1"
val serialization = "1.3.0"
val kaidl = "1.15"
val room = "2.3.0"
val multiprocess = "1.0.0"