mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdd0e3dd30 | ||
|
|
5823955c71 | ||
|
|
714c9a554f | ||
|
|
e621324b48 | ||
|
|
dfe1e7ecd9 | ||
|
|
4c3380d822 | ||
|
|
1d68516cdb | ||
|
|
821bb49914 | ||
|
|
c95993a629 | ||
|
|
e6495f5e1f | ||
|
|
c104942b5f | ||
|
|
59835667aa | ||
|
|
8a98eea8fa | ||
|
|
3dc20b9e70 | ||
|
|
d8ab6fd755 | ||
|
|
cc499a7897 | ||
|
|
76f5261b20 | ||
|
|
6a506b761f | ||
|
|
fe966f9c5d | ||
|
|
bcf7f793ec | ||
|
|
75de6ce041 | ||
|
|
4417a85ef7 | ||
|
|
9e0b67c04a | ||
|
|
8cd203e7b0 | ||
|
|
211160f7f8 | ||
|
|
2afc7262eb | ||
|
|
94a0282c70 | ||
|
|
96b78829ab | ||
|
|
35d5a90b2a | ||
|
|
50d73ad498 | ||
|
|
d1f8bc3062 | ||
|
|
d3353b1aa5 | ||
|
|
cd48fb4e08 | ||
|
|
f70738ecf5 | ||
|
|
2d63466597 | ||
|
|
ecf67443fb | ||
|
|
43987ad111 | ||
|
|
5fbd6c6196 | ||
|
|
1ec7f1f7e9 | ||
|
|
c5104c241a | ||
|
|
021ba3519d | ||
|
|
119f74cd05 | ||
|
|
f0b61c9e1f | ||
|
|
a573631068 | ||
|
|
a12444b258 | ||
|
|
17257228a9 | ||
|
|
53b6a9dfc1 | ||
|
|
c45f8ddfc3 | ||
|
|
e04c9c15ff | ||
|
|
d5cb363579 | ||
|
|
0748021ffa | ||
|
|
e958e7f675 | ||
|
|
68113e694e |
18
.github/ISSUE_TEMPLATE/01-bug-report-en.md
vendored
18
.github/ISSUE_TEMPLATE/01-bug-report-en.md
vendored
@@ -7,6 +7,10 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Be sure to put a clear title after [BUG] in the text box above -->
|
||||
<!-- Be sure to put a clear title after [BUG] in the text box above -->
|
||||
<!-- Be sure to put a clear title after [BUG] in the text box above -->
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
@@ -23,15 +27,12 @@ A clear and concise description of what you expected to happen.
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Logs**
|
||||
if applicable, add logs to help detect problem
|
||||
|
||||
**Device Info (please complete the following information):**
|
||||
|
||||
- Device: [e.g. Pixel 4]
|
||||
- ROM: [e.g: AOSP]
|
||||
- ROM Version:
|
||||
- Android Version [e.g. Oreo]
|
||||
- Android Version [e.g. 10]
|
||||
|
||||
**Application Info (please complete the following information):**
|
||||
|
||||
@@ -40,4 +41,11 @@ if applicable, add logs to help detect problem
|
||||
- Distribution Channel: [e.g. Google Play]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
Add any other context about the problem here.
|
||||
|
||||
<!--
|
||||
*Logs*
|
||||
if applicable, upload logs to help detect problem
|
||||
|
||||
`Open App` -> `Support` -> `Feedback` -> `Upload Logcat`
|
||||
-->
|
||||
@@ -7,6 +7,10 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Be sure to put a clear title after [Feature Request] in the text box above -->
|
||||
<!-- Be sure to put a clear title after [Feature Request] in the text box above -->
|
||||
<!-- Be sure to put a clear title after [Feature Request] in the text box above -->
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
|
||||
19
.github/ISSUE_TEMPLATE/03-bug-report-zh-cn.md
vendored
19
.github/ISSUE_TEMPLATE/03-bug-report-zh-cn.md
vendored
@@ -7,6 +7,10 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- 请务必在上方文本框处 [BUG] 后填入清晰明了的标题 -->
|
||||
<!-- 请务必在上方文本框处 [BUG] 后填入清晰明了的标题 -->
|
||||
<!-- 请务必在上方文本框处 [BUG] 后填入清晰明了的标题 -->
|
||||
|
||||
**描述出现的错误**
|
||||
请简洁的描述你遇到的错误
|
||||
|
||||
@@ -23,14 +27,10 @@ assignees: ''
|
||||
**屏幕截图**
|
||||
如果适用, 上传屏幕截图以帮助描述错误
|
||||
|
||||
**日志**
|
||||
|
||||
如果适用, 上传日志以帮助侦测错误
|
||||
|
||||
**设备信息 (请完成一下信息):**
|
||||
**设备信息 (请完成以下信息):**
|
||||
- 机型: [例如: Pixel 4]
|
||||
- 系统/ROM: [例如: MIUI 11]
|
||||
- Android 版本 [例如: Oreo]
|
||||
- Android 版本 [例如: 10]
|
||||
- ROM版本 [例如: 20.3.19]
|
||||
|
||||
**应用信息**
|
||||
@@ -40,3 +40,10 @@ assignees: ''
|
||||
|
||||
**附加信息**
|
||||
其他的可能与改错误相关的信息
|
||||
|
||||
<!--
|
||||
*日志*
|
||||
如果适用, 上传日志以帮助侦测错误
|
||||
|
||||
`打开应用` -> `支持` -> `反馈` -> `上传日志`
|
||||
-->
|
||||
@@ -7,6 +7,10 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- 请务必在上方文本框处 [Feature Request] 后填入清晰明了的标题 -->
|
||||
<!-- 请务必在上方文本框处 [Feature Request] 后填入清晰明了的标题 -->
|
||||
<!-- 请务必在上方文本框处 [Feature Request] 后填入清晰明了的标题 -->
|
||||
|
||||
**功能描述**
|
||||
请清晰的描述你想要的功能
|
||||
|
||||
|
||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
blank_issues_enabled: false
|
||||
@@ -1,4 +1,5 @@
|
||||
import java.util.*
|
||||
import java.security.*
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
@@ -121,6 +122,18 @@ task("injectAppCenterKey") {
|
||||
}
|
||||
}
|
||||
|
||||
task("injectPackageNameBase64") {
|
||||
doFirst {
|
||||
val packageName = android.defaultConfig.applicationId ?: return@doFirst
|
||||
|
||||
val base64 = Base64.getEncoder().encodeToString(packageName.toByteArray(Charsets.UTF_8))
|
||||
|
||||
android.buildTypes.forEach {
|
||||
it.buildConfigField("String", "PACKAGE_NAME_BASE64", "\"$base64\"")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
tasks["preBuild"].dependsOn(tasks["injectAppCenterKey"])
|
||||
tasks["preBuild"].dependsOn(tasks["injectAppCenterKey"], tasks["injectPackageNameBase64"])
|
||||
}
|
||||
@@ -16,11 +16,9 @@ import kotlinx.android.synthetic.main.activity_log_viewer.*
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import java.io.File
|
||||
import kotlin.streams.toList
|
||||
|
||||
class LogViewerActivity : BaseActivity() {
|
||||
private val pauseMutex = Mutex()
|
||||
private var pollingThread: Thread? = null
|
||||
private val connection = object : ServiceConnection {
|
||||
override fun onServiceDisconnected(name: ComponentName?) {
|
||||
finish()
|
||||
@@ -49,12 +47,6 @@ class LogViewerActivity : BaseActivity() {
|
||||
startFileMode(file.toFile())
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
||||
pollingThread?.interrupt()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
|
||||
@@ -79,6 +71,7 @@ class LogViewerActivity : BaseActivity() {
|
||||
mainList.itemAnimator?.removeDuration = 100
|
||||
|
||||
stop.setOnClickListener {
|
||||
unbindService(connection)
|
||||
stopService(LogcatService::class.intent)
|
||||
finish()
|
||||
}
|
||||
@@ -92,15 +85,15 @@ class LogViewerActivity : BaseActivity() {
|
||||
launch {
|
||||
val items = withContext(Dispatchers.IO) {
|
||||
try {
|
||||
file.readText()
|
||||
.split("\n")
|
||||
.parallelStream()
|
||||
.map { it.trim() }
|
||||
.filter { it.isNotEmpty() && !it.startsWith("#") }
|
||||
.map { it.split(" ", limit = 3) }
|
||||
.filter { it.size == 3 }
|
||||
.map { LogEvent(LogEvent.Level.valueOf(it[1]), it[2], it[0].toLong()) }
|
||||
.toList()
|
||||
file.bufferedReader().useLines { lines ->
|
||||
lines
|
||||
.map { it.trim() }
|
||||
.filter { it.isNotEmpty() && !it.startsWith("#") }
|
||||
.map { it.split(" ", limit = 3) }
|
||||
.filter { it.size == 3 }
|
||||
.map { LogEvent(LogEvent.Level.valueOf(it[1]), it[2], it[0].toLong()) }
|
||||
.toList()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
showSnackbarException(getString(R.string.open_log_failure), e.message)
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.github.kr328.clash.adapter.LogFileAdapter
|
||||
import com.github.kr328.clash.common.utils.intent
|
||||
import com.github.kr328.clash.common.utils.startForegroundServiceCompat
|
||||
import com.github.kr328.clash.core.event.LogEvent
|
||||
import com.github.kr328.clash.design.common.Category
|
||||
import com.github.kr328.clash.design.view.CommonUiLayout
|
||||
import com.github.kr328.clash.model.LogFile
|
||||
@@ -24,12 +25,15 @@ import kotlinx.android.synthetic.main.activity_logs.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.FileInputStream
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class LogsActivity : BaseActivity() {
|
||||
companion object {
|
||||
const val REQUEST_CODE = 50000
|
||||
|
||||
private val LOG_EXPORT_DATE_FORMAT = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH)
|
||||
private val LOG_EXPORT_TIME_FORMAT = SimpleDateFormat("HH:mm:ss", Locale.ENGLISH)
|
||||
}
|
||||
|
||||
private var lastWriteFile: LogFile? = null
|
||||
@@ -102,9 +106,31 @@ class LogsActivity : BaseActivity() {
|
||||
|
||||
launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
contentResolver.openOutputStream(url)?.use { output ->
|
||||
FileInputStream(logsDir.resolve(file.fileName)).use { input ->
|
||||
input.copyTo(output)
|
||||
contentResolver.openOutputStream(url)?.bufferedWriter()?.use { output ->
|
||||
output.write("# Logcat on " + LOG_EXPORT_DATE_FORMAT.format(Date(file.date)) + "\n")
|
||||
|
||||
logsDir.resolve(file.fileName).bufferedReader().useLines { lines ->
|
||||
lines.map { it.trim() }
|
||||
.filter { it.isNotEmpty() && !it.startsWith("#") }
|
||||
.map { it.split(" ", limit = 3) }
|
||||
.filter { it.size == 3 }
|
||||
.map {
|
||||
LogEvent(
|
||||
LogEvent.Level.valueOf(it[1]),
|
||||
it[2],
|
||||
it[0].toLong()
|
||||
)
|
||||
}
|
||||
.forEach {
|
||||
output.write(
|
||||
String.format(
|
||||
"%s |%s| %s\n",
|
||||
LOG_EXPORT_TIME_FORMAT.format(Date(it.time)),
|
||||
it.level.toString(),
|
||||
it.message
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class MainApplication : Application() {
|
||||
if (!report.stackTrace.contains("DeadObjectException"))
|
||||
return mutableListOf()
|
||||
|
||||
val logcat = LogcatDumper.dump().joinToString(separator = "\n")
|
||||
val logcat = LogcatDumper.dumpCrash()
|
||||
|
||||
return mutableListOf(
|
||||
ErrorAttachmentLog.attachmentWithText(logcat, "logcat.txt")
|
||||
|
||||
@@ -4,9 +4,19 @@ import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.github.kr328.clash.dump.LogcatDumper
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.microsoft.appcenter.crashes.Crashes
|
||||
import com.microsoft.appcenter.crashes.ingestion.models.ErrorAttachmentLog
|
||||
import kotlinx.android.synthetic.main.activity_support.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class SupportActivity : BaseActivity() {
|
||||
class UserRequestTrackException: Exception()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -46,6 +56,20 @@ class SupportActivity : BaseActivity() {
|
||||
|
||||
category(text = getString(R.string.feedback))
|
||||
|
||||
option(
|
||||
title = getString(R.string.upload_logcat),
|
||||
summary = getString(R.string.upload_logcat_summary)
|
||||
) {
|
||||
onClick {
|
||||
AlertDialog.Builder(this@SupportActivity)
|
||||
.setTitle(R.string.upload_logcat)
|
||||
.setMessage(R.string.upload_logcat_warn)
|
||||
.setNegativeButton(R.string.cancel) {_, _ -> }
|
||||
.setPositiveButton(R.string.ok) {_, _ -> upload() }
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
option(
|
||||
title = getString(R.string.github_issues),
|
||||
summary = getString(R.string.github_issues_url)
|
||||
@@ -77,4 +101,19 @@ class SupportActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun upload() {
|
||||
launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
val attachment = ErrorAttachmentLog
|
||||
.attachmentWithText(LogcatDumper.dumpAll(), "logcat.txt")
|
||||
|
||||
Crashes.trackError(UserRequestTrackException(), null, listOf(attachment))
|
||||
}
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
Snackbar.make(rootView, R.string.uploaded, Snackbar.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,37 @@
|
||||
package com.github.kr328.clash.dump
|
||||
|
||||
object LogcatDumper {
|
||||
fun dump(): List<String> {
|
||||
fun dumpCrash(): String {
|
||||
return try {
|
||||
val process =
|
||||
Runtime.getRuntime().exec(arrayOf("logcat", "-d", "-s", "-v", "raw", "Go"))
|
||||
Runtime.getRuntime().exec(arrayOf("logcat", "-d", "-s", "Go", "AndroidRuntime", "DEBUG"))
|
||||
|
||||
val result = process.inputStream.bufferedReader().useLines {
|
||||
var list = mutableListOf<String>()
|
||||
var capture = false
|
||||
|
||||
it.forEach { line ->
|
||||
if (line.startsWith("panic")) {
|
||||
capture = true
|
||||
|
||||
list = mutableListOf()
|
||||
}
|
||||
|
||||
if (capture)
|
||||
list.add(line)
|
||||
}
|
||||
|
||||
list
|
||||
val result = process.inputStream.use {
|
||||
it.reader().readText()
|
||||
}
|
||||
|
||||
process.waitFor()
|
||||
|
||||
result
|
||||
} catch (e: Exception) {
|
||||
emptyList()
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
fun dumpAll(): String {
|
||||
return try {
|
||||
val process =
|
||||
Runtime.getRuntime().exec(arrayOf("logcat", "-d"))
|
||||
|
||||
val result = process.inputStream.use {
|
||||
it.reader().readText()
|
||||
}
|
||||
|
||||
process.waitFor()
|
||||
|
||||
result
|
||||
} catch (e: Exception) {
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ class ProfileEditFragment(
|
||||
private val type: Type,
|
||||
private val source: String?
|
||||
) : Fragment() {
|
||||
private var root: CommonUiLayout? = null
|
||||
|
||||
var isModified = false
|
||||
|
||||
companion object {
|
||||
@@ -46,6 +48,7 @@ class ProfileEditFragment(
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return CommonUiLayout(requireContext()).apply {
|
||||
root = this
|
||||
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
|
||||
build {
|
||||
@@ -111,12 +114,14 @@ class ProfileEditFragment(
|
||||
|
||||
if (s.isBlank()) {
|
||||
content = ""
|
||||
interval = 0
|
||||
return@onTextChanged
|
||||
}
|
||||
|
||||
val value = s.toIntOrNull()
|
||||
if (value == null || value < 15) {
|
||||
content = ""
|
||||
interval = 0
|
||||
Snackbar.make(view, R.string.invalid_interval, Snackbar.LENGTH_LONG)
|
||||
.show()
|
||||
return@onTextChanged
|
||||
@@ -143,16 +148,16 @@ class ProfileEditFragment(
|
||||
if (resultCode != Activity.RESULT_OK || data == null)
|
||||
return
|
||||
|
||||
val layout = view as CommonUiLayout
|
||||
root?.apply {
|
||||
data.data?.apply {
|
||||
screen.requireElement<TextInput>(KEY_URL).content = this.toString()
|
||||
}
|
||||
|
||||
data.data?.apply {
|
||||
layout.screen.requireElement<TextInput>(KEY_URL).content = this.toString()
|
||||
}
|
||||
|
||||
data.getStringExtra(Constants.URL_PROVIDER_INTENT_EXTRA_NAME)?.also {
|
||||
layout.screen.requireElement<TextInput>(KEY_NAME).apply {
|
||||
if (content.isBlank())
|
||||
content = it
|
||||
data.getStringExtra(Constants.URL_PROVIDER_INTENT_EXTRA_NAME)?.also {
|
||||
screen.requireElement<TextInput>(KEY_NAME).apply {
|
||||
if (content.isBlank())
|
||||
content = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,7 +168,9 @@ class ProfileEditFragment(
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
|
||||
(view as CommonUiLayout?)?.screen?.saveState(outState)
|
||||
root?.apply {
|
||||
screen.saveState(outState)
|
||||
}
|
||||
}
|
||||
|
||||
private fun openUrlProvider(): Boolean {
|
||||
@@ -182,11 +189,13 @@ class ProfileEditFragment(
|
||||
else -> return false
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Snackbar.make(
|
||||
view as ViewGroup,
|
||||
R.string.start_url_provider_failure,
|
||||
Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
root?.apply {
|
||||
Snackbar.make(
|
||||
this,
|
||||
R.string.start_url_provider_failure,
|
||||
Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
@@ -8,8 +8,10 @@ import android.content.ServiceConnection
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.IBinder
|
||||
import android.util.Base64
|
||||
import androidx.core.content.edit
|
||||
import com.github.kr328.clash.ApkBrokenActivity
|
||||
import com.github.kr328.clash.BuildConfig
|
||||
import com.github.kr328.clash.Constants
|
||||
import com.github.kr328.clash.common.Global
|
||||
import com.github.kr328.clash.common.utils.intent
|
||||
@@ -88,7 +90,7 @@ object Remote {
|
||||
|
||||
val application = Global.application
|
||||
|
||||
if ( it ) {
|
||||
if (it) {
|
||||
handler.removeMessages(0)
|
||||
|
||||
GlobalScope.launch {
|
||||
@@ -152,6 +154,38 @@ object Remote {
|
||||
if (sp.getLong(Constants.PREFERENCE_KEY_LAST_INSTALL, 0) == pkg.lastUpdateTime)
|
||||
return true
|
||||
|
||||
val pkgName: String = try {
|
||||
application::class.java.getMethod(
|
||||
String(
|
||||
charArrayOf(
|
||||
'g',
|
||||
'e',
|
||||
't',
|
||||
'P',
|
||||
'a',
|
||||
'c',
|
||||
'k',
|
||||
'a',
|
||||
'g',
|
||||
'e',
|
||||
'N',
|
||||
'a',
|
||||
'm',
|
||||
'e'
|
||||
)
|
||||
)
|
||||
).invoke(application)?.toString()
|
||||
} catch (e: Exception) {
|
||||
Log.w("getPackageName failure", e)
|
||||
null
|
||||
} ?: application.packageName
|
||||
|
||||
val packageNameBase64 = Base64
|
||||
.encodeToString(pkgName.toByteArray(Charsets.UTF_8), Base64.NO_WRAP)
|
||||
|
||||
if (packageNameBase64 != BuildConfig.PACKAGE_NAME_BASE64)
|
||||
return false
|
||||
|
||||
val info = application.applicationInfo
|
||||
val sources =
|
||||
info.splitSourceDirs ?: arrayOf(info.sourceDir) ?: return false
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.github.kr328.clash.ApkBrokenActivity
|
||||
import com.github.kr328.clash.common.utils.intent
|
||||
import com.github.kr328.clash.service.Constants
|
||||
import com.github.kr328.clash.service.ServiceStatusProvider
|
||||
import java.lang.Exception
|
||||
|
||||
object RemoteUtils {
|
||||
fun detectClashRunning(context: Context): Boolean {
|
||||
@@ -24,7 +25,7 @@ object RemoteUtils {
|
||||
)
|
||||
|
||||
return pong != null
|
||||
} catch (e: IllegalArgumentException) {
|
||||
} catch (e: Exception) {
|
||||
context.startActivity(ApkBrokenActivity::class.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||
|
||||
return false
|
||||
@@ -46,7 +47,7 @@ object RemoteUtils {
|
||||
)
|
||||
|
||||
return pong?.getString("name")
|
||||
} catch (e: IllegalArgumentException) {
|
||||
} catch (e: Exception) {
|
||||
context.startActivity(ApkBrokenActivity::class.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||
|
||||
return null
|
||||
|
||||
@@ -131,4 +131,8 @@
|
||||
<string name="tips_support"><![CDATA[Clash for Android 是一个<strong>免费开源</strong>的项目<br /> 我们<strong>不提供</strong>任何代理服务<br />请务必<strong>不要</strong>反馈非应用自身引起的问题]]></string>
|
||||
<string name="donate">捐赠</string>
|
||||
<string name="clone_profile">复制配置</string>
|
||||
<string name="upload_logcat">上传日志</string>
|
||||
<string name="upload_logcat_summary">上传日志以帮助我们侦测问题</string>
|
||||
<string name="upload_logcat_warn">请注意, 上传的日志可能包含个人敏感信息, 仍要继续吗?</string>
|
||||
<string name="uploaded">已上传</string>
|
||||
</resources>
|
||||
@@ -173,4 +173,9 @@
|
||||
<string name="missing_vpn_component">Missing VPN Components</string>
|
||||
|
||||
<string name="profile_not_found">Profile not found</string>
|
||||
|
||||
<string name="upload_logcat">Upload Logcat</string>
|
||||
<string name="upload_logcat_summary">Upload logcat to help us detect issues</string>
|
||||
<string name="upload_logcat_warn">Please note that the uploaded logs may contain personally sensitive information, do you still want to continue?</string>
|
||||
<string name="uploaded">Uploaded</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
val kotlinVersion = "1.3.71"
|
||||
val kotlinVersion = "1.3.72"
|
||||
|
||||
rootProject.extra.apply {
|
||||
this["gBuildToolsVersion"] = "29.0.3"
|
||||
@@ -10,8 +10,8 @@ buildscript {
|
||||
this["gMinSdkVersion"] = 24
|
||||
this["gTargetSdkVersion"] = 29
|
||||
|
||||
this["gVersionCode"] = 10204
|
||||
this["gVersionName"] = "1.2.4"
|
||||
this["gVersionCode"] = 10213
|
||||
this["gVersionName"] = "1.2.13"
|
||||
|
||||
this["gKotlinVersion"] = kotlinVersion
|
||||
this["gKotlinCoroutineVersion"] = "1.3.5"
|
||||
@@ -30,7 +30,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:4.0.0-beta04")
|
||||
classpath("com.android.tools.build:gradle:4.0.0-beta05")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
classpath("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
|
||||
}
|
||||
|
||||
@@ -77,6 +77,6 @@ repositories {
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
tasks["clean"].dependsOn(tasks["resetGolangMode"])
|
||||
tasks["clean"].dependsOn(tasks["resetGolangPathMode"])
|
||||
tasks["preBuild"].dependsOn(tasks["extractSources"], tasks["downloadGeoipDatabase"])
|
||||
}
|
||||
@@ -145,7 +145,7 @@ task("generateClashBindSources") {
|
||||
}
|
||||
}
|
||||
|
||||
task("bindClashCore") {
|
||||
task("assembleClashCore") {
|
||||
dependsOn(tasks["generateClashBindSources"])
|
||||
|
||||
onlyIf {
|
||||
@@ -169,14 +169,8 @@ task("bindClashCore") {
|
||||
}
|
||||
|
||||
task("extractSources", type = Copy::class) {
|
||||
dependsOn(tasks["bindClashCore"])
|
||||
dependsOn(tasks["assembleClashCore"])
|
||||
|
||||
doFirst {
|
||||
buildDir.resolve(Constants.OUTPUT_PATH).apply {
|
||||
resolve("jniLibs").deleteRecursively()
|
||||
resolve("classes").deleteRecursively()
|
||||
}
|
||||
}
|
||||
from(zipTree(buildDir.resolve(Constants.GOLANG_OUTPUT))) {
|
||||
include("**/*.so")
|
||||
eachFile {
|
||||
@@ -192,6 +186,8 @@ task("extractSources", type = Copy::class) {
|
||||
}
|
||||
|
||||
task("downloadGeoipDatabase") {
|
||||
dependsOn(tasks["extractSources"])
|
||||
|
||||
onlyIf {
|
||||
val file = buildDir.resolve(Constants.OUTPUT_PATH).resolve("assets/Country.mmdb")
|
||||
|
||||
@@ -211,7 +207,7 @@ task("downloadGeoipDatabase") {
|
||||
}
|
||||
}
|
||||
|
||||
task("resetGolangMode", type = Exec::class) {
|
||||
task("resetGolangPathMode", type = Exec::class) {
|
||||
onlyIf {
|
||||
!Os.isFamily(Os.FAMILY_WINDOWS)
|
||||
}
|
||||
|
||||
@@ -106,23 +106,42 @@ func QueryAllProxyGroups(collection ProxyGroupCollection) {
|
||||
func SetSelectedProxy(name, proxy string) bool {
|
||||
p := tunnel.Proxies()[name]
|
||||
if p == nil {
|
||||
log.Infoln("Set %s: Not such proxy group", name)
|
||||
return false
|
||||
}
|
||||
|
||||
pb, ok := p.(*outbound.Proxy)
|
||||
if !ok {
|
||||
log.Infoln("Set %s: Not a proxy object", name)
|
||||
return false
|
||||
}
|
||||
|
||||
selector, ok := pb.ProxyAdapter.(*outboundgroup.Selector)
|
||||
if !ok {
|
||||
log.Infoln("Set %s: Not a selector group", name)
|
||||
return false
|
||||
}
|
||||
|
||||
selected := selector.Now()
|
||||
if selected == proxy {
|
||||
log.Infoln("Set " + name + " -> " + proxy)
|
||||
return true
|
||||
}
|
||||
|
||||
if err := selector.Set(proxy); err != nil {
|
||||
log.Infoln("Set %s: %s", name, err.Error())
|
||||
return false
|
||||
}
|
||||
|
||||
for _, conn := range tunnel.DefaultManager.Snapshot().Connections {
|
||||
for _, p := range conn.Chain() {
|
||||
if p == name {
|
||||
_ = conn.Close()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Infoln("Set " + name + " -> " + proxy)
|
||||
|
||||
return true
|
||||
|
||||
@@ -20,12 +20,14 @@ func init() {
|
||||
dialer.ListenConfigHook = onNewListenConfig
|
||||
}
|
||||
|
||||
func onNewDialer(dialer *net.Dialer) {
|
||||
func onNewDialer(dialer *net.Dialer) error {
|
||||
dialer.Control = onNewSocket
|
||||
return nil
|
||||
}
|
||||
|
||||
func onNewListenConfig(listen *net.ListenConfig) {
|
||||
func onNewListenConfig(listen *net.ListenConfig) error {
|
||||
listen.Control = onNewSocket
|
||||
return nil
|
||||
}
|
||||
|
||||
func onNewSocket(_, _ string, c syscall.RawConn) error {
|
||||
|
||||
Submodule core/src/main/golang/clash updated: f48ce6fc8e...b21f564efd
@@ -7,6 +7,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
@@ -29,20 +30,29 @@ var client = &http.Client{
|
||||
|
||||
client, server := net.Pipe()
|
||||
|
||||
tunnel.Add(inbound.NewSocket(socks5.ParseAddr(address), server, constant.HTTP, constant.TCP))
|
||||
tunnel.Add(inbound.NewSocket(socks5.ParseAddr(address), server, constant.HTTP))
|
||||
|
||||
return client, nil
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func fetchRemote(url string) ([]byte, error) {
|
||||
request, err := http.NewRequest("GET", url, nil)
|
||||
func fetchRemote(sUrl string) ([]byte, error) {
|
||||
uri, err := url.Parse(sUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
request, err := http.NewRequest("GET", uri.String(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
request.Header.Set("User-Agent", "ClashForAndroid/"+ApplicationVersion)
|
||||
if user := uri.User; user != nil {
|
||||
password, _ := user.Password()
|
||||
request.SetBasicAuth(user.Username(), password)
|
||||
}
|
||||
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
@@ -87,14 +97,10 @@ func PullLocal(fd int, output, baseDir string) error {
|
||||
}
|
||||
|
||||
func save(data []byte, output, baseDir string) error {
|
||||
cfg, err := parseConfig(data, baseDir)
|
||||
_, err := parseConfig(data, baseDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, v := range cfg.Providers {
|
||||
_ = v.Destroy()
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(output, data, defaultFileMode)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ go 1.13
|
||||
|
||||
require (
|
||||
github.com/Dreamacro/clash v0.0.0 // local
|
||||
github.com/kr328/tun2socket v0.0.0-20200415021819-256b721ac9a4
|
||||
github.com/kr328/tun2socket v0.0.0-20200429021948-00f70a9cb042
|
||||
github.com/miekg/dns v1.1.29
|
||||
)
|
||||
|
||||
|
||||
@@ -3,17 +3,22 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/go-chi/chi v4.0.3+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
|
||||
github.com/go-chi/chi v4.1.1+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
|
||||
github.com/go-chi/cors v1.0.1/go.mod h1:K2Yje0VW/SJzxiyMYu6iPQYa7hMjQX2i/F491VChg1I=
|
||||
github.com/go-chi/cors v1.1.1/go.mod h1:K2Yje0VW/SJzxiyMYu6iPQYa7hMjQX2i/F491VChg1I=
|
||||
github.com/go-chi/render v1.0.1/go.mod h1:pq4Rr7HbnsdaeHagklXub+p6Wd16Af5l9koip1OvJns=
|
||||
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr328/tun2socket v0.0.0-20200415021819-256b721ac9a4/go.mod h1:FWfSixjrLgtK+dHkDoN6lHMNhvER24gnjUZd/wt8Z9o=
|
||||
github.com/kr328/tun2socket v0.0.0-20200423032118-6f5116368120/go.mod h1:FWfSixjrLgtK+dHkDoN6lHMNhvER24gnjUZd/wt8Z9o=
|
||||
github.com/kr328/tun2socket v0.0.0-20200429021948-00f70a9cb042 h1:Orn4L0/9fcf2ppxI3mmPl5q1xKB1P5roRmXUkc6adBw=
|
||||
github.com/kr328/tun2socket v0.0.0-20200429021948-00f70a9cb042/go.mod h1:FWfSixjrLgtK+dHkDoN6lHMNhvER24gnjUZd/wt8Z9o=
|
||||
github.com/miekg/dns v1.1.29/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
|
||||
github.com/oschwald/geoip2-golang v1.4.0/go.mod h1:8QwxJvRImBH+Zl6Aa6MaIcs5YdlZSTKtzmPGzQqi9ng=
|
||||
github.com/oschwald/maxminddb-golang v1.6.0/go.mod h1:DUJFucBg2cvqx42YmDa/+xHvb0elJtOm3o4aFQ/nb/w=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
@@ -23,11 +28,13 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200320181102-891825fb96df/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200320220750-118fecf932d8/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -35,6 +42,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191224085550-c709ea063b76/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
@@ -56,7 +56,7 @@ func hijackTCPDNS(conn net.Conn, endpoint *binding.Endpoint) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if !hijackAddress.Equal(net.IPv4zero) && !hijackAddress.Equal(net.IPv6zero) && !hijackAddress.Equal(endpoint.Target.IP) {
|
||||
if !hijackAddress.Equal(net.IPv4zero) && !hijackAddress.Equal(endpoint.Target.IP) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ func hijackDNS(payload []byte, endpoint *binding.Endpoint, sender redirect.UDPSe
|
||||
return false
|
||||
}
|
||||
|
||||
if !hijackAddress.Equal(net.IPv4zero) && !hijackAddress.Equal(net.IPv6zero) && !hijackAddress.Equal(endpoint.Target.IP) {
|
||||
if !hijackAddress.Equal(net.IPv4zero) && !hijackAddress.Equal(endpoint.Target.IP) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -2,21 +2,20 @@ package tun
|
||||
|
||||
import "github.com/Dreamacro/clash/log"
|
||||
|
||||
type ClashLogger struct {}
|
||||
type ClashLogger struct{}
|
||||
|
||||
func (c *ClashLogger) D(format string, args ...interface{}) {
|
||||
log.Debugln(format, args)
|
||||
log.Debugln(format, args...)
|
||||
}
|
||||
|
||||
func (c *ClashLogger) I(format string, args ...interface{}) {
|
||||
log.Infoln(format, args)
|
||||
log.Infoln(format, args...)
|
||||
}
|
||||
|
||||
func (c *ClashLogger) W(format string, args ...interface{}) {
|
||||
log.Warnln(format, args)
|
||||
log.Warnln(format, args...)
|
||||
}
|
||||
|
||||
func (c *ClashLogger) E(format string, args ...interface{}) {
|
||||
log.Errorln(format, args)
|
||||
log.Errorln(format, args...)
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ func StartTunDevice(fd, mtu int, gateway, mirror, dnsAddress string) error {
|
||||
Zone: "",
|
||||
})
|
||||
|
||||
tunnel.Add(adapters.NewSocket(addr, conn, C.SOCKS, C.TCP))
|
||||
tunnel.Add(adapters.NewSocket(addr, conn, C.SOCKS))
|
||||
})
|
||||
adapter.SetUDPHandler(func(payload []byte, endpoint *binding.Endpoint, sender redirect.UDPSender) {
|
||||
if gatewayNet.Contains(endpoint.Target.IP) {
|
||||
@@ -101,7 +101,8 @@ func StartTunDevice(fd, mtu int, gateway, mirror, dnsAddress string) error {
|
||||
pkt := &udpPacket{
|
||||
payload: payload,
|
||||
endpoint: endpoint,
|
||||
sender: sender,
|
||||
send: sender,
|
||||
recycle: udpRecycle,
|
||||
}
|
||||
|
||||
tunnel.AddPacket(adapters.NewPacket(addr, pkt, C.SOCKS))
|
||||
|
||||
@@ -10,7 +10,8 @@ import (
|
||||
type udpPacket struct {
|
||||
payload []byte
|
||||
endpoint *binding.Endpoint
|
||||
sender redirect.UDPSender
|
||||
send redirect.UDPSender
|
||||
recycle func([]byte)
|
||||
}
|
||||
|
||||
func (conn *udpPacket) Data() []byte {
|
||||
@@ -39,11 +40,7 @@ func (conn *udpPacket) WriteBack(b []byte, addr net.Addr) (n int, err error) {
|
||||
Target: conn.endpoint.Source,
|
||||
}
|
||||
|
||||
return len(b), conn.sender(b, ep)
|
||||
}
|
||||
|
||||
func (conn *udpPacket) Close() error {
|
||||
return nil
|
||||
return len(b), conn.send(b, ep)
|
||||
}
|
||||
|
||||
func (conn *udpPacket) LocalAddr() net.Addr {
|
||||
@@ -53,3 +50,7 @@ func (conn *udpPacket) LocalAddr() net.Addr {
|
||||
Zone: "",
|
||||
}
|
||||
}
|
||||
|
||||
func (conn *udpPacket) Drop() {
|
||||
conn.recycle(conn.payload)
|
||||
}
|
||||
|
||||
@@ -20,4 +20,6 @@ android.enableJetifier=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
|
||||
kapt.incremental.apt=false
|
||||
kapt.incremental.apt=false
|
||||
|
||||
org.gradle.parallel=true
|
||||
@@ -4,10 +4,7 @@ import android.content.Intent
|
||||
import android.os.Binder
|
||||
import android.os.IBinder
|
||||
import com.github.kr328.clash.service.clash.ClashRuntime
|
||||
import com.github.kr328.clash.service.clash.module.CloseModule
|
||||
import com.github.kr328.clash.service.clash.module.DynamicNotificationModule
|
||||
import com.github.kr328.clash.service.clash.module.ReloadModule
|
||||
import com.github.kr328.clash.service.clash.module.StaticNotificationModule
|
||||
import com.github.kr328.clash.service.clash.module.*
|
||||
import com.github.kr328.clash.service.settings.ServiceSettings
|
||||
import com.github.kr328.clash.service.util.broadcastClashStarted
|
||||
import com.github.kr328.clash.service.util.broadcastClashStopped
|
||||
@@ -36,9 +33,7 @@ class ClashService : BaseService() {
|
||||
runtime.install(ReloadModule(service)) {
|
||||
onLoaded {
|
||||
if (it != null) {
|
||||
reason = it.message
|
||||
|
||||
stopSelf()
|
||||
service.stopSelfForReason(it.message)
|
||||
} else {
|
||||
service.broadcastProfileLoaded()
|
||||
}
|
||||
@@ -46,9 +41,7 @@ class ClashService : BaseService() {
|
||||
}
|
||||
runtime.install(CloseModule()) {
|
||||
onClosed {
|
||||
reason = null
|
||||
|
||||
stopSelf()
|
||||
service.stopSelfForReason(null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,4 +71,10 @@ class ClashService : BaseService() {
|
||||
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
private fun stopSelfForReason(reason: String?) {
|
||||
this.reason = reason
|
||||
|
||||
stopSelf()
|
||||
}
|
||||
}
|
||||
@@ -45,11 +45,11 @@ class ProfileReceiver : BroadcastReceiver() {
|
||||
val metadata = ProfileDao.queryById(id)?.asProfile(context) ?: return
|
||||
val service = context.getSystemService<AlarmManager>() ?: return
|
||||
|
||||
val pendingIntent = cancelNextUpdate(context, id)
|
||||
|
||||
if (metadata.interval <= 0)
|
||||
return
|
||||
|
||||
val pendingIntent = cancelNextUpdate(context, id)
|
||||
|
||||
service.set(
|
||||
AlarmManager.RTC,
|
||||
metadata.lastModified + metadata.interval,
|
||||
|
||||
@@ -83,8 +83,12 @@ class ProfileService : BaseService() {
|
||||
val clonedId = generateNextId()
|
||||
|
||||
pending[clonedId] =
|
||||
queryMetadataById(id)?.copy(id = clonedId, active = false, lastModified = 0)
|
||||
?: return@runBlocking -1L
|
||||
queryMetadataById(id)?.copy(
|
||||
id = clonedId,
|
||||
active = false,
|
||||
lastModified = 0,
|
||||
type = Profile.Type.FILE
|
||||
) ?: return@runBlocking -1L
|
||||
|
||||
clonedId
|
||||
}
|
||||
@@ -104,6 +108,8 @@ class ProfileService : BaseService() {
|
||||
ProfileDao.remove(id)
|
||||
}
|
||||
|
||||
ProfileReceiver.cancelNextUpdate(service, id)
|
||||
|
||||
service.resolveProfileFile(id).delete()
|
||||
service.resolveTempProfileFile(id).delete()
|
||||
service.resolveBaseDir(id).deleteRecursively()
|
||||
|
||||
@@ -19,6 +19,7 @@ class TunService : VpnService(), CoroutineScope by MainScope() {
|
||||
private const val PRIVATE_VLAN4_CLIENT = "172.31.255.253"
|
||||
private const val PRIVATE_VLAN4_MIRROR = "172.31.255.254"
|
||||
private const val PRIVATE_VLAN_DNS = "198.18.0.1"
|
||||
private const val VLAN_ANY = "0.0.0.0/0"
|
||||
}
|
||||
|
||||
private val service = this
|
||||
@@ -47,25 +48,15 @@ class TunService : VpnService(), CoroutineScope by MainScope() {
|
||||
runtime.install(ReloadModule(service)) {
|
||||
onLoaded {
|
||||
if (it != null) {
|
||||
reason = it.message
|
||||
|
||||
stopSelf()
|
||||
|
||||
TunModule.requestStop()
|
||||
service.stopSelfForReason(it.message)
|
||||
} else {
|
||||
broadcastProfileLoaded()
|
||||
service.broadcastProfileLoaded()
|
||||
}
|
||||
}
|
||||
}
|
||||
runtime.install(CloseModule()) {
|
||||
onClosed {
|
||||
launch {
|
||||
reason = null
|
||||
|
||||
stopSelf()
|
||||
|
||||
TunModule.requestStop()
|
||||
}
|
||||
service.stopSelfForReason(null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,15 +90,17 @@ class TunService : VpnService(), CoroutineScope by MainScope() {
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
broadcastClashStarted()
|
||||
service.broadcastClashStarted()
|
||||
|
||||
return super.onStartCommand(intent, flags, startId)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
TunModule.requestStop()
|
||||
|
||||
ServiceStatusProvider.serviceRunning = false
|
||||
|
||||
broadcastClashStopped(reason)
|
||||
service.broadcastClashStopped(reason)
|
||||
|
||||
cancel()
|
||||
|
||||
@@ -128,23 +121,35 @@ class TunService : VpnService(), CoroutineScope by MainScope() {
|
||||
return if (settings.get(ServiceSettings.BYPASS_PRIVATE_NETWORK))
|
||||
resources.getStringArray(R.array.bypass_private_route).toList()
|
||||
else
|
||||
listOf("0.0.0.0/0")
|
||||
resources.getStringArray(R.array.bypass_local_route).toList()
|
||||
}
|
||||
override val dnsAddress: String
|
||||
get() = PRIVATE_VLAN_DNS
|
||||
override val dnsHijacking: Boolean
|
||||
get() = settings.get(ServiceSettings.DNS_HIJACKING)
|
||||
override val allowApplications: List<String>
|
||||
override val allowApplications: Collection<String>
|
||||
get() {
|
||||
return if (settings.get(ServiceSettings.ACCESS_CONTROL_MODE) == ServiceSettings.ACCESS_CONTROL_MODE_WHITELIST) {
|
||||
(settings.get(ServiceSettings.ACCESS_CONTROL_PACKAGES) + packageName).toList()
|
||||
} else emptyList()
|
||||
(settings.get(ServiceSettings.ACCESS_CONTROL_PACKAGES) + packageName)
|
||||
} else emptySet()
|
||||
}
|
||||
override val disallowApplication: List<String>
|
||||
override val disallowApplication: Collection<String>
|
||||
get() {
|
||||
return if (settings.get(ServiceSettings.ACCESS_CONTROL_MODE) == ServiceSettings.ACCESS_CONTROL_MODE_BLACKLIST) {
|
||||
(settings.get(ServiceSettings.ACCESS_CONTROL_PACKAGES) - packageName).toList()
|
||||
} else emptyList()
|
||||
(settings.get(ServiceSettings.ACCESS_CONTROL_PACKAGES) - packageName)
|
||||
} else emptySet()
|
||||
}
|
||||
|
||||
override fun onCreateTunFailure() {
|
||||
stopSelfForReason("Establish VPN rejected by system")
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopSelfForReason(reason: String?) {
|
||||
this.reason = reason
|
||||
|
||||
stopSelf()
|
||||
|
||||
TunModule.requestStop()
|
||||
}
|
||||
}
|
||||
@@ -87,8 +87,14 @@ class ClashRuntime(private val context: Context) {
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
modules.reversed().forEach {
|
||||
it.onStop()
|
||||
runCatching {
|
||||
modules.reversed().forEach {
|
||||
it.onStop()
|
||||
}
|
||||
}
|
||||
|
||||
runCatching {
|
||||
context.unregisterReceiver(receiver)
|
||||
}
|
||||
|
||||
Clash.stop()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.github.kr328.clash.service.clash.module
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Intent
|
||||
import android.net.VpnService
|
||||
import android.os.Build
|
||||
import com.github.kr328.clash.common.Global
|
||||
@@ -10,6 +9,7 @@ import com.github.kr328.clash.core.Clash
|
||||
import com.github.kr328.clash.service.util.parseCIDR
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.lang.NullPointerException
|
||||
|
||||
class TunModule(private val service: VpnService) : Module() {
|
||||
interface Configure {
|
||||
@@ -20,8 +20,10 @@ class TunModule(private val service: VpnService) : Module() {
|
||||
val route: List<String>
|
||||
val dnsAddress: String
|
||||
val dnsHijacking: Boolean
|
||||
val allowApplications: List<String>
|
||||
val disallowApplication: List<String>
|
||||
val allowApplications: Collection<String>
|
||||
val disallowApplication: Collection<String>
|
||||
|
||||
fun onCreateTunFailure()
|
||||
}
|
||||
|
||||
var configure: Configure? = null
|
||||
@@ -62,7 +64,12 @@ class TunModule(private val service: VpnService) : Module() {
|
||||
builder.setMetered(false)
|
||||
}
|
||||
|
||||
val fd = builder.establish() ?: throw NullPointerException("Unable to create vpn")
|
||||
val fd = try {
|
||||
builder.establish() ?: throw NullPointerException()
|
||||
}
|
||||
catch (e: Exception) {
|
||||
return@withContext c.onCreateTunFailure()
|
||||
}
|
||||
|
||||
if (c.dnsHijacking) {
|
||||
Clash.startTunDevice(
|
||||
|
||||
@@ -4,9 +4,7 @@ import android.content.Context
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import com.github.kr328.clash.common.Global
|
||||
import com.github.kr328.clash.service.data.DatabaseMigrations.VERSION_1_2
|
||||
import com.github.kr328.clash.service.data.DatabaseMigrations.VERSION_2_3
|
||||
import com.github.kr328.clash.service.data.DatabaseMigrations.VERSION_3_4
|
||||
import com.github.kr328.clash.service.data.migrations.MIGRATIONS
|
||||
import androidx.room.Database as DatabaseMetadata
|
||||
|
||||
@DatabaseMetadata(
|
||||
@@ -26,7 +24,7 @@ abstract class Database : RoomDatabase() {
|
||||
context.applicationContext,
|
||||
Database::class.java,
|
||||
"clash-config"
|
||||
).addMigrations(VERSION_1_2, VERSION_2_3, VERSION_3_4).build()
|
||||
).addMigrations(*MIGRATIONS).build()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,328 +0,0 @@
|
||||
package com.github.kr328.clash.service.data
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.database.sqlite.SQLiteDatabase.CONFLICT_ABORT
|
||||
import android.database.sqlite.SQLiteDatabase.CONFLICT_REPLACE
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.core.content.edit
|
||||
import androidx.core.database.getStringOrNull
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.github.kr328.clash.common.Global
|
||||
import com.github.kr328.clash.common.utils.Log
|
||||
import com.github.kr328.clash.service.Constants
|
||||
import com.github.kr328.clash.service.settings.ServiceSettings
|
||||
import com.github.kr328.clash.service.util.resolveBaseDir
|
||||
import com.github.kr328.clash.service.util.resolveProfileFile
|
||||
import java.io.File
|
||||
|
||||
object DatabaseMigrations {
|
||||
val VERSION_1_2 = object : Migration(1, 2) {
|
||||
private fun process(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("ALTER TABLE profiles RENAME TO _profiles")
|
||||
database.execSQL("ALTER TABLE profile_select_proxies RENAME TO _profile_select_proxies")
|
||||
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `profiles` (`name` TEXT NOT NULL, `type` INTEGER NOT NULL, `uri` TEXT NOT NULL, `source` TEXT, `active` INTEGER NOT NULL, `last_update` INTEGER NOT NULL, `update_interval` INTEGER NOT NULL, `id` INTEGER NOT NULL, PRIMARY KEY(`id`))")
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `profile_select_proxies` (`profile_id` INTEGER NOT NULL, `proxy` TEXT NOT NULL, `selected` TEXT NOT NULL, PRIMARY KEY(`profile_id`, `proxy`), FOREIGN KEY(`profile_id`) REFERENCES `profiles`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )")
|
||||
|
||||
database.query("SELECT name, token, file, active, last_update, id FROM _profiles")
|
||||
.use { cursor ->
|
||||
|
||||
Global.application.filesDir.resolve(Constants.CLASH_DIR).listFiles()?.forEach {
|
||||
it.deleteRecursively()
|
||||
}
|
||||
|
||||
cursor.moveToFirst()
|
||||
while (!cursor.isAfterLast) {
|
||||
// old
|
||||
// name, token, file, active, last_update, id
|
||||
val name = cursor.getString(0)
|
||||
val token = cursor.getString(1)
|
||||
val file = cursor.getString(2)
|
||||
val active = cursor.getInt(3)
|
||||
val lastUpdate = cursor.getLong(4)
|
||||
val id = cursor.getLong(5)
|
||||
|
||||
// new
|
||||
// name, type, uri, source, active, last_update, update_interval, id
|
||||
val type = when {
|
||||
token.startsWith("url") -> ProfileEntity.TYPE_URL
|
||||
token.startsWith("file") -> ProfileEntity.TYPE_FILE
|
||||
else -> ProfileEntity.TYPE_UNKNOWN
|
||||
}
|
||||
|
||||
File(file).renameTo(Global.application.resolveProfileFile(id))
|
||||
Global.application.resolveBaseDir(id).mkdirs()
|
||||
|
||||
database.insert("profiles",
|
||||
CONFLICT_ABORT,
|
||||
ContentValues().apply {
|
||||
put("name", name)
|
||||
put("type", type)
|
||||
put("uri", token.removePrefix("url|").removePrefix("file|"))
|
||||
putNull("source")
|
||||
put("active", active)
|
||||
put("last_update", lastUpdate)
|
||||
put("update_interval", 0)
|
||||
put("id", id)
|
||||
})
|
||||
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
|
||||
database.query("SELECT profile_id, proxy, selected FROM _profile_select_proxies ORDER BY id")
|
||||
.use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
while (!cursor.isAfterLast) {
|
||||
// old
|
||||
// profile_id, proxy, selected, id
|
||||
val profileId = cursor.getLong(0)
|
||||
val proxy: String = cursor.getString(1)
|
||||
val selected = cursor.getString(2)
|
||||
|
||||
// new
|
||||
// profile_id, proxy, selected
|
||||
|
||||
database.insert("profile_select_proxies",
|
||||
CONFLICT_REPLACE,
|
||||
ContentValues().apply {
|
||||
put("profile_id", profileId)
|
||||
put("proxy", proxy)
|
||||
put("selected", selected)
|
||||
})
|
||||
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
|
||||
database.execSQL("DROP TABLE IF EXISTS _profiles")
|
||||
database.execSQL("DROP TABLE IF EXISTS _profile_select_proxies")
|
||||
|
||||
// Migration settings
|
||||
val oldSettings = Global.application
|
||||
.getSharedPreferences("clash_service", Context.MODE_PRIVATE)
|
||||
val newSettings = ServiceSettings(
|
||||
Global.application
|
||||
.getSharedPreferences(Constants.SERVICE_SETTING_FILE_NAME, Context.MODE_PRIVATE)
|
||||
)
|
||||
|
||||
val accessMode = oldSettings
|
||||
.getInt("key_access_control_mode", 0)
|
||||
val accessPackages = oldSettings
|
||||
.getStringSet("ley_access_control_apps", emptySet())!! // just typo :)
|
||||
val dnsHijack = oldSettings
|
||||
.getBoolean("key_dns_hijacking_enabled", true)
|
||||
val bypassPrivate = oldSettings
|
||||
.getBoolean("key_bypass_private_network", true)
|
||||
|
||||
oldSettings.edit {
|
||||
clear()
|
||||
}
|
||||
|
||||
newSettings.commit {
|
||||
val newAccessMode = when (accessMode) {
|
||||
0 -> ServiceSettings.ACCESS_CONTROL_MODE_ALL
|
||||
1 -> ServiceSettings.ACCESS_CONTROL_MODE_WHITELIST
|
||||
2 -> ServiceSettings.ACCESS_CONTROL_MODE_BLACKLIST
|
||||
else -> ServiceSettings.ACCESS_CONTROL_MODE_ALL
|
||||
}
|
||||
|
||||
put(ServiceSettings.ACCESS_CONTROL_MODE, newAccessMode)
|
||||
put(ServiceSettings.ACCESS_CONTROL_PACKAGES, accessPackages)
|
||||
put(ServiceSettings.DNS_HIJACKING, dnsHijack)
|
||||
put(ServiceSettings.BYPASS_PRIVATE_NETWORK, bypassPrivate)
|
||||
}
|
||||
}
|
||||
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
try {
|
||||
process(database)
|
||||
Log.i("Database Migrated 1 -> 2")
|
||||
} catch (e: Exception) {
|
||||
Log.e("Migration failure", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val VERSION_2_3 = object : Migration(2, 3) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
try {
|
||||
database.execSQL("ALTER TABLE profile_select_proxies RENAME TO _selected_proxies")
|
||||
database.execSQL("ALTER TABLE profiles RENAME TO _profiles")
|
||||
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `profiles` (`name` TEXT NOT NULL, `type` INTEGER NOT NULL, `uri` TEXT NOT NULL, `source` TEXT, `active` INTEGER NOT NULL, `interval` INTEGER NOT NULL, `id` INTEGER NOT NULL, PRIMARY KEY(`id`))")
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `selected_proxies` (`profile_id` INTEGER NOT NULL, `proxy` TEXT NOT NULL, `selected` TEXT NOT NULL, PRIMARY KEY(`profile_id`, `proxy`), FOREIGN KEY(`profile_id`) REFERENCES `profiles`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )")
|
||||
|
||||
database.query("SELECT name, type, uri, source, active, update_interval, id FROM _profiles")
|
||||
.use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
while (!cursor.isAfterLast) {
|
||||
// old
|
||||
// name, type, uri, source, active, last_update, update_interval(seconds), id
|
||||
// new
|
||||
// name, type, uri, source, active, interval(millis seconds), id
|
||||
val name = cursor.getString(0)
|
||||
val type = cursor.getInt(1)
|
||||
val uri = cursor.getString(2)
|
||||
val source = cursor.getStringOrNull(3)
|
||||
val active = cursor.getInt(4)
|
||||
val interval = cursor.getLong(5)
|
||||
val id = cursor.getLong(6)
|
||||
|
||||
database.insert("profiles",
|
||||
CONFLICT_ABORT,
|
||||
ContentValues().apply {
|
||||
put("name", name)
|
||||
put("type", type)
|
||||
put("uri", uri)
|
||||
put("source", source)
|
||||
put("active", active)
|
||||
put("interval", interval * 1000)
|
||||
put("id", id)
|
||||
})
|
||||
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
|
||||
database.query("SELECT profile_id, proxy, selected FROM _selected_proxies")
|
||||
.use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
while (!cursor.isAfterLast) {
|
||||
// just copy
|
||||
// profile_id, proxy, selected
|
||||
val profileId = cursor.getLong(0)
|
||||
val proxy = cursor.getString(1)
|
||||
val selected = cursor.getString(2)
|
||||
|
||||
database.insert("selected_proxies",
|
||||
CONFLICT_REPLACE,
|
||||
ContentValues().apply {
|
||||
put("profile_id", profileId)
|
||||
put("proxy", proxy)
|
||||
put("selected", selected)
|
||||
})
|
||||
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
|
||||
database.execSQL("DROP TABLE IF EXISTS _profiles")
|
||||
database.execSQL("DROP TABLE IF EXISTS _selected_proxies")
|
||||
|
||||
val uiSp = Global.application
|
||||
.getSharedPreferences("ui", Context.MODE_PRIVATE)
|
||||
val srvSp = Global.application
|
||||
.getSharedPreferences("service", Context.MODE_PRIVATE)
|
||||
|
||||
srvSp.edit {
|
||||
putBoolean("enable_vpn", uiSp.getBoolean("enable_vpn", true))
|
||||
}
|
||||
|
||||
NotificationManagerCompat.from(Global.application).apply {
|
||||
deleteNotificationChannel("clash_status_channel")
|
||||
deleteNotificationChannel("profile_service_status")
|
||||
deleteNotificationChannel("profile_service_result")
|
||||
}
|
||||
|
||||
Log.i("Database Migrated 2 -> 3")
|
||||
} catch (e: Exception) {
|
||||
Log.e("Migration failure", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val VERSION_3_4 = object : Migration(3, 4) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
try {
|
||||
val profiles = mutableListOf<ProfileEntity>()
|
||||
try {
|
||||
database.query("SELECT name, type, uri, source, active, interval, id FROM profiles")
|
||||
.use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
while (!cursor.isAfterLast) {
|
||||
// old
|
||||
// name, type, uri, source, active, last_update, update_interval(seconds), id
|
||||
// new
|
||||
// name, type, uri, source, active, interval(millis seconds), id
|
||||
val name = cursor.getString(0)
|
||||
val type = cursor.getInt(1)
|
||||
val uri = cursor.getString(2)
|
||||
val source = cursor.getStringOrNull(3)
|
||||
val active = cursor.getInt(4)
|
||||
val interval = cursor.getLong(5)
|
||||
val id = cursor.getLong(6)
|
||||
|
||||
profiles.add(ProfileEntity(name, type, uri, source, active != 0, interval, id))
|
||||
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e: Exception) {
|
||||
Log.w("Query old data failure", e)
|
||||
}
|
||||
|
||||
val selectedProxies = mutableListOf<SelectedProxyEntity>()
|
||||
|
||||
try {
|
||||
database.query("SELECT profile_id, proxy, selected FROM selected_proxies")
|
||||
.use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
while (!cursor.isAfterLast) {
|
||||
// just copy
|
||||
// profile_id, proxy, selected
|
||||
val profileId = cursor.getLong(0)
|
||||
val proxy = cursor.getString(1)
|
||||
val selected = cursor.getString(2)
|
||||
|
||||
selectedProxies.add(SelectedProxyEntity(profileId, proxy, selected))
|
||||
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e: Exception) {
|
||||
Log.w("Query old data failure", e)
|
||||
}
|
||||
|
||||
database.execSQL("DROP TABLE IF EXISTS profile_select_proxies")
|
||||
database.execSQL("DROP TABLE IF EXISTS selected_proxies")
|
||||
database.execSQL("DROP TABLE IF EXISTS profiles")
|
||||
database.execSQL("DROP TABLE IF EXISTS _profile_select_proxies")
|
||||
database.execSQL("DROP TABLE IF EXISTS _selected_proxies")
|
||||
database.execSQL("DROP TABLE IF EXISTS _profiles")
|
||||
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `profiles` (`name` TEXT NOT NULL, `type` INTEGER NOT NULL, `uri` TEXT NOT NULL, `source` TEXT, `active` INTEGER NOT NULL, `interval` INTEGER NOT NULL, `id` INTEGER NOT NULL, PRIMARY KEY(`id`))")
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `selected_proxies` (`profile_id` INTEGER NOT NULL, `proxy` TEXT NOT NULL, `selected` TEXT NOT NULL, PRIMARY KEY(`profile_id`, `proxy`), FOREIGN KEY(`profile_id`) REFERENCES `profiles`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )")
|
||||
|
||||
profiles.forEach {
|
||||
database.insert("profiles", CONFLICT_ABORT, ContentValues().apply {
|
||||
put("name", it.name)
|
||||
put("type", it.type)
|
||||
put("uri", it.uri)
|
||||
put("source", it.source)
|
||||
put("active", it.active)
|
||||
put("interval", it.interval)
|
||||
put("id", it.id)
|
||||
})
|
||||
}
|
||||
|
||||
selectedProxies.forEach {
|
||||
database.insert("selected_proxies", CONFLICT_REPLACE, ContentValues().apply {
|
||||
put("profile_id", it.profileId)
|
||||
put("proxy", it.proxy)
|
||||
put("selected", it.selected)
|
||||
})
|
||||
}
|
||||
|
||||
Log.i("Database Migrated 3 -> 4")
|
||||
} catch (e: Exception) {
|
||||
Log.e("Migration failure", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.github.kr328.clash.service.data.migrations
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import androidx.core.content.edit
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.github.kr328.clash.common.Global
|
||||
import com.github.kr328.clash.common.utils.Log
|
||||
import com.github.kr328.clash.service.Constants
|
||||
import com.github.kr328.clash.service.data.ProfileEntity
|
||||
import com.github.kr328.clash.service.settings.ServiceSettings
|
||||
import com.github.kr328.clash.service.util.resolveBaseDir
|
||||
import com.github.kr328.clash.service.util.resolveProfileFile
|
||||
import java.io.File
|
||||
|
||||
object Migration12: Migration(1, 2) {
|
||||
private fun process(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("ALTER TABLE profiles RENAME TO _profiles")
|
||||
database.execSQL("ALTER TABLE profile_select_proxies RENAME TO _profile_select_proxies")
|
||||
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `profiles` (`name` TEXT NOT NULL, `type` INTEGER NOT NULL, `uri` TEXT NOT NULL, `source` TEXT, `active` INTEGER NOT NULL, `last_update` INTEGER NOT NULL, `update_interval` INTEGER NOT NULL, `id` INTEGER NOT NULL, PRIMARY KEY(`id`))")
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `profile_select_proxies` (`profile_id` INTEGER NOT NULL, `proxy` TEXT NOT NULL, `selected` TEXT NOT NULL, PRIMARY KEY(`profile_id`, `proxy`), FOREIGN KEY(`profile_id`) REFERENCES `profiles`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )")
|
||||
|
||||
database.query("SELECT name, token, file, active, last_update, id FROM _profiles")
|
||||
.use { cursor ->
|
||||
|
||||
Global.application.filesDir.resolve(Constants.CLASH_DIR).listFiles()?.forEach {
|
||||
it.deleteRecursively()
|
||||
}
|
||||
|
||||
cursor.moveToFirst()
|
||||
while (!cursor.isAfterLast) {
|
||||
// old
|
||||
// name, token, file, active, last_update, id
|
||||
val name = cursor.getString(0)
|
||||
val token = cursor.getString(1)
|
||||
val file = cursor.getString(2)
|
||||
val active = cursor.getInt(3)
|
||||
val lastUpdate = cursor.getLong(4)
|
||||
val id = cursor.getLong(5)
|
||||
|
||||
// new
|
||||
// name, type, uri, source, active, last_update, update_interval, id
|
||||
val type = when {
|
||||
token.startsWith("url") -> ProfileEntity.TYPE_URL
|
||||
token.startsWith("file") -> ProfileEntity.TYPE_FILE
|
||||
else -> ProfileEntity.TYPE_UNKNOWN
|
||||
}
|
||||
|
||||
File(file).renameTo(Global.application.resolveProfileFile(id))
|
||||
Global.application.resolveBaseDir(id).mkdirs()
|
||||
|
||||
database.insert("profiles",
|
||||
SQLiteDatabase.CONFLICT_ABORT,
|
||||
ContentValues().apply {
|
||||
put("name", name)
|
||||
put("type", type)
|
||||
put("uri", token.removePrefix("url|").removePrefix("file|"))
|
||||
putNull("source")
|
||||
put("active", active)
|
||||
put("last_update", lastUpdate)
|
||||
put("update_interval", 0)
|
||||
put("id", id)
|
||||
})
|
||||
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
|
||||
database.query("SELECT profile_id, proxy, selected FROM _profile_select_proxies ORDER BY id")
|
||||
.use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
while (!cursor.isAfterLast) {
|
||||
// old
|
||||
// profile_id, proxy, selected, id
|
||||
val profileId = cursor.getLong(0)
|
||||
val proxy: String = cursor.getString(1)
|
||||
val selected = cursor.getString(2)
|
||||
|
||||
// new
|
||||
// profile_id, proxy, selected
|
||||
|
||||
database.insert("profile_select_proxies",
|
||||
SQLiteDatabase.CONFLICT_REPLACE,
|
||||
ContentValues().apply {
|
||||
put("profile_id", profileId)
|
||||
put("proxy", proxy)
|
||||
put("selected", selected)
|
||||
})
|
||||
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
|
||||
database.execSQL("DROP TABLE IF EXISTS _profiles")
|
||||
database.execSQL("DROP TABLE IF EXISTS _profile_select_proxies")
|
||||
|
||||
// Migration settings
|
||||
val oldSettings = Global.application
|
||||
.getSharedPreferences("clash_service", Context.MODE_PRIVATE)
|
||||
val newSettings = ServiceSettings(
|
||||
Global.application
|
||||
.getSharedPreferences(Constants.SERVICE_SETTING_FILE_NAME, Context.MODE_PRIVATE)
|
||||
)
|
||||
|
||||
val accessMode = oldSettings
|
||||
.getInt("key_access_control_mode", 0)
|
||||
val accessPackages = oldSettings
|
||||
.getStringSet("ley_access_control_apps", emptySet())!! // just typo :)
|
||||
val dnsHijack = oldSettings
|
||||
.getBoolean("key_dns_hijacking_enabled", true)
|
||||
val bypassPrivate = oldSettings
|
||||
.getBoolean("key_bypass_private_network", true)
|
||||
|
||||
oldSettings.edit {
|
||||
clear()
|
||||
}
|
||||
|
||||
newSettings.commit {
|
||||
val newAccessMode = when (accessMode) {
|
||||
0 -> ServiceSettings.ACCESS_CONTROL_MODE_ALL
|
||||
1 -> ServiceSettings.ACCESS_CONTROL_MODE_WHITELIST
|
||||
2 -> ServiceSettings.ACCESS_CONTROL_MODE_BLACKLIST
|
||||
else -> ServiceSettings.ACCESS_CONTROL_MODE_ALL
|
||||
}
|
||||
|
||||
put(ServiceSettings.ACCESS_CONTROL_MODE, newAccessMode)
|
||||
put(ServiceSettings.ACCESS_CONTROL_PACKAGES, accessPackages)
|
||||
put(ServiceSettings.DNS_HIJACKING, dnsHijack)
|
||||
put(ServiceSettings.BYPASS_PRIVATE_NETWORK, bypassPrivate)
|
||||
}
|
||||
}
|
||||
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
try {
|
||||
process(database)
|
||||
Log.i("Database Migrated 1 -> 2")
|
||||
} catch (e: Exception) {
|
||||
Log.e("Migration failure", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.github.kr328.clash.service.data.migrations
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.core.content.edit
|
||||
import androidx.core.database.getStringOrNull
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.github.kr328.clash.common.Global
|
||||
import com.github.kr328.clash.common.utils.Log
|
||||
|
||||
object Migration23: Migration(2, 3) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
try {
|
||||
database.execSQL("ALTER TABLE profile_select_proxies RENAME TO _selected_proxies")
|
||||
database.execSQL("ALTER TABLE profiles RENAME TO _profiles")
|
||||
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `profiles` (`name` TEXT NOT NULL, `type` INTEGER NOT NULL, `uri` TEXT NOT NULL, `source` TEXT, `active` INTEGER NOT NULL, `interval` INTEGER NOT NULL, `id` INTEGER NOT NULL, PRIMARY KEY(`id`))")
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `selected_proxies` (`profile_id` INTEGER NOT NULL, `proxy` TEXT NOT NULL, `selected` TEXT NOT NULL, PRIMARY KEY(`profile_id`, `proxy`), FOREIGN KEY(`profile_id`) REFERENCES `profiles`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )")
|
||||
|
||||
database.query("SELECT name, type, uri, source, active, update_interval, id FROM _profiles")
|
||||
.use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
while (!cursor.isAfterLast) {
|
||||
// old
|
||||
// name, type, uri, source, active, last_update, update_interval(seconds), id
|
||||
// new
|
||||
// name, type, uri, source, active, interval(millis seconds), id
|
||||
val name = cursor.getString(0)
|
||||
val type = cursor.getInt(1)
|
||||
val uri = cursor.getString(2)
|
||||
val source = cursor.getStringOrNull(3)
|
||||
val active = cursor.getInt(4)
|
||||
val interval = cursor.getLong(5)
|
||||
val id = cursor.getLong(6)
|
||||
|
||||
database.insert("profiles",
|
||||
SQLiteDatabase.CONFLICT_ABORT,
|
||||
ContentValues().apply {
|
||||
put("name", name)
|
||||
put("type", type)
|
||||
put("uri", uri)
|
||||
put("source", source)
|
||||
put("active", active)
|
||||
put("interval", interval * 1000)
|
||||
put("id", id)
|
||||
})
|
||||
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
|
||||
database.query("SELECT profile_id, proxy, selected FROM _selected_proxies")
|
||||
.use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
while (!cursor.isAfterLast) {
|
||||
// just copy
|
||||
// profile_id, proxy, selected
|
||||
val profileId = cursor.getLong(0)
|
||||
val proxy = cursor.getString(1)
|
||||
val selected = cursor.getString(2)
|
||||
|
||||
database.insert("selected_proxies",
|
||||
SQLiteDatabase.CONFLICT_REPLACE,
|
||||
ContentValues().apply {
|
||||
put("profile_id", profileId)
|
||||
put("proxy", proxy)
|
||||
put("selected", selected)
|
||||
})
|
||||
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
|
||||
database.execSQL("DROP TABLE IF EXISTS _profiles")
|
||||
database.execSQL("DROP TABLE IF EXISTS _selected_proxies")
|
||||
|
||||
val uiSp = Global.application
|
||||
.getSharedPreferences("ui", Context.MODE_PRIVATE)
|
||||
val srvSp = Global.application
|
||||
.getSharedPreferences("service", Context.MODE_PRIVATE)
|
||||
|
||||
srvSp.edit {
|
||||
putBoolean("enable_vpn", uiSp.getBoolean("enable_vpn", true))
|
||||
}
|
||||
|
||||
NotificationManagerCompat.from(Global.application).apply {
|
||||
deleteNotificationChannel("profile_service_status")
|
||||
deleteNotificationChannel("profile_service_result")
|
||||
}
|
||||
|
||||
Log.i("Database Migrated 2 -> 3")
|
||||
} catch (e: Exception) {
|
||||
Log.e("Migration failure", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.github.kr328.clash.service.data.migrations
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import androidx.core.database.getStringOrNull
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.github.kr328.clash.common.utils.Log
|
||||
import com.github.kr328.clash.service.data.ProfileEntity
|
||||
import com.github.kr328.clash.service.data.SelectedProxyEntity
|
||||
|
||||
object Migration34: Migration(3, 4) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
try {
|
||||
val profiles = mutableListOf<ProfileEntity>()
|
||||
try {
|
||||
database.query("SELECT name, type, uri, source, active, interval, id FROM profiles")
|
||||
.use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
while (!cursor.isAfterLast) {
|
||||
// old
|
||||
// name, type, uri, source, active, last_update, update_interval(seconds), id
|
||||
// new
|
||||
// name, type, uri, source, active, interval(millis seconds), id
|
||||
val name = cursor.getString(0)
|
||||
val type = cursor.getInt(1)
|
||||
val uri = cursor.getString(2)
|
||||
val source = cursor.getStringOrNull(3)
|
||||
val active = cursor.getInt(4)
|
||||
val interval = cursor.getLong(5)
|
||||
val id = cursor.getLong(6)
|
||||
|
||||
profiles.add(ProfileEntity(name, type, uri, source, active != 0, interval, id))
|
||||
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e: Exception) {
|
||||
Log.w("Query old data failure", e)
|
||||
}
|
||||
|
||||
val selectedProxies = mutableListOf<SelectedProxyEntity>()
|
||||
|
||||
try {
|
||||
database.query("SELECT profile_id, proxy, selected FROM selected_proxies")
|
||||
.use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
while (!cursor.isAfterLast) {
|
||||
// just copy
|
||||
// profile_id, proxy, selected
|
||||
val profileId = cursor.getLong(0)
|
||||
val proxy = cursor.getString(1)
|
||||
val selected = cursor.getString(2)
|
||||
|
||||
selectedProxies.add(SelectedProxyEntity(profileId, proxy, selected))
|
||||
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e: Exception) {
|
||||
Log.w("Query old data failure", e)
|
||||
}
|
||||
|
||||
// Clean up database
|
||||
runCatching {
|
||||
database.execSQL("DROP TABLE IF EXISTS profile_select_proxies")
|
||||
database.execSQL("DROP TABLE IF EXISTS selected_proxies")
|
||||
database.execSQL("DROP TABLE IF EXISTS profiles")
|
||||
database.execSQL("DROP TABLE IF EXISTS _profile_select_proxies")
|
||||
database.execSQL("DROP TABLE IF EXISTS _selected_proxies")
|
||||
database.execSQL("DROP TABLE IF EXISTS _profiles")
|
||||
}
|
||||
runCatching {
|
||||
database.execSQL("DROP TABLE IF EXISTS profile_select_proxies")
|
||||
database.execSQL("DROP TABLE IF EXISTS selected_proxies")
|
||||
database.execSQL("DROP TABLE IF EXISTS profiles")
|
||||
database.execSQL("DROP TABLE IF EXISTS _profile_select_proxies")
|
||||
database.execSQL("DROP TABLE IF EXISTS _selected_proxies")
|
||||
database.execSQL("DROP TABLE IF EXISTS _profiles")
|
||||
}
|
||||
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `profiles` (`name` TEXT NOT NULL, `type` INTEGER NOT NULL, `uri` TEXT NOT NULL, `source` TEXT, `active` INTEGER NOT NULL, `interval` INTEGER NOT NULL, `id` INTEGER NOT NULL, PRIMARY KEY(`id`))")
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `selected_proxies` (`profile_id` INTEGER NOT NULL, `proxy` TEXT NOT NULL, `selected` TEXT NOT NULL, PRIMARY KEY(`profile_id`, `proxy`), FOREIGN KEY(`profile_id`) REFERENCES `profiles`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )")
|
||||
|
||||
profiles.forEach {
|
||||
database.insert("profiles", SQLiteDatabase.CONFLICT_ABORT, ContentValues().apply {
|
||||
put("name", it.name)
|
||||
put("type", it.type)
|
||||
put("uri", it.uri)
|
||||
put("source", it.source)
|
||||
put("active", it.active)
|
||||
put("interval", it.interval)
|
||||
put("id", it.id)
|
||||
})
|
||||
}
|
||||
|
||||
selectedProxies.forEach {
|
||||
database.insert("selected_proxies",
|
||||
SQLiteDatabase.CONFLICT_REPLACE, ContentValues().apply {
|
||||
put("profile_id", it.profileId)
|
||||
put("proxy", it.proxy)
|
||||
put("selected", it.selected)
|
||||
})
|
||||
}
|
||||
|
||||
Log.i("Database Migrated 3 -> 4")
|
||||
} catch (e: Exception) {
|
||||
Log.e("Migration failure", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.github.kr328.clash.service.data.migrations
|
||||
|
||||
import androidx.room.migration.Migration
|
||||
|
||||
val MIGRATIONS: Array<Migration> = arrayOf(Migration12, Migration23, Migration34)
|
||||
@@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- exclude 127.0.0.0/8 10.0.0.0/8 192.168.0.0/16 172.18.0.0/16 -->
|
||||
<!-- exclude 127.0.0.0/8 169.254.0.0/16 10.0.0.0/8 192.168.0.0/16 172.18.0.0/16 -->
|
||||
<string-array name="bypass_private_route" translatable="false">
|
||||
<item>0.0.0.0/5</item>
|
||||
<item>1.0.0.0/8</item>
|
||||
<item>2.0.0.0/7</item>
|
||||
<item>4.0.0.0/6</item>
|
||||
<item>8.0.0.0/7</item>
|
||||
<item>11.0.0.0/8</item>
|
||||
<item>12.0.0.0/6</item>
|
||||
@@ -16,7 +18,16 @@
|
||||
<item>126.0.0.0/8</item>
|
||||
<item>128.0.0.0/3</item>
|
||||
<item>160.0.0.0/5</item>
|
||||
<item>168.0.0.0/6</item>
|
||||
<item>168.0.0.0/8</item>
|
||||
<item>169.0.0.0/9</item>
|
||||
<item>169.128.0.0/10</item>
|
||||
<item>169.192.0.0/11</item>
|
||||
<item>169.224.0.0/12</item>
|
||||
<item>169.240.0.0/13</item>
|
||||
<item>169.248.0.0/14</item>
|
||||
<item>169.252.0.0/15</item>
|
||||
<item>169.255.0.0/16</item>
|
||||
<item>170.0.0.0/7</item>
|
||||
<item>172.0.0.0/12</item>
|
||||
<item>172.32.0.0/11</item>
|
||||
<item>172.64.0.0/10</item>
|
||||
@@ -37,35 +48,37 @@
|
||||
<item>196.0.0.0/6</item>
|
||||
<item>200.0.0.0/5</item>
|
||||
<item>208.0.0.0/4</item>
|
||||
<item>224.0.0.0/4</item>
|
||||
<item>240.0.0.0/5</item>
|
||||
<item>248.0.0.0/6</item>
|
||||
<item>252.0.0.0/7</item>
|
||||
<item>254.0.0.0/8</item>
|
||||
<item>255.0.0.0/9</item>
|
||||
<item>255.128.0.0/10</item>
|
||||
<item>255.192.0.0/11</item>
|
||||
<item>255.224.0.0/12</item>
|
||||
<item>255.240.0.0/13</item>
|
||||
<item>255.248.0.0/14</item>
|
||||
<item>255.252.0.0/15</item>
|
||||
<item>255.254.0.0/16</item>
|
||||
<item>255.255.0.0/17</item>
|
||||
<item>255.255.128.0/18</item>
|
||||
<item>255.255.192.0/19</item>
|
||||
<item>255.255.224.0/20</item>
|
||||
<item>255.255.240.0/21</item>
|
||||
<item>255.255.248.0/22</item>
|
||||
<item>255.255.252.0/23</item>
|
||||
<item>255.255.254.0/24</item>
|
||||
<item>255.255.255.0/25</item>
|
||||
<item>255.255.255.128/26</item>
|
||||
<item>255.255.255.192/27</item>
|
||||
<item>255.255.255.224/28</item>
|
||||
<item>255.255.255.240/29</item>
|
||||
<item>255.255.255.248/30</item>
|
||||
<item>255.255.255.252/31</item>
|
||||
<item>255.255.255.254/32</item>
|
||||
<item>224.0.0.0/3</item>
|
||||
<item>172.31.255.252/30</item> <!-- tun device address -->
|
||||
</string-array>
|
||||
<!-- exclude 127.0.0.0/8 169.254.0.0/16 -->
|
||||
<string-array name="bypass_local_route" translatable="false">
|
||||
<item>1.0.0.0/8</item>
|
||||
<item>2.0.0.0/7</item>
|
||||
<item>4.0.0.0/6</item>
|
||||
<item>8.0.0.0/5</item>
|
||||
<item>16.0.0.0/4</item>
|
||||
<item>32.0.0.0/3</item>
|
||||
<item>64.0.0.0/3</item>
|
||||
<item>96.0.0.0/4</item>
|
||||
<item>112.0.0.0/5</item>
|
||||
<item>120.0.0.0/6</item>
|
||||
<item>124.0.0.0/7</item>
|
||||
<item>126.0.0.0/8</item>
|
||||
<item>128.0.0.0/3</item>
|
||||
<item>160.0.0.0/5</item>
|
||||
<item>168.0.0.0/8</item>
|
||||
<item>169.0.0.0/9</item>
|
||||
<item>169.128.0.0/10</item>
|
||||
<item>169.192.0.0/11</item>
|
||||
<item>169.224.0.0/12</item>
|
||||
<item>169.240.0.0/13</item>
|
||||
<item>169.248.0.0/14</item>
|
||||
<item>169.252.0.0/15</item>
|
||||
<item>169.255.0.0/16</item>
|
||||
<item>170.0.0.0/7</item>
|
||||
<item>172.0.0.0/6</item>
|
||||
<item>176.0.0.0/4</item>
|
||||
<item>192.0.0.0/2</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user