mirror of https://github.com/NekoX-Dev/NekoX.git
Remove legacy proxy format
This commit is contained in:
parent
ce6576f51c
commit
e946c35c01
|
@ -54,28 +54,6 @@ public class SubInfo implements Mappable {
|
|||
|
||||
HashMap<String,Exception> exceptions = new HashMap<>();
|
||||
|
||||
if (id == 1) {
|
||||
|
||||
try {
|
||||
|
||||
List<String> legacyList = ProxyUtil.downloadLegacyProxyList();
|
||||
|
||||
if (legacyList != null) {
|
||||
|
||||
exceptions.put("<Internal>", new IOException("Update Failed"));
|
||||
|
||||
return legacyList;
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
exceptions.put("<Internal>", e);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (String url : urls) {
|
||||
|
||||
try {
|
||||
|
|
|
@ -9,15 +9,13 @@ object SubManager {
|
|||
|
||||
val database by lazy { mkDatabase("proxy_sub") }
|
||||
|
||||
@JvmField var count = 0
|
||||
val count get() = subList.find().totalCount()
|
||||
|
||||
@JvmStatic
|
||||
val subList by lazy {
|
||||
|
||||
database.getRepository("proxy_sub", SubInfo::class.java).apply {
|
||||
|
||||
count = find().totalCount()
|
||||
|
||||
val public = find(ObjectFilters.eq("id", 1L)).firstOrDefault()
|
||||
|
||||
update(SubInfo().apply {
|
||||
|
@ -25,6 +23,12 @@ object SubManager {
|
|||
name = LocaleController.getString("NekoXProxy", R.string.NekoXProxy)
|
||||
enable = public?.enable ?: true
|
||||
|
||||
urls = listOf(
|
||||
"https://gitlab.com/nekohasekai/nekox-proxy-list/-/raw/master/proxy_list",
|
||||
"https://nekox-dev.github.io/ProxyList/proxy_list",
|
||||
"https://gitee.com/nekoshizuku/AwesomeRepo/raw/master/proxy_list"
|
||||
)
|
||||
|
||||
id = 1L
|
||||
internal = true
|
||||
|
||||
|
|
|
@ -19,8 +19,17 @@ fun Request.Builder.applyUserAgent(): Request.Builder {
|
|||
object HttpUtil {
|
||||
|
||||
@JvmField
|
||||
val okHttpClient = OkHttpClient().newBuilder().dns(DnsFactory).connectTimeout(3, TimeUnit.SECONDS).build()
|
||||
val okHttpClientNoDoh = OkHttpClient().newBuilder().connectTimeout(3, TimeUnit.SECONDS).build()
|
||||
val okHttpClient = OkHttpClient().newBuilder()
|
||||
.dns(DnsFactory)
|
||||
.connectTimeout(3, TimeUnit.SECONDS)
|
||||
.readTimeout(3, TimeUnit.SECONDS)
|
||||
.build()
|
||||
|
||||
val okHttpClientNoDoh = OkHttpClient()
|
||||
.newBuilder()
|
||||
.connectTimeout(3, TimeUnit.SECONDS)
|
||||
.readTimeout(3, TimeUnit.SECONDS)
|
||||
.build()
|
||||
|
||||
@JvmStatic
|
||||
val okHttpClientWithCurrProxy: OkHttpClient
|
||||
|
|
|
@ -14,8 +14,7 @@ import android.view.Gravity
|
|||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Toast
|
||||
import cn.hutool.core.codec.Base64
|
||||
import cn.hutool.core.util.StrUtil
|
||||
import android.util.Base64
|
||||
import com.google.zxing.*
|
||||
import com.google.zxing.common.GlobalHistogramBinarizer
|
||||
import com.google.zxing.qrcode.QRCodeReader
|
||||
|
@ -26,11 +25,9 @@ import com.v2ray.ang.V2RayConfig.SS_PROTOCOL
|
|||
import com.v2ray.ang.V2RayConfig.VMESS1_PROTOCOL
|
||||
import com.v2ray.ang.V2RayConfig.VMESS_PROTOCOL
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import org.json.JSONArray
|
||||
import org.telegram.messenger.*
|
||||
import org.telegram.messenger.browser.Browser
|
||||
import org.telegram.ui.ActionBar.BottomSheet
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.File
|
||||
import java.net.NetworkInterface
|
||||
import java.util.*
|
||||
|
@ -38,9 +35,6 @@ import kotlin.collections.HashMap
|
|||
|
||||
object ProxyUtil {
|
||||
|
||||
@JvmField
|
||||
val cacheFile = File(ApplicationLoader.applicationContext.filesDir.parentFile, "nekox/remote_proxy_list.json")
|
||||
|
||||
@JvmStatic
|
||||
fun isVPNEnabled(): Boolean {
|
||||
|
||||
|
@ -60,55 +54,12 @@ object ProxyUtil {
|
|||
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun downloadLegacyProxyList(): List<String>? {
|
||||
|
||||
runCatching {
|
||||
|
||||
// 从 GITEE 主站 读取
|
||||
|
||||
JSONArray(HttpUtil.get("https://gitee.com/nekoshizuku/AwesomeRepo/raw/master/proxy_list.json"))
|
||||
|
||||
}.recoverCatching {
|
||||
|
||||
// 从 GITLAB 读取
|
||||
|
||||
JSONArray(HttpUtil.get("https://gitlab.com/nekohasekai/nekox-proxy-list/-/raw/master/proxy_list.json"))
|
||||
|
||||
}.recoverCatching {
|
||||
|
||||
// 从 GITHUB PAGES 读取
|
||||
|
||||
JSONArray(HttpUtil.get("https://nekox-dev.github.io/ProxyList/proxy_list.json"))
|
||||
|
||||
}.recoverCatching {
|
||||
|
||||
// 从 GITHUB 主站 读取
|
||||
|
||||
val master = HttpUtil.getByteArray("https://github.com/NekoX-Dev/ProxyList/archive/master.zip")
|
||||
|
||||
JSONArray(String(ZipUtil.read(ByteArrayInputStream(master), "ProxyList-master/proxy_list.json")))
|
||||
|
||||
}.getOrNull()?.also { arr ->
|
||||
|
||||
return (0 until arr.length()).map {
|
||||
|
||||
SharedConfig.parseProxyInfo(arr.getJSONObject(it).getString("proxy")).toUrl()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun parseProxies(_text: String): MutableList<String> {
|
||||
|
||||
val text = runCatching {
|
||||
|
||||
Base64.decodeStr(_text)
|
||||
String(Base64.decode(_text, Base64.URL_SAFE))
|
||||
|
||||
}.recover {
|
||||
|
||||
|
|
Loading…
Reference in New Issue