添加备用源推荐信息
This commit is contained in:
parent
a5be17398c
commit
12a2c571f5
|
|
@ -21,7 +21,7 @@ class SplashHelper(private val splashAtyVM: PublicViewMode) {
|
|||
third: (AsyncCallback) -> Unit,
|
||||
callback: (Boolean) -> Unit
|
||||
) {
|
||||
first(createCallback("getHostByGithub method success", "getHostByGithub method failed", callback) {
|
||||
first(createCallback("getHost method success", "getHostByGithub method failed", callback) {
|
||||
second(createCallback("getHostByAWS method success", "getHostByAWS method failed", callback) {
|
||||
third(createCallback("getHost method success", "getHost methods failed", callback) {
|
||||
callback(false) // 所有方法都失败
|
||||
|
|
|
|||
|
|
@ -515,7 +515,7 @@ class UIMainActivity : BaseActivity() {
|
|||
private fun firstEntry() {
|
||||
val decodeBool =
|
||||
MMKV.defaultMMKV().decodeBool(BZYConstants.INITIALIZATION, false)
|
||||
if ((decodeBool)) {
|
||||
if (decodeBool) {
|
||||
MaterialDialog(this).show {
|
||||
cornerRadius(res = R.dimen.dp_10)
|
||||
customView(
|
||||
|
|
@ -555,7 +555,6 @@ class UIMainActivity : BaseActivity() {
|
|||
@Deprecated("Deprecated in Java")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
|
||||
if (requestCode == REQUEST_CODE_PAY_WEB_VIEW_ACTIVITY) {
|
||||
if (activityDialog != null) {
|
||||
activityDialog?.dismiss()
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.yingmao.clash.base
|
|||
|
||||
|
||||
import android.text.TextUtils
|
||||
import com.cncat.vpn.common.log.Log
|
||||
import com.yingmao.clash.net.http.HttpApi
|
||||
import com.yingmao.clash.net.http.NetService
|
||||
import com.orhanobut.logger.Logger
|
||||
|
|
@ -16,7 +17,7 @@ import kotlinx.coroutines.GlobalScope
|
|||
import kotlinx.coroutines.launch
|
||||
import java.util.ArrayList
|
||||
|
||||
open class PublicViewMode: BaseViewMode() {
|
||||
open class PublicViewMode : BaseViewMode() {
|
||||
// fun hasLocalAcl() :Boolean{
|
||||
// val acls = Acl.getFile(Acl.CUSTOM_RULES).readLines()
|
||||
// Logger.d("sss ====> "+acls+"size:${acls.size}")
|
||||
|
|
@ -24,34 +25,38 @@ open class PublicViewMode: BaseViewMode() {
|
|||
// return acls.size > 3
|
||||
// }
|
||||
|
||||
fun getHost(callback: AsyncCallback) {
|
||||
val rt =
|
||||
NetService.instances.createFreeBaseUrl("https://yingmao.oss-cn-hongkong.aliyuncs.com/")
|
||||
doAsyncNoNeedReturn(HttpReqType.GET_HOST) {
|
||||
try { //TODO bug 会引起崩溃
|
||||
var host = if (BuildConfig.is_ym) {
|
||||
rt.getHost()
|
||||
fun getHost(callback: AsyncCallback) {
|
||||
val rt =
|
||||
NetService.instances.createFreeBaseUrl("https://yingmao.oss-cn-hongkong.aliyuncs.com/")
|
||||
doAsyncNoNeedReturn(HttpReqType.GET_HOST) {
|
||||
try { //TODO bug 会引起崩溃
|
||||
var host = if (BuildConfig.is_ym) {
|
||||
rt.getHost()
|
||||
|
||||
} else if (BuildConfig.is_tz) {
|
||||
rt.getHostTZ()
|
||||
} else {
|
||||
rt.getHostDef()
|
||||
}
|
||||
} else if (BuildConfig.is_tz) {
|
||||
rt.getHostTZ()
|
||||
} else {
|
||||
rt.getHostDef()
|
||||
}
|
||||
// Log.e("data", "2:$host")
|
||||
if (!TextUtils.isEmpty(host)) {
|
||||
host = AESUtil.decrypt(host)
|
||||
val hostSet = host.split("+").toSet()
|
||||
MMKV.defaultMMKV().encode(BZYConstants.MMKV_KEY_ROUTER_HOST, hostSet)
|
||||
}
|
||||
host?.takeIf { it.isNotEmpty() }?.let {
|
||||
val decryptedHost = AESUtil.decrypt(it)
|
||||
val hostList = decryptedHost.split("+")
|
||||
if (hostList.isNotEmpty()) {
|
||||
//第一个为推荐域名
|
||||
MMKV.defaultMMKV().encode(BZYConstants.MMKV_KEY_FIRST_HOST, hostList[0])
|
||||
MMKV.defaultMMKV().encode(BZYConstants.MMKV_KEY_ROUTER_HOST, hostList.toSet())
|
||||
}
|
||||
}
|
||||
// Log.e("data", "22:$host")
|
||||
|
||||
callback.suc()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
callback.err()
|
||||
callback.suc()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
callback.err()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getHostByGithub(callback: AsyncCallback) {
|
||||
val rt = NetService.instances.createFreeBaseUrl("https://raw.githubusercontent.com/")
|
||||
|
|
@ -61,19 +66,24 @@ fun getHost(callback: AsyncCallback) {
|
|||
BuildConfig.is_ym -> {
|
||||
rt.getHostGithub()
|
||||
}
|
||||
|
||||
BuildConfig.is_tz -> {
|
||||
rt.getHostTZ()
|
||||
}
|
||||
|
||||
else -> {
|
||||
rt.getHostDef()
|
||||
}
|
||||
}
|
||||
host?.takeIf { it.isNotEmpty() }?.let {
|
||||
com.cncat.vpn.common.log.Log.d("getHostByGithub host-->${it}")
|
||||
val decryptedHost = AESUtil.decrypt(it)
|
||||
com.cncat.vpn.common.log.Log.d("getHostByGithub decryptedHost-->${decryptedHost}")
|
||||
val hostSet = decryptedHost.split("+").toSet()
|
||||
MMKV.defaultMMKV().encode(BZYConstants.MMKV_KEY_ROUTER_HOST, hostSet)
|
||||
val hostList = decryptedHost.split("+")
|
||||
if (hostList.isNotEmpty()) {
|
||||
//第一个为推荐域名
|
||||
MMKV.defaultMMKV().encode(BZYConstants.MMKV_KEY_FIRST_HOST, hostList[0])
|
||||
|
||||
MMKV.defaultMMKV().encode(BZYConstants.MMKV_KEY_ROUTER_HOST, hostList.toSet())
|
||||
}
|
||||
}
|
||||
callback.suc()
|
||||
} catch (e: Exception) {
|
||||
|
|
@ -84,26 +94,31 @@ fun getHost(callback: AsyncCallback) {
|
|||
}
|
||||
|
||||
fun getHostByAWS(callback: AsyncCallback) {
|
||||
val rt = NetService.instances.createFreeBaseUrl("https://yingmao2.s3.ap-east-1.amazonaws.com/")
|
||||
val rt =
|
||||
NetService.instances.createFreeBaseUrl("https://yingmao2.s3.ap-east-1.amazonaws.com/")
|
||||
doAsyncNoNeedReturn(HttpReqType.GET_HOST) {
|
||||
try {
|
||||
val host = when {
|
||||
BuildConfig.is_ym -> {
|
||||
rt.getHostAWS()
|
||||
}
|
||||
|
||||
BuildConfig.is_tz -> {
|
||||
rt.getHostTZ()
|
||||
}
|
||||
|
||||
else -> {
|
||||
rt.getHostDef()
|
||||
}
|
||||
}
|
||||
host?.takeIf { it.isNotEmpty() }?.let {
|
||||
com.cncat.vpn.common.log.Log.d("getHostByAWS host-->${it}")
|
||||
val decryptedHost = AESUtil.decrypt(it)
|
||||
com.cncat.vpn.common.log.Log.d("getHostByAWS decryptedHost-->${decryptedHost}")
|
||||
val hostSet = decryptedHost.split("+").toSet()
|
||||
MMKV.defaultMMKV().encode(BZYConstants.MMKV_KEY_ROUTER_HOST, hostSet)
|
||||
val hostList = decryptedHost.split("+")
|
||||
if (hostList.isNotEmpty()) {
|
||||
//第一个为推荐域名
|
||||
MMKV.defaultMMKV().encode(BZYConstants.MMKV_KEY_FIRST_HOST, hostList[0])
|
||||
MMKV.defaultMMKV().encode(BZYConstants.MMKV_KEY_ROUTER_HOST, hostList.toSet())
|
||||
}
|
||||
}
|
||||
callback.suc()
|
||||
} catch (e: Exception) {
|
||||
|
|
@ -113,47 +128,48 @@ fun getHost(callback: AsyncCallback) {
|
|||
}
|
||||
}
|
||||
|
||||
fun getServiceAclAndSet(){
|
||||
fun getServiceAclAndSet() {
|
||||
val httpApi = NetService.instances.createHttpsEncodeStr(HttpApi::class.java)
|
||||
GlobalScope.launch {
|
||||
val rsp = doAsyncEncodeStrBg(DomainRsp::class.java) { httpApi.getDomain()}
|
||||
val rsp = doAsyncEncodeStrBg(DomainRsp::class.java) { httpApi.getDomain() }
|
||||
Logger.d("~~~~~! ${rsp}")
|
||||
val acls = ArrayList<String>()
|
||||
// proxyPattern:0:全局,1:代理
|
||||
(rsp as DomainRsp).let {
|
||||
if(it.data?.proxyPattern == 0){
|
||||
if (it.data?.proxyPattern == 0) {
|
||||
acls.add("[proxy_all]")
|
||||
acls.add("[bypass_list]")
|
||||
}else{
|
||||
} else {
|
||||
acls.add("[bypass_all]")
|
||||
acls.add("[proxy_list]")
|
||||
}
|
||||
|
||||
it.data?.domain?.let { domains -> domains.forEach { domain ->
|
||||
var domainFormat = domain
|
||||
it.data?.domain?.let { domains ->
|
||||
domains.forEach { domain ->
|
||||
var domainFormat = domain
|
||||
// domainFormat =domainFormat.replace(".","\\.")
|
||||
Logger.d("domainFormat : $domainFormat")
|
||||
if(domainFormat.startsWith( "https://www.",true)){
|
||||
domainFormat = domainFormat.replaceFirst("https://www.","")
|
||||
Logger.d("domainFormat 1 : $domainFormat")
|
||||
}else{
|
||||
Logger.d("domainFormat : $domainFormat")
|
||||
if (domainFormat.startsWith("https://www.", true)) {
|
||||
domainFormat = domainFormat.replaceFirst("https://www.", "")
|
||||
Logger.d("domainFormat 1 : $domainFormat")
|
||||
} else {
|
||||
// domainFormat = "(^|\\.)${domainFormat}"
|
||||
Logger.d("domainFormat 2 : $domainFormat")
|
||||
}
|
||||
if(domainFormat.endsWith("/")){
|
||||
domainFormat = domainFormat.substring(0,domainFormat.lastIndex)
|
||||
Logger.d("domainFormat 3 : $domainFormat")
|
||||
}
|
||||
Logger.d("domainFormat 2 : $domainFormat")
|
||||
}
|
||||
if (domainFormat.endsWith("/")) {
|
||||
domainFormat = domainFormat.substring(0, domainFormat.lastIndex)
|
||||
Logger.d("domainFormat 3 : $domainFormat")
|
||||
}
|
||||
// domainFormat = "${domainFormat}$"
|
||||
Logger.d("domainFormat 11 : $domainFormat")
|
||||
acls.add(domainFormat)
|
||||
//youtobe 播放视频需要添加的域名
|
||||
Logger.d("domainFormat 11 : $domainFormat")
|
||||
acls.add(domainFormat)
|
||||
//youtobe 播放视频需要添加的域名
|
||||
// acls.add("youtu.be")
|
||||
// acls.add("youtube.com")
|
||||
// acls.add("ytimg.com")
|
||||
// acls.add("googlevideo.com")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Acl.getFile(Acl.CUSTOM_RULES).printWriter().use {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class BZYConstants {
|
|||
const val MMKV_KEY_OLD_CURRENT_HOST = "old_current_host"
|
||||
//备用地址
|
||||
const val MMKV_KEY_ROUTER_HOST ="router_host"
|
||||
const val MMKV_KEY_FIRST_HOST ="first_host"
|
||||
const val MMKV_KEY_Airport_Base64 ="airport_base64"
|
||||
//注册地址
|
||||
const val MMKV_KEY_REGISTER_HOST ="register_host"
|
||||
|
|
|
|||
|
|
@ -509,7 +509,7 @@ class SettingFragment: BaseFragment(), CoroutineScope by CoroutineScope(Dispatch
|
|||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_CURRENT_NODE)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.NODE_SELECTED_NAME_KEY)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_VPN_UserCommand)
|
||||
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.NODE_All_ITEM_NAME_KEY)
|
||||
Log.d("cleanUserInfo clashRunning==>${clashRunning}")
|
||||
if (clashRunning) {
|
||||
fragments.filterIsInstance<HomeFragment>().forEach { it.stopClash() }
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import com.google.android.material.radiobutton.MaterialRadioButton
|
|||
import com.yingmao.clash.R
|
||||
import com.yingmao.clash.entity.ClashNodebBean
|
||||
import com.cncat.vpn.service.model.Profile
|
||||
import com.tencent.mmkv.MMKV
|
||||
import com.yingmao.clash.conf.BZYConstants
|
||||
import com.yingmao.clash.entity.DomainItemBean
|
||||
import com.yingmao.clash.util.Utils
|
||||
|
||||
|
|
@ -38,7 +40,13 @@ class DomainListAdapter(layoutResId: Int) :
|
|||
}
|
||||
val addressName = holder.getView<TextView>(R.id.domain_list_item_tv_address_name)
|
||||
if (!TextUtils.isEmpty(item.address)) {
|
||||
addressName.text = item.address.replace(Regex("https://"), "")
|
||||
var mmkv = MMKV.defaultMMKV()
|
||||
val fhost = mmkv.decodeString(BZYConstants.MMKV_KEY_FIRST_HOST, "")
|
||||
var showAddress= item.address.replace(Regex("https://"), "")
|
||||
if (item.address==fhost){
|
||||
showAddress+=" (推荐)"
|
||||
}
|
||||
addressName.text =showAddress
|
||||
}
|
||||
// addressName.text = "地址${addressIndex}"
|
||||
addressIndex++
|
||||
|
|
|
|||
Loading…
Reference in New Issue