From 820e6cdf36e2c6787198b24b3512c767a628e905 Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Sat, 27 Mar 2021 11:09:24 +0800
Subject: [PATCH 1/6] fix migration inbound port parsed as 0
---
.../app/src/main/kotlin/com/v2ray/ang/util/AngConfigManager.kt | 2 +-
V2rayNG/app/src/main/res/values/arrays.xml | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/AngConfigManager.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/AngConfigManager.kt
index 5becce11..0ace879a 100644
--- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/AngConfigManager.kt
+++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/AngConfigManager.kt
@@ -65,7 +65,7 @@ object AngConfigManager {
AppConfig.PREF_V2RAY_ROUTING_AGENT,
AppConfig.PREF_V2RAY_ROUTING_BLOCKED,
AppConfig.PREF_V2RAY_ROUTING_DIRECT,).forEach { key ->
- settingsStorage?.encode(key, sharedPreferences.getString(key, ""))
+ settingsStorage?.encode(key, sharedPreferences.getString(key, null))
}
listOf(AppConfig.PREF_SPEED_ENABLED,
AppConfig.PREF_SNIFFING_ENABLED,
diff --git a/V2rayNG/app/src/main/res/values/arrays.xml b/V2rayNG/app/src/main/res/values/arrays.xml
index 8965f0ac..755bb1d6 100644
--- a/V2rayNG/app/src/main/res/values/arrays.xml
+++ b/V2rayNG/app/src/main/res/values/arrays.xml
@@ -5,6 +5,7 @@
- aes-128-gcm
- auto
- none
+ - zero
- aes-256-cfb
@@ -98,6 +99,7 @@
- xtls-rprx-direct
- xtls-rprx-direct-udp443
- xtls-rprx-splice
+ - xtls-rprx-splice-udp443
From a360310be289eeb973b6ba98a46bc83426ff1fe2 Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Sat, 27 Mar 2021 19:33:48 +0800
Subject: [PATCH 2/6] fix header type none
---
.../kotlin/com/v2ray/ang/dto/V2rayConfig.kt | 32 +++++++++++--------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
index 76e410cb..f3a34fef 100644
--- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
+++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
@@ -68,17 +68,17 @@ data class V2rayConfig(
data class OutSettingsBean(var vnext: List? = null,
var servers: List? = null,
- /*Blackhole*/
+ /*Blackhole*/
var response: Response? = null,
- /*DNS*/
+ /*DNS*/
val network: String? = null,
val address: String? = null,
val port: Int? = null,
- /*Freedom*/
+ /*Freedom*/
val domainStrategy: String? = null,
val redirect: String? = null,
val userLevel: Int? = null,
- /*Loopback*/
+ /*Loopback*/
val inboundTag: String? = null) {
data class VnextBean(var address: String = "",
@@ -172,15 +172,19 @@ data class V2rayConfig(
var sni = ""
network = transport
when (network) {
- "tcp" -> if (headerType == HTTP) {
+ "tcp" -> {
val tcpSetting = TcpSettingsBean()
- tcpSetting.header.type = HTTP
- if (!TextUtils.isEmpty(host) || !TextUtils.isEmpty(path)) {
- val requestObj = TcpSettingsBean.HeaderBean.RequestBean()
- requestObj.headers.Host = (host ?: "").split(",").map { it.trim() }
- requestObj.path = (path ?: "").split(",").map { it.trim() }
- tcpSetting.header.request = requestObj
- sni = requestObj.headers.Host.getOrNull(0) ?: sni
+ if (headerType == HTTP) {
+ tcpSetting.header.type = HTTP
+ if (!TextUtils.isEmpty(host) || !TextUtils.isEmpty(path)) {
+ val requestObj = TcpSettingsBean.HeaderBean.RequestBean()
+ requestObj.headers.Host = (host ?: "").split(",").map { it.trim() }
+ requestObj.path = (path ?: "").split(",").map { it.trim() }
+ tcpSetting.header.request = requestObj
+ sni = requestObj.headers.Host.getOrNull(0) ?: sni
+ }
+ } else {
+ tcpSetting.header.type = "none"
}
tcpSettings = tcpSetting
}
@@ -286,7 +290,7 @@ data class V2rayConfig(
if (protocol.equals(EConfigType.VMESS.name, true)
|| protocol.equals(EConfigType.VLESS.name, true)) {
val transport = streamSettings?.network ?: return null
- return when(transport) {
+ return when (transport) {
"tcp" -> {
val tcpSetting = streamSettings?.tcpSettings ?: return null
listOf(tcpSetting.header.type,
@@ -388,7 +392,7 @@ data class V2rayConfig(
return GsonBuilder()
.setPrettyPrinting()
.registerTypeAdapter( // custom serialiser is needed here since JSON by default parse number as Double, core will fail to start
- object: TypeToken() {}.type,
+ object : TypeToken() {}.type,
JsonSerializer { src: Double?, _: Type?, _: JsonSerializationContext? -> JsonPrimitive(src?.toInt()) }
)
.create()
From 5930a6a9eb3fe8122db8cf6e5968bc5f37b8adcf Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Sat, 27 Mar 2021 19:54:50 +0800
Subject: [PATCH 3/6] Update V2rayConfig.kt
---
V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt | 1 +
1 file changed, 1 insertion(+)
diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
index f3a34fef..0024490d 100644
--- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
+++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
@@ -185,6 +185,7 @@ data class V2rayConfig(
}
} else {
tcpSetting.header.type = "none"
+ sni = host ?: ""
}
tcpSettings = tcpSetting
}
From 0ce60eae73d3642b2a82af1cc0a645105d346b9a Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Sat, 27 Mar 2021 20:54:41 +0800
Subject: [PATCH 4/6] Update MainRecyclerAdapter.kt
---
.../src/main/kotlin/com/v2ray/ang/ui/MainRecyclerAdapter.kt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/MainRecyclerAdapter.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/MainRecyclerAdapter.kt
index 26161149..7146a217 100644
--- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/MainRecyclerAdapter.kt
+++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/MainRecyclerAdapter.kt
@@ -48,7 +48,7 @@ class MainRecyclerAdapter(val activity: MainActivity) : RecyclerView.Adapter
From 62b928e6a0823db288557a27d39a0b5537a0a230 Mon Sep 17 00:00:00 2001
From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com>
Date: Sat, 27 Mar 2021 18:41:36 -0400
Subject: [PATCH 5/6] Support Trojan flow and email
---
V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
index 0024490d..be6d0bb1 100644
--- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
+++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
@@ -99,6 +99,8 @@ data class V2rayConfig(
var password: String = "",
var port: Int = DEFAULT_PORT,
var level: Int = DEFAULT_LEVEL,
+ val email: String? = null,
+ val flow: String? = null,
var users: List? = null) {
From 4d9aced5a4ecc989c5d321a530dda9ac23a384ef Mon Sep 17 00:00:00 2001
From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com>
Date: Sat, 27 Mar 2021 19:01:49 -0400
Subject: [PATCH 6/6] Gson display to not escape HTML character like "="
---
V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt | 1 +
1 file changed, 1 insertion(+)
diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
index be6d0bb1..5cdaf5d9 100644
--- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
+++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
@@ -394,6 +394,7 @@ data class V2rayConfig(
fun toPrettyPrinting(): String {
return GsonBuilder()
.setPrettyPrinting()
+ .disableHtmlEscaping()
.registerTypeAdapter( // custom serialiser is needed here since JSON by default parse number as Double, core will fail to start
object : TypeToken() {}.type,
JsonSerializer { src: Double?, _: Type?, _: JsonSerializationContext? -> JsonPrimitive(src?.toInt()) }