diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/extension/_Ext.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/extension/_Ext.kt index fb0bff631..91e3e9d89 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/extension/_Ext.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/extension/_Ext.kt @@ -17,16 +17,16 @@ val Context.v2RayApplication: AngApplication get() = applicationContext as AngApplication fun Context.toast(message: Int): Toast = ToastCompat - .makeText(this, message, Toast.LENGTH_SHORT) - .apply { - show() - } + .makeText(this, message, Toast.LENGTH_SHORT) + .apply { + show() + } fun Context.toast(message: CharSequence): Toast = ToastCompat - .makeText(this, message, Toast.LENGTH_SHORT) - .apply { - show() - } + .makeText(this, message, Toast.LENGTH_SHORT) + .apply { + show() + } fun JSONObject.putOpt(pair: Pair) = putOpt(pair.first, pair.second) fun JSONObject.putOpt(pairs: Map) = pairs.forEach { putOpt(it.key to it.value) } @@ -77,4 +77,8 @@ val URLConnection.responseLength: Long get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) contentLengthLong else contentLength.toLong() val URI.idnHost: String - get() = (host!!).replace("[", "").replace("]", "") \ No newline at end of file + get() = (host!!).replace("[", "").replace("]", "") + +fun String.removeWhiteSpace(): String { + return this.replace(" ", "") +} \ No newline at end of file diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt index bc92d69eb..895e17a1a 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt @@ -19,6 +19,7 @@ import com.v2ray.ang.dto.ServerConfig import com.v2ray.ang.dto.V2rayConfig import com.v2ray.ang.dto.V2rayConfig.Companion.DEFAULT_PORT import com.v2ray.ang.dto.V2rayConfig.Companion.TLS +import com.v2ray.ang.extension.removeWhiteSpace import com.v2ray.ang.extension.toast import com.v2ray.ang.util.MmkvManager import com.v2ray.ang.util.MmkvManager.ID_MAIN @@ -476,7 +477,7 @@ class ServerActivity : BaseActivity() { } else { wireguard.reserved = null } - wireguard.address = listOf(et_local_address?.text.toString().trim()) + wireguard.address = et_local_address?.text.toString().removeWhiteSpace().split(",") wireguard.mtu = Utils.parseInt(et_local_mtu?.text.toString()) } 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 7e749cc87..6e333acb0 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 @@ -22,6 +22,7 @@ import com.v2ray.ang.util.MmkvManager.KEY_SELECTED_SERVER import java.net.URI import java.util.* import com.v2ray.ang.extension.idnHost +import com.v2ray.ang.extension.removeWhiteSpace import com.v2ray.ang.extension.toast object AngConfigManager { @@ -446,13 +447,13 @@ object AngConfigManager { config.outboundBean?.settings?.let { wireguard -> wireguard.secretKey = uri.userInfo wireguard.address = - (queryParam["address"] ?: WIREGUARD_LOCAL_ADDRESS_V4).replace(" ", "") + (queryParam["address"] ?: WIREGUARD_LOCAL_ADDRESS_V4).removeWhiteSpace() .split(",") wireguard.peers?.get(0)?.publicKey = queryParam["publickey"] ?: "" wireguard.peers?.get(0)?.endpoint = "${uri.idnHost}:${uri.port}" wireguard.mtu = Utils.parseInt(queryParam["mtu"] ?: WIREGUARD_LOCAL_MTU) wireguard.reserved = - (queryParam["reserved"] ?: "0,0,0").replace(" ", "").split(",") + (queryParam["reserved"] ?: "0,0,0").removeWhiteSpace().split(",") .map { it.toInt() } } }