Compare commits

...

8 Commits

Author SHA1 Message Date
2dust
13480b0077 up1.7.21 2022-10-14 20:33:10 +08:00
2dust
1987880294 Merge pull request #1689 from BI7PRK/master
Add uTLS option
2022-10-14 20:01:32 +08:00
xskill
0ae459a70e Add uTLS option 2022-10-13 15:07:10 +08:00
2dust
02bc46634d Update README.md 2022-10-10 20:24:52 +08:00
2dust
cfdaa0c54b Update build.gradle 2022-09-19 20:42:01 +08:00
2dust
cbe6c1e3e0 Update build.gradle 2022-09-19 20:25:48 +08:00
2dust
3cd6f12b94 Merge pull request #1639 from zhaoguomanong/master
fix NullPointerException
2022-09-10 19:51:19 +08:00
zhaoguomanong
516235cd6a fix NullPointerException
复现方法:
添加两个订阅A, B -> 选择A中任意节点并启动 -> 删除A订阅, 选中B订阅中任意节点启动 -> crash

09-09 10:53:50.355 18739 18739 D AndroidRuntime: Shutting down VM
09-09 10:53:50.356 18739 18739 E AndroidRuntime: FATAL EXCEPTION: main
09-09 10:53:50.356 18739 18739 E AndroidRuntime: Process: com.v2ray.ang, PID: 18739
09-09 10:53:50.356 18739 18739 E AndroidRuntime: java.lang.NullPointerException
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at com.v2ray.ang.ui.MainRecyclerAdapter.onBindViewHolder$lambda-6(MainRecyclerAdapter.kt:156)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at com.v2ray.ang.ui.MainRecyclerAdapter.$r8$lambda$VmDbsAxtrWNiVtS0BmO3UDui2o4(Unknown Source:0)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at com.v2ray.ang.ui.MainRecyclerAdapter$$ExternalSyntheticLambda2.onClick(Unknown Source:4)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at android.view.View.performClick(View.java:6597)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at android.view.View.performClickInternal(View.java:6574)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at android.view.View.access$3100(View.java:778)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at android.view.View$PerformClick.run(View.java:25906)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:873)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:193)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6718)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
09-09 10:53:50.356 18739 18739 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Signed-off-by: zhaoguomanong <zhaoguomanong@gmail.com>
2022-09-09 13:12:15 +08:00
12 changed files with 142 additions and 187 deletions

View File

@@ -13,6 +13,9 @@ A V2Ray client for Android, support [Xray core](https://github.com/XTLS/Xray-cor
<img alt="Get it on Google Play" src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" width="165" height="64" />
</a>
### Telegram Channel
[github_2dust](https://t.me/github_2dust)
### Usage
#### Geoip and Geosite

View File

@@ -18,8 +18,8 @@ android {
minSdkVersion 21
targetSdkVersion Integer.parseInt("$targetSdkVer")
multiDexEnabled true
versionCode 473
versionName "1.7.19"
versionCode 476
versionName "1.7.21"
}
if (props["sign"]) {

View File

@@ -259,11 +259,12 @@ data class V2rayConfig(
return sni
}
fun populateTlsSettings(streamSecurity: String, allowInsecure: Boolean, sni: String) {
fun populateTlsSettings(streamSecurity: String, allowInsecure: Boolean, sni: String, fingerprint: String?) {
security = streamSecurity
val tlsSetting = TlsSettingsBean(
allowInsecure = allowInsecure,
serverName = sni
serverName = sni,
fingerprint = fingerprint
)
if (security == TLS) {
tlsSettings = tlsSetting

View File

@@ -2,6 +2,7 @@ package com.v2ray.ang.ui
import android.content.Intent
import android.graphics.Color
import android.text.TextUtils
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
@@ -153,7 +154,9 @@ class MainRecyclerAdapter(val activity: MainActivity) : RecyclerView.Adapter<Mai
val selected = mainStorage?.decodeString(MmkvManager.KEY_SELECTED_SERVER)
if (guid != selected) {
mainStorage?.encode(MmkvManager.KEY_SELECTED_SERVER, guid)
notifyItemChanged(mActivity.mainViewModel.getPosition(selected!!))
if (!TextUtils.isEmpty(selected)) {
notifyItemChanged(mActivity.mainViewModel.getPosition(selected!!))
}
notifyItemChanged(mActivity.mainViewModel.getPosition(guid))
if (isRunning) {
mActivity.showCircle()

View File

@@ -67,7 +67,9 @@ class ServerActivity : BaseActivity() {
private val allowinsecures: Array<out String> by lazy {
resources.getStringArray(R.array.allowinsecures)
}
private val uTlsItems: Array<out String> by lazy {
resources.getStringArray(R.array.streamsecurity_utls)
}
// Kotlin synthetics was used, but since it is removed in 1.8. We switch to old manual approach.
// We don't use AndroidViewBinding because, it is better to share similar logics for different
// protocols. Use findViewById manually ensures the xml are de-coupled with the activity logic.
@@ -82,6 +84,7 @@ class ServerActivity : BaseActivity() {
private val sp_stream_security: Spinner? by lazy { findViewById(R.id.sp_stream_security) }
private val sp_allow_insecure: Spinner? by lazy { findViewById(R.id.sp_allow_insecure) }
private val et_sni: EditText? by lazy { findViewById(R.id.et_sni) }
private val sp_stream_fingerprint: Spinner? by lazy { findViewById(R.id.sp_stream_fingerprint) } //uTLS
private val sp_network: Spinner? by lazy { findViewById(R.id.sp_network) }
private val sp_header_type: Spinner? by lazy { findViewById(R.id.sp_header_type) }
private val sp_header_type_title: TextView? by lazy { findViewById(R.id.sp_header_type_title) }
@@ -170,6 +173,12 @@ class ServerActivity : BaseActivity() {
sp_allow_insecure?.setSelection(allowinsecure)
}
et_sni?.text = Utils.getEditable(tlsSetting.serverName)
tlsSetting.fingerprint?.let {
val utlsIndex = Utils.arrayFind(uTlsItems, tlsSetting.fingerprint)
sp_stream_fingerprint?.setSelection(utlsIndex)
}
}
}
val network = Utils.arrayFind(networks, streamSetting.network)
@@ -310,6 +319,7 @@ class ServerActivity : BaseActivity() {
val sniField = et_sni?.text?.toString()?.trim() ?: return
val allowInsecureField = sp_allow_insecure?.selectedItemPosition ?: return
val streamSecurity = sp_stream_security?.selectedItemPosition ?: return
var utlsIndex = sp_stream_fingerprint?.selectedItemPosition ?: return
var sni = streamSetting.populateTransportSettings(
transport = networks[network],
@@ -330,7 +340,8 @@ class ServerActivity : BaseActivity() {
} else {
allowinsecures[allowInsecureField].toBoolean()
}
streamSetting.populateTlsSettings(streamSecuritys[streamSecurity], allowInsecure, sni)
streamSetting.populateTlsSettings(streamSecuritys[streamSecurity], allowInsecure, sni, uTlsItems[utlsIndex])
}
private fun transportTypes(network: String?): Array<out String> {

View File

@@ -143,8 +143,9 @@ object AngConfigManager {
} else {
vmessBean.allowInsecure.toBoolean()
}
var fingerprint = streamSetting.tlsSettings?.fingerprint
streamSetting.populateTlsSettings(vmessBean.streamSecurity, allowInsecure,
vmessBean.sni.ifBlank { sni })
vmessBean.sni.ifBlank { sni }, fingerprint)
}
}
val key = MmkvManager.encodeServerConfig(vmessBean.guid, config)
@@ -185,6 +186,9 @@ object AngConfigManager {
config = ServerConfig.create(EConfigType.VMESS)
val streamSetting = config.outboundBean?.streamSettings ?: return -1
var fingerprint = streamSetting.tlsSettings?.fingerprint
if (!tryParseNewVmess(str, config, allowInsecure)) {
if (str.indexOf("?") > 0) {
if (!tryResolveVmess4Kitsunebi(str, config)) {
@@ -216,8 +220,10 @@ object AngConfigManager {
}
val sni = streamSetting.populateTransportSettings(vmessQRCode.net, vmessQRCode.type, vmessQRCode.host,
vmessQRCode.path, vmessQRCode.path, vmessQRCode.host, vmessQRCode.path, vmessQRCode.type, vmessQRCode.path)
streamSetting.populateTlsSettings(vmessQRCode.tls, allowInsecure,
if (TextUtils.isEmpty(vmessQRCode.sni)) sni else vmessQRCode.sni)
if (TextUtils.isEmpty(vmessQRCode.sni)) sni else vmessQRCode.sni, fingerprint)
}
}
} else if (str.startsWith(EConfigType.SHADOWSOCKS.protocolScheme)) {
@@ -292,6 +298,7 @@ object AngConfigManager {
config.remarks = Utils.urlDecode(uri.fragment ?: "")
var flow = ""
var fingerprint = config.outboundBean?.streamSettings?.tlsSettings?.fingerprint
if (uri.rawQuery != null) {
val queryParam = uri.rawQuery.split("&")
.associate { it.split("=").let { (k, v) -> k to Utils.urlDecode(v) } }
@@ -299,10 +306,11 @@ object AngConfigManager {
val sni = config.outboundBean?.streamSettings?.populateTransportSettings(queryParam["type"] ?: "tcp", queryParam["headerType"],
queryParam["host"], queryParam["path"], queryParam["seed"], queryParam["quicSecurity"], queryParam["key"],
queryParam["mode"], queryParam["serviceName"])
config.outboundBean?.streamSettings?.populateTlsSettings(queryParam["security"] ?: TLS, allowInsecure, queryParam["sni"] ?: sni!!)
config.outboundBean?.streamSettings?.populateTlsSettings(queryParam["security"] ?: TLS, allowInsecure, queryParam["sni"] ?: sni!!, fingerprint)
flow = queryParam["flow"] ?: ""
} else {
config.outboundBean?.streamSettings?.populateTlsSettings(TLS, allowInsecure, "")
config.outboundBean?.streamSettings?.populateTlsSettings(TLS, allowInsecure, "", fingerprint)
}
config.outboundBean?.settings?.servers?.get(0)?.let { server ->
@@ -317,6 +325,8 @@ object AngConfigManager {
.associate { it.split("=").let { (k, v) -> k to Utils.urlDecode(v) } }
config = ServerConfig.create(EConfigType.VLESS)
val streamSetting = config.outboundBean?.streamSettings ?: return -1
var fingerprint = streamSetting.tlsSettings?.fingerprint
config.remarks = Utils.urlDecode(uri.fragment ?: "")
config.outboundBean?.settings?.vnext?.get(0)?.let { vnext ->
vnext.address = uri.idnHost
@@ -329,7 +339,7 @@ object AngConfigManager {
val sni = streamSetting.populateTransportSettings(queryParam["type"] ?: "tcp", queryParam["headerType"],
queryParam["host"], queryParam["path"], queryParam["seed"], queryParam["quicSecurity"], queryParam["key"],
queryParam["mode"], queryParam["serviceName"])
streamSetting.populateTlsSettings(queryParam["security"] ?: "", allowInsecure, queryParam["sni"] ?: sni)
streamSetting.populateTlsSettings(queryParam["security"] ?: "", allowInsecure, queryParam["sni"] ?: sni, fingerprint)
}
if (config == null){
return R.string.toast_incorrect_protocol
@@ -369,12 +379,12 @@ object AngConfigManager {
vnext.users[0].security = DEFAULT_SECURITY
vnext.users[0].alterId = alterId.toInt()
}
var fingerprint = streamSetting.tlsSettings?.fingerprint
val sni = streamSetting.populateTransportSettings(protocol, queryParam["type"],
queryParam["host"]?.split("|")?.get(0) ?: "",
queryParam["path"]?.takeIf { it.trim() != "/" } ?: "", queryParam["seed"], queryParam["security"],
queryParam["key"], queryParam["mode"], queryParam["serviceName"])
streamSetting.populateTlsSettings(if (tls) TLS else "", allowInsecure, sni)
streamSetting.populateTlsSettings(if (tls) TLS else "", allowInsecure, sni, fingerprint)
true
}.getOrElse { false }
}

View File

@@ -202,64 +202,7 @@
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_stream_security" />
<Spinner
android:id="@+id/sp_stream_security"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:entries="@array/streamsecurityxs"
android:nextFocusDown="@+id/et_sni" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_sni" />
<EditText
android:id="@+id/et_sni"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_allow_insecure" />
<Spinner
android:id="@+id/sp_allow_insecure"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:entries="@array/allowinsecures"
android:nextFocusUp="@+id/et_sni" />
</LinearLayout>
<include layout="@layout/tls_layout" />
<LinearLayout
android:layout_width="match_parent"

View File

@@ -223,63 +223,7 @@
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_stream_security" />
<Spinner
android:id="@+id/sp_stream_security"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:entries="@array/streamsecurityxs"
android:nextFocusDown="@+id/et_sni" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_sni" />
<EditText
android:id="@+id/et_sni"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_allow_insecure" />
<Spinner
android:id="@+id/sp_allow_insecure"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:entries="@array/allowinsecures"
android:nextFocusUp="@+id/et_sni" />
</LinearLayout>
<include layout="@layout/tls_layout" />
<LinearLayout
android:layout_width="match_parent"

View File

@@ -222,64 +222,7 @@
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_stream_security" />
<Spinner
android:id="@+id/sp_stream_security"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:entries="@array/streamsecuritys"
android:nextFocusDown="@+id/et_sni" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_sni" />
<EditText
android:id="@+id/et_sni"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_allow_insecure" />
<Spinner
android:id="@+id/sp_allow_insecure"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:entries="@array/allowinsecures"
android:nextFocusUp="@+id/et_sni" />
</LinearLayout>
<include layout="@layout/tls_layout" />
<LinearLayout
android:layout_width="match_parent"

View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:orientation="vertical">
<LinearLayout
android:id="@+id/l1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_horizontal_margin"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_stream_security" />
<Spinner
android:id="@+id/sp_stream_security"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:entries="@array/streamsecurityxs"
android:nextFocusDown="@+id/et_sni" />
</LinearLayout>
<LinearLayout
android:id="@+id/l2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_horizontal_margin"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_sni" />
<EditText
android:id="@+id/et_sni"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:inputType="text"
android:nextFocusDown="@+id/sp_stream_fingerprint" />
</LinearLayout>
<LinearLayout
android:id="@+id/l3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_stream_fingerprint" />
<Spinner
android:id="@+id/sp_stream_fingerprint"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:entries="@array/streamsecurity_utls"
android:nextFocusDown="@+id/sp_allow_insecure" />
</LinearLayout>
<LinearLayout
android:id="@+id/l4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_allow_insecure" />
<Spinner
android:id="@+id/sp_allow_insecure"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:entries="@array/allowinsecures" />
</LinearLayout>
</LinearLayout>

View File

@@ -60,6 +60,14 @@
<item>xtls</item>
</string-array>
<string-array name="streamsecurity_utls" translatable="false">
<item></item>
<item>chrome</item>
<item>firefox</item>
<item>safari</item>
<item>randomized</item>
</string-array>
<string-array name="allowinsecures" translatable="false">
<item></item>
<item>true</item>

View File

@@ -49,6 +49,7 @@
<string name="server_lab_request_host">request host(host/ws host/h2 host)/QUIC security</string>
<string name="server_lab_path">path(ws path/h2 path)/QUIC key/kcp seed/gRPC serviceName</string>
<string name="server_lab_stream_security">tls</string>
<string name="server_lab_stream_fingerprint">uTLS</string>
<string name="server_lab_allow_insecure">allowInsecure</string>
<string name="server_lab_sni">SNI</string>
<string name="server_lab_address3">address</string>