Optimized code
This commit is contained in:
1 parent
ee5a3b0dd9
commit
a5287dbadc
18 files changed
+58
-79
No files matched your search
@@ -1,32 +0,0 @@
|
|||||||
package com.v2ray.ang.dto
|
|
||||||
|
|
||||||
data class AngConfig(
|
|
||||||
var index: Int,
|
|
||||||
var vmess: ArrayList<VmessBean>,
|
|
||||||
var subItem: ArrayList<SubItemBean>
|
|
||||||
) {
|
|
||||||
data class VmessBean(var guid: String = "123456",
|
|
||||||
var address: String = "v2ray.cool",
|
|
||||||
var port: Int = 10086,
|
|
||||||
var id: String = "a3482e88-686a-4a58-8126-99c9df64b7bf",
|
|
||||||
var alterId: Int = 64,
|
|
||||||
var security: String = "aes-128-cfb",
|
|
||||||
var network: String = "tcp",
|
|
||||||
var remarks: String = "def",
|
|
||||||
var headerType: String = "",
|
|
||||||
var requestHost: String = "",
|
|
||||||
var path: String = "",
|
|
||||||
var streamSecurity: String = "",
|
|
||||||
var allowInsecure: String = "",
|
|
||||||
var configType: Int = 1,
|
|
||||||
var configVersion: Int = 1,
|
|
||||||
var testResult: String = "",
|
|
||||||
var subid: String = "",
|
|
||||||
var flow: String = "",
|
|
||||||
var sni: String = "")
|
|
||||||
|
|
||||||
data class SubItemBean(var id: String = "",
|
|
||||||
var remarks: String = "",
|
|
||||||
var url: String = "",
|
|
||||||
var enabled: Boolean = true)
|
|
||||||
}
|
|
||||||
@@ -157,7 +157,7 @@ data class V2rayConfig(
|
|||||||
var headers: HeadersBean = HeadersBean(),
|
var headers: HeadersBean = HeadersBean(),
|
||||||
val version: String? = null,
|
val version: String? = null,
|
||||||
val method: String? = null) {
|
val method: String? = null) {
|
||||||
data class HeadersBean(var Host: List<String> = ArrayList(),
|
data class HeadersBean(var Host: List<String>? = ArrayList(),
|
||||||
@SerializedName("User-Agent")
|
@SerializedName("User-Agent")
|
||||||
val userAgent: List<String>? = null,
|
val userAgent: List<String>? = null,
|
||||||
@SerializedName("Accept-Encoding")
|
@SerializedName("Accept-Encoding")
|
||||||
@@ -247,7 +247,7 @@ data class V2rayConfig(
|
|||||||
requestObj.headers.Host = (host ?: "").split(",").map { it.trim() }.filter { it.isNotEmpty() }
|
requestObj.headers.Host = (host ?: "").split(",").map { it.trim() }.filter { it.isNotEmpty() }
|
||||||
requestObj.path = (path ?: "").split(",").map { it.trim() }.filter { it.isNotEmpty() }
|
requestObj.path = (path ?: "").split(",").map { it.trim() }.filter { it.isNotEmpty() }
|
||||||
tcpSetting.header.request = requestObj
|
tcpSetting.header.request = requestObj
|
||||||
sni = requestObj.headers.Host.getOrNull(0) ?: sni
|
sni = requestObj.headers.Host?.getOrNull(0) ?: sni
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tcpSetting.header.type = "none"
|
tcpSetting.header.type = "none"
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ object SubscriptionUpdater {
|
|||||||
|
|
||||||
val count = AngConfigManager.importBatchConfig(server, subid, append)
|
val count = AngConfigManager.importBatchConfig(server, subid, append)
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
AngConfigManager.importBatchConfig(Utils.decode(server!!), subid, append)
|
AngConfigManager.importBatchConfig(Utils.decode(server), subid, append)
|
||||||
}
|
}
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
AngConfigManager.appendCustomConfigServer(server, subid)
|
AngConfigManager.appendCustomConfigServer(server, subid)
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ class MainRecyclerAdapter(val activity: MainActivity) : RecyclerView.Adapter<Mai
|
|||||||
if (guid != selected) {
|
if (guid != selected) {
|
||||||
mainStorage?.encode(MmkvManager.KEY_SELECTED_SERVER, guid)
|
mainStorage?.encode(MmkvManager.KEY_SELECTED_SERVER, guid)
|
||||||
if (!TextUtils.isEmpty(selected)) {
|
if (!TextUtils.isEmpty(selected)) {
|
||||||
notifyItemChanged(mActivity.mainViewModel.getPosition(selected!!))
|
notifyItemChanged(mActivity.mainViewModel.getPosition(selected?:""))
|
||||||
}
|
}
|
||||||
notifyItemChanged(mActivity.mainViewModel.getPosition(guid))
|
notifyItemChanged(mActivity.mainViewModel.getPosition(guid))
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class PerAppProxyActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onQueryTextChange(newText: String?): Boolean {
|
override fun onQueryTextChange(newText: String?): Boolean {
|
||||||
filterProxyApp(newText!!)
|
filterProxyApp(newText?:"")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -209,12 +209,12 @@ class PerAppProxyActivity : BaseActivity() {
|
|||||||
if (it.blacklist.containsAll(pkgNames)) {
|
if (it.blacklist.containsAll(pkgNames)) {
|
||||||
it.apps.forEach {
|
it.apps.forEach {
|
||||||
val packageName = it.packageName
|
val packageName = it.packageName
|
||||||
adapter?.blacklist!!.remove(packageName)
|
adapter?.blacklist?.remove(packageName)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
it.apps.forEach {
|
it.apps.forEach {
|
||||||
val packageName = it.packageName
|
val packageName = it.packageName
|
||||||
adapter?.blacklist!!.add(packageName)
|
adapter?.blacklist?.add(packageName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it.notifyDataSetChanged()
|
it.notifyDataSetChanged()
|
||||||
@@ -278,7 +278,7 @@ class PerAppProxyActivity : BaseActivity() {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter?.blacklist!!.clear()
|
adapter?.blacklist?.clear()
|
||||||
|
|
||||||
if (binding.switchBypassApps.isChecked) {
|
if (binding.switchBypassApps.isChecked) {
|
||||||
adapter?.let {
|
adapter?.let {
|
||||||
@@ -286,7 +286,7 @@ class PerAppProxyActivity : BaseActivity() {
|
|||||||
val packageName = it.packageName
|
val packageName = it.packageName
|
||||||
Log.d(ANG_PACKAGE, packageName)
|
Log.d(ANG_PACKAGE, packageName)
|
||||||
if (!inProxyApps(proxyApps, packageName, force)) {
|
if (!inProxyApps(proxyApps, packageName, force)) {
|
||||||
adapter?.blacklist!!.add(packageName)
|
adapter?.blacklist?.add(packageName)
|
||||||
println(packageName)
|
println(packageName)
|
||||||
return@block
|
return@block
|
||||||
}
|
}
|
||||||
@@ -299,7 +299,7 @@ class PerAppProxyActivity : BaseActivity() {
|
|||||||
val packageName = it.packageName
|
val packageName = it.packageName
|
||||||
Log.d(ANG_PACKAGE, packageName)
|
Log.d(ANG_PACKAGE, packageName)
|
||||||
if (inProxyApps(proxyApps, packageName, force)) {
|
if (inProxyApps(proxyApps, packageName, force)) {
|
||||||
adapter?.blacklist!!.add(packageName)
|
adapter?.blacklist?.add(packageName)
|
||||||
println(packageName)
|
println(packageName)
|
||||||
return@block
|
return@block
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class RoutingSettingsFragment : Fragment() {
|
|||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
val content = settingsStorage?.getString(requireArguments().getString(routing_arg), "")
|
val content = settingsStorage?.getString(requireArguments().getString(routing_arg), "")
|
||||||
binding.etRoutingContent.text = Utils.getEditable(content!!)
|
binding.etRoutingContent.text = Utils.getEditable(content)
|
||||||
|
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ class RoutingSettingsFragment : Fragment() {
|
|||||||
private val scanQRCodeForReplace = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
private val scanQRCodeForReplace = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||||
if (it.resultCode == RESULT_OK) {
|
if (it.resultCode == RESULT_OK) {
|
||||||
val content = it.data?.getStringExtra("SCAN_RESULT")
|
val content = it.data?.getStringExtra("SCAN_RESULT")
|
||||||
binding.etRoutingContent.text = Utils.getEditable(content!!)
|
binding.etRoutingContent.text = Utils.getEditable(content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ class RoutingSettingsFragment : Fragment() {
|
|||||||
val content = Utils.getUrlContext(url, 5000)
|
val content = Utils.getUrlContext(url, 5000)
|
||||||
launch(Dispatchers.Main) {
|
launch(Dispatchers.Main) {
|
||||||
val routingList = if (TextUtils.isEmpty(content)) {
|
val routingList = if (TextUtils.isEmpty(content)) {
|
||||||
Utils.readTextFromAssets(activity?.v2RayApplication!!, "custom_routing_$tag")
|
Utils.readTextFromAssets(activity?.v2RayApplication, "custom_routing_$tag")
|
||||||
} else {
|
} else {
|
||||||
content
|
content
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class ScannerActivity : BaseActivity(){
|
|||||||
|
|
||||||
private fun handleResult(result: QRResult) {
|
private fun handleResult(result: QRResult) {
|
||||||
if (result is QRResult.QRSuccess ) {
|
if (result is QRResult.QRSuccess ) {
|
||||||
finished(result.content.rawValue!!)
|
finished(result.content.rawValue?:"")
|
||||||
} else {
|
} else {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ class ScannerActivity : BaseActivity(){
|
|||||||
try {
|
try {
|
||||||
val bitmap = BitmapFactory.decodeStream(contentResolver.openInputStream(uri))
|
val bitmap = BitmapFactory.decodeStream(contentResolver.openInputStream(uri))
|
||||||
val text = QRCodeDecoder.syncDecodeQRCode(bitmap)
|
val text = QRCodeDecoder.syncDecodeQRCode(bitmap)
|
||||||
finished(text!!)
|
finished(text?:"")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
toast(e.message.toString())
|
toast(e.message.toString())
|
||||||
|
|||||||
@@ -5,10 +5,14 @@ import android.text.TextUtils
|
|||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.*
|
import android.widget.AdapterView
|
||||||
|
import android.widget.ArrayAdapter
|
||||||
|
import android.widget.EditText
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.Spinner
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.tencent.mmkv.MMKV
|
import com.tencent.mmkv.MMKV
|
||||||
import com.v2ray.ang.AngApplication
|
|
||||||
import com.v2ray.ang.AppConfig
|
import com.v2ray.ang.AppConfig
|
||||||
import com.v2ray.ang.AppConfig.PREF_ALLOW_INSECURE
|
import com.v2ray.ang.AppConfig.PREF_ALLOW_INSECURE
|
||||||
import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_ADDRESS_V4
|
import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_ADDRESS_V4
|
||||||
@@ -286,7 +290,7 @@ class ServerActivity : BaseActivity() {
|
|||||||
tlsSetting.alpn?.let {
|
tlsSetting.alpn?.let {
|
||||||
val alpnIndex = Utils.arrayFind(
|
val alpnIndex = Utils.arrayFind(
|
||||||
alpns,
|
alpns,
|
||||||
Utils.removeWhiteSpace(tlsSetting.alpn.joinToString())!!
|
Utils.removeWhiteSpace(tlsSetting.alpn.joinToString())?:""
|
||||||
)
|
)
|
||||||
sp_stream_alpn?.setSelection(alpnIndex)
|
sp_stream_alpn?.setSelection(alpnIndex)
|
||||||
}
|
}
|
||||||
@@ -414,7 +418,7 @@ class ServerActivity : BaseActivity() {
|
|||||||
saveStreamSettings(it)
|
saveStreamSettings(it)
|
||||||
}
|
}
|
||||||
if (config.subscriptionId.isEmpty() && !subscriptionId.isNullOrEmpty()) {
|
if (config.subscriptionId.isEmpty() && !subscriptionId.isNullOrEmpty()) {
|
||||||
config.subscriptionId = subscriptionId!!
|
config.subscriptionId = subscriptionId?:""
|
||||||
}
|
}
|
||||||
|
|
||||||
MmkvManager.encodeServerConfig(editGuid, config)
|
MmkvManager.encodeServerConfig(editGuid, config)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class TaskerActivity : BaseActivity() {
|
|||||||
val adapter = ArrayAdapter(this,
|
val adapter = ArrayAdapter(this,
|
||||||
android.R.layout.simple_list_item_single_choice, lstData)
|
android.R.layout.simple_list_item_single_choice, lstData)
|
||||||
listview = findViewById<View>(R.id.listview) as ListView
|
listview = findViewById<View>(R.id.listview) as ListView
|
||||||
listview!!.adapter = adapter
|
listview?.adapter = adapter
|
||||||
|
|
||||||
init()
|
init()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ object Utils {
|
|||||||
* @param text
|
* @param text
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
fun getEditable(text: String): Editable {
|
fun getEditable(text: String?): Editable {
|
||||||
return Editable.Factory.getInstance().newEditable(text)
|
return Editable.Factory.getInstance().newEditable(text?:"")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,16 +101,16 @@ object Utils {
|
|||||||
/**
|
/**
|
||||||
* base64 decode
|
* base64 decode
|
||||||
*/
|
*/
|
||||||
fun decode(text: String): String {
|
fun decode(text: String?): String {
|
||||||
tryDecodeBase64(text)?.let { return it }
|
tryDecodeBase64(text)?.let { return it }
|
||||||
if (text.endsWith('=')) {
|
if (text?.endsWith('=')==true) {
|
||||||
// try again for some loosely formatted base64
|
// try again for some loosely formatted base64
|
||||||
tryDecodeBase64(text.trimEnd('='))?.let { return it }
|
tryDecodeBase64(text.trimEnd('='))?.let { return it }
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
fun tryDecodeBase64(text: String): String? {
|
fun tryDecodeBase64(text: String?): String? {
|
||||||
try {
|
try {
|
||||||
return Base64.decode(text, Base64.NO_WRAP).toString(charset("UTF-8"))
|
return Base64.decode(text, Base64.NO_WRAP).toString(charset("UTF-8"))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -302,7 +302,11 @@ object Utils {
|
|||||||
/**
|
/**
|
||||||
* readTextFromAssets
|
* readTextFromAssets
|
||||||
*/
|
*/
|
||||||
fun readTextFromAssets(context: Context, fileName: String): String {
|
fun readTextFromAssets(context: Context?, fileName: String): String {
|
||||||
|
if(context == null)
|
||||||
|
{
|
||||||
|
return ""
|
||||||
|
}
|
||||||
val content = context.assets.open(fileName).bufferedReader().use {
|
val content = context.assets.open(fileName).bufferedReader().use {
|
||||||
it.readText()
|
it.readText()
|
||||||
}
|
}
|
||||||
@@ -389,7 +393,10 @@ object Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getIpv6Address(address: String): String {
|
fun getIpv6Address(address: String?): String {
|
||||||
|
if(address == null){
|
||||||
|
return ""
|
||||||
|
}
|
||||||
return if (isIpv6Address(address) && !address.contains('[') && !address.contains(']')) {
|
return if (isIpv6Address(address) && !address.contains('[') && !address.contains(']')) {
|
||||||
String.format("[%s]", address)
|
String.format("[%s]", address)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -295,10 +295,10 @@ object V2rayConfigUtil {
|
|||||||
rulesDomain.domain?.add(it)
|
rulesDomain.domain?.add(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rulesDomain.domain?.size!! > 0) {
|
if ((rulesDomain.domain?.size ?: 0) > 0) {
|
||||||
v2rayConfig.routing.rules.add(rulesDomain)
|
v2rayConfig.routing.rules.add(rulesDomain)
|
||||||
}
|
}
|
||||||
if (rulesIP.ip?.size!! > 0) {
|
if ((rulesIP.ip?.size ?: 0) > 0) {
|
||||||
v2rayConfig.routing.rules.add(rulesIP)
|
v2rayConfig.routing.rules.add(rulesIP)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -560,7 +560,7 @@ object V2rayConfigUtil {
|
|||||||
} else {
|
} else {
|
||||||
path
|
path
|
||||||
}
|
}
|
||||||
outbound.streamSettings?.tcpSettings?.header?.request?.headers?.Host = host!!
|
outbound.streamSettings?.tcpSettings?.header?.request?.headers?.Host = host
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ object ShadowsocksFmt {
|
|||||||
val url = String.format(
|
val url = String.format(
|
||||||
"%s@%s:%s",
|
"%s@%s:%s",
|
||||||
pw,
|
pw,
|
||||||
Utils.getIpv6Address(outbound.getServerAddress()!!),
|
Utils.getIpv6Address(outbound.getServerAddress()),
|
||||||
outbound.getServerPort()
|
outbound.getServerPort()
|
||||||
)
|
)
|
||||||
return url + remark
|
return url + remark
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ object SocksFmt {
|
|||||||
val url = String.format(
|
val url = String.format(
|
||||||
"%s@%s:%s",
|
"%s@%s:%s",
|
||||||
Utils.encode(pw),
|
Utils.encode(pw),
|
||||||
Utils.getIpv6Address(outbound.getServerAddress()!!),
|
Utils.getIpv6Address(outbound.getServerAddress()),
|
||||||
outbound.getServerPort()
|
outbound.getServerPort()
|
||||||
)
|
)
|
||||||
return url + remark
|
return url + remark
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ object TrojanFmt {
|
|||||||
fingerprint = queryParam["fp"] ?: ""
|
fingerprint = queryParam["fp"] ?: ""
|
||||||
config.outboundBean?.streamSettings?.populateTlsSettings(
|
config.outboundBean?.streamSettings?.populateTlsSettings(
|
||||||
queryParam["security"] ?: V2rayConfig.TLS,
|
queryParam["security"] ?: V2rayConfig.TLS,
|
||||||
allowInsecure, queryParam["sni"] ?: sni!!, fingerprint, queryParam["alpn"],
|
allowInsecure, queryParam["sni"] ?: sni?:"", fingerprint, queryParam["alpn"],
|
||||||
null, null, null
|
null, null, null
|
||||||
)
|
)
|
||||||
flow = queryParam["flow"] ?: ""
|
flow = queryParam["flow"] ?: ""
|
||||||
@@ -92,16 +92,16 @@ object TrojanFmt {
|
|||||||
Utils.removeWhiteSpace(tlsSetting.alpn.joinToString()).orEmpty()
|
Utils.removeWhiteSpace(tlsSetting.alpn.joinToString()).orEmpty()
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(tlsSetting.fingerprint)) {
|
if (!TextUtils.isEmpty(tlsSetting.fingerprint)) {
|
||||||
dicQuery["fp"] = tlsSetting.fingerprint!!
|
dicQuery["fp"] = tlsSetting.fingerprint?:""
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(tlsSetting.publicKey)) {
|
if (!TextUtils.isEmpty(tlsSetting.publicKey)) {
|
||||||
dicQuery["pbk"] = tlsSetting.publicKey!!
|
dicQuery["pbk"] = tlsSetting.publicKey?:""
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(tlsSetting.shortId)) {
|
if (!TextUtils.isEmpty(tlsSetting.shortId)) {
|
||||||
dicQuery["sid"] = tlsSetting.shortId!!
|
dicQuery["sid"] = tlsSetting.shortId?:""
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(tlsSetting.spiderX)) {
|
if (!TextUtils.isEmpty(tlsSetting.spiderX)) {
|
||||||
dicQuery["spx"] = Utils.urlEncode(tlsSetting.spiderX!!)
|
dicQuery["spx"] = Utils.urlEncode(tlsSetting.spiderX?:"")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dicQuery["type"] =
|
dicQuery["type"] =
|
||||||
@@ -162,7 +162,7 @@ object TrojanFmt {
|
|||||||
val url = String.format(
|
val url = String.format(
|
||||||
"%s@%s:%s",
|
"%s@%s:%s",
|
||||||
outbound.getPassword(),
|
outbound.getPassword(),
|
||||||
Utils.getIpv6Address(outbound.getServerAddress()!!),
|
Utils.getIpv6Address(outbound.getServerAddress()),
|
||||||
outbound.getServerPort()
|
outbound.getServerPort()
|
||||||
)
|
)
|
||||||
return url + query + remark
|
return url + query + remark
|
||||||
|
|||||||
@@ -92,16 +92,16 @@ object VlessFmt {
|
|||||||
Utils.removeWhiteSpace(tlsSetting.alpn.joinToString()).orEmpty()
|
Utils.removeWhiteSpace(tlsSetting.alpn.joinToString()).orEmpty()
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(tlsSetting.fingerprint)) {
|
if (!TextUtils.isEmpty(tlsSetting.fingerprint)) {
|
||||||
dicQuery["fp"] = tlsSetting.fingerprint!!
|
dicQuery["fp"] = tlsSetting.fingerprint?:""
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(tlsSetting.publicKey)) {
|
if (!TextUtils.isEmpty(tlsSetting.publicKey)) {
|
||||||
dicQuery["pbk"] = tlsSetting.publicKey!!
|
dicQuery["pbk"] = tlsSetting.publicKey?:""
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(tlsSetting.shortId)) {
|
if (!TextUtils.isEmpty(tlsSetting.shortId)) {
|
||||||
dicQuery["sid"] = tlsSetting.shortId!!
|
dicQuery["sid"] = tlsSetting.shortId?:""
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(tlsSetting.spiderX)) {
|
if (!TextUtils.isEmpty(tlsSetting.spiderX)) {
|
||||||
dicQuery["spx"] = Utils.urlEncode(tlsSetting.spiderX!!)
|
dicQuery["spx"] = Utils.urlEncode(tlsSetting.spiderX?:"")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dicQuery["type"] =
|
dicQuery["type"] =
|
||||||
@@ -162,7 +162,7 @@ object VlessFmt {
|
|||||||
val url = String.format(
|
val url = String.format(
|
||||||
"%s@%s:%s",
|
"%s@%s:%s",
|
||||||
outbound.getPassword(),
|
outbound.getPassword(),
|
||||||
Utils.getIpv6Address(outbound.getServerAddress()!!),
|
Utils.getIpv6Address(outbound.getServerAddress()),
|
||||||
outbound.getServerPort()
|
outbound.getServerPort()
|
||||||
)
|
)
|
||||||
return url + query + remark
|
return url + query + remark
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ object WireguardFmt {
|
|||||||
val url = String.format(
|
val url = String.format(
|
||||||
"%s@%s:%s",
|
"%s@%s:%s",
|
||||||
Utils.urlEncode(outbound.getPassword().toString()),
|
Utils.urlEncode(outbound.getPassword().toString()),
|
||||||
Utils.getIpv6Address(outbound.getServerAddress()!!),
|
Utils.getIpv6Address(outbound.getServerAddress()),
|
||||||
outbound.getServerPort()
|
outbound.getServerPort()
|
||||||
)
|
)
|
||||||
return url + query + remark
|
return url + query + remark
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var serverList = MmkvManager.decodeServerList()
|
var serverList = MmkvManager.decodeServerList()
|
||||||
var subscriptionId: String = settingsStorage.decodeString(AppConfig.CACHE_SUBSCRIPTION_ID, "")!!
|
var subscriptionId: String = settingsStorage.decodeString(AppConfig.CACHE_SUBSCRIPTION_ID, "")?:""
|
||||||
var keywordFilter: String = settingsStorage.decodeString(AppConfig.CACHE_KEYWORD_FILTER, "")!!
|
var keywordFilter: String = settingsStorage.decodeString(AppConfig.CACHE_KEYWORD_FILTER, "")?:""
|
||||||
private set
|
private set
|
||||||
val serversCache = mutableListOf<ServersCache>()
|
val serversCache = mutableListOf<ServersCache>()
|
||||||
val isRunning by lazy { MutableLiveData<Boolean>() }
|
val isRunning by lazy { MutableLiveData<Boolean>() }
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class SubViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
fun importBatchConfig(server: String?, subid: String = "", append: Boolean): Int {
|
fun importBatchConfig(server: String?, subid: String = "", append: Boolean): Int {
|
||||||
var count = AngConfigManager.importBatchConfig(server, subid, append)
|
var count = AngConfigManager.importBatchConfig(server, subid, append)
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
count = AngConfigManager.importBatchConfig(Utils.decode(server!!), subid, append)
|
count = AngConfigManager.importBatchConfig(Utils.decode(server), subid, append)
|
||||||
}
|
}
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
count = AngConfigManager.appendCustomConfigServer(server, subid)
|
count = AngConfigManager.appendCustomConfigServer(server, subid)
|
||||||
|
|||||||
Reference in new issue
Block a user