Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Nov 19, 2024
1 parent 1f6104d commit 6f2c96c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 10 additions & 3 deletions V2rayNG/app/src/main/java/com/v2ray/ang/ui/ServerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.v2ray.ang.R
import com.v2ray.ang.dto.EConfigType
import com.v2ray.ang.dto.NetworkType
import com.v2ray.ang.dto.ProfileItem
import com.v2ray.ang.extension.isNotNullEmpty
import com.v2ray.ang.extension.toast
import com.v2ray.ang.handler.MmkvManager
import com.v2ray.ang.util.JsonUtil
Expand Down Expand Up @@ -168,7 +169,7 @@ class ServerActivity : BaseActivity() {
types,
when (networks[position]) {
NetworkType.GRPC.type -> config?.mode
NetworkType.SPLIT_HTTP.type, NetworkType.XHTTP.type -> config?.xhttpMode
NetworkType.SPLIT_HTTP.type, NetworkType.XHTTP.type -> config?.xhttpMode
else -> config?.headerType
}.orEmpty()
)
Expand Down Expand Up @@ -221,7 +222,7 @@ class ServerActivity : BaseActivity() {
)
et_extra?.text = Utils.getEditable(
when (networks[position]) {
NetworkType.SPLIT_HTTP.type, NetworkType.XHTTP.type -> JsonUtil.toJsonPretty(JsonUtil.parseString(config?.xhttpExtra))
NetworkType.SPLIT_HTTP.type, NetworkType.XHTTP.type -> config?.xhttpExtra
else -> null
}.orEmpty()
)
Expand Down Expand Up @@ -468,6 +469,12 @@ class ServerActivity : BaseActivity() {
return false
}
}
if (et_extra?.text?.toString().isNotNullEmpty()) {
if (JsonUtil.parseString(et_extra?.text?.toString()) == null) {
toast(R.string.server_lab_xhttp_extra)
return false
}
}

saveCommon(config)
saveStreamSettings(config)
Expand Down Expand Up @@ -577,7 +584,7 @@ class ServerActivity : BaseActivity() {
grpcModes
}

NetworkType.SPLIT_HTTP.type, NetworkType.XHTTP.type -> {
NetworkType.SPLIT_HTTP.type, NetworkType.XHTTP.type -> {
xhttpMode
}

Expand Down
8 changes: 6 additions & 2 deletions V2rayNG/app/src/main/java/com/v2ray/ang/util/JsonUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ object JsonUtil {
fun parseString(src: String?): JsonObject? {
if (src == null)
return null
return JsonParser.parseString(src).getAsJsonObject()
try {
return JsonParser.parseString(src).getAsJsonObject()
} catch (e: Exception) {
e.printStackTrace()
return null
}
}

}

0 comments on commit 6f2c96c

Please sign in to comment.