Bug fix
This commit is contained in:
@@ -17,16 +17,16 @@ val Context.v2RayApplication: AngApplication
|
|||||||
get() = applicationContext as AngApplication
|
get() = applicationContext as AngApplication
|
||||||
|
|
||||||
fun Context.toast(message: Int): Toast = ToastCompat
|
fun Context.toast(message: Int): Toast = ToastCompat
|
||||||
.makeText(this, message, Toast.LENGTH_SHORT)
|
.makeText(this, message, Toast.LENGTH_SHORT)
|
||||||
.apply {
|
.apply {
|
||||||
show()
|
show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.toast(message: CharSequence): Toast = ToastCompat
|
fun Context.toast(message: CharSequence): Toast = ToastCompat
|
||||||
.makeText(this, message, Toast.LENGTH_SHORT)
|
.makeText(this, message, Toast.LENGTH_SHORT)
|
||||||
.apply {
|
.apply {
|
||||||
show()
|
show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun JSONObject.putOpt(pair: Pair<String, Any>) = putOpt(pair.first, pair.second)
|
fun JSONObject.putOpt(pair: Pair<String, Any>) = putOpt(pair.first, pair.second)
|
||||||
fun JSONObject.putOpt(pairs: Map<String, Any>) = pairs.forEach { putOpt(it.key to it.value) }
|
fun JSONObject.putOpt(pairs: Map<String, Any>) = pairs.forEach { putOpt(it.key to it.value) }
|
||||||
@@ -78,3 +78,7 @@ val URLConnection.responseLength: Long
|
|||||||
|
|
||||||
val URI.idnHost: String
|
val URI.idnHost: String
|
||||||
get() = (host!!).replace("[", "").replace("]", "")
|
get() = (host!!).replace("[", "").replace("]", "")
|
||||||
|
|
||||||
|
fun String.removeWhiteSpace(): String {
|
||||||
|
return this.replace(" ", "")
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ import com.v2ray.ang.dto.ServerConfig
|
|||||||
import com.v2ray.ang.dto.V2rayConfig
|
import com.v2ray.ang.dto.V2rayConfig
|
||||||
import com.v2ray.ang.dto.V2rayConfig.Companion.DEFAULT_PORT
|
import com.v2ray.ang.dto.V2rayConfig.Companion.DEFAULT_PORT
|
||||||
import com.v2ray.ang.dto.V2rayConfig.Companion.TLS
|
import com.v2ray.ang.dto.V2rayConfig.Companion.TLS
|
||||||
|
import com.v2ray.ang.extension.removeWhiteSpace
|
||||||
import com.v2ray.ang.extension.toast
|
import com.v2ray.ang.extension.toast
|
||||||
import com.v2ray.ang.util.MmkvManager
|
import com.v2ray.ang.util.MmkvManager
|
||||||
import com.v2ray.ang.util.MmkvManager.ID_MAIN
|
import com.v2ray.ang.util.MmkvManager.ID_MAIN
|
||||||
@@ -476,7 +477,7 @@ class ServerActivity : BaseActivity() {
|
|||||||
} else {
|
} else {
|
||||||
wireguard.reserved = null
|
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())
|
wireguard.mtu = Utils.parseInt(et_local_mtu?.text.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.v2ray.ang.util.MmkvManager.KEY_SELECTED_SERVER
|
|||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import com.v2ray.ang.extension.idnHost
|
import com.v2ray.ang.extension.idnHost
|
||||||
|
import com.v2ray.ang.extension.removeWhiteSpace
|
||||||
import com.v2ray.ang.extension.toast
|
import com.v2ray.ang.extension.toast
|
||||||
|
|
||||||
object AngConfigManager {
|
object AngConfigManager {
|
||||||
@@ -446,13 +447,13 @@ object AngConfigManager {
|
|||||||
config.outboundBean?.settings?.let { wireguard ->
|
config.outboundBean?.settings?.let { wireguard ->
|
||||||
wireguard.secretKey = uri.userInfo
|
wireguard.secretKey = uri.userInfo
|
||||||
wireguard.address =
|
wireguard.address =
|
||||||
(queryParam["address"] ?: WIREGUARD_LOCAL_ADDRESS_V4).replace(" ", "")
|
(queryParam["address"] ?: WIREGUARD_LOCAL_ADDRESS_V4).removeWhiteSpace()
|
||||||
.split(",")
|
.split(",")
|
||||||
wireguard.peers?.get(0)?.publicKey = queryParam["publickey"] ?: ""
|
wireguard.peers?.get(0)?.publicKey = queryParam["publickey"] ?: ""
|
||||||
wireguard.peers?.get(0)?.endpoint = "${uri.idnHost}:${uri.port}"
|
wireguard.peers?.get(0)?.endpoint = "${uri.idnHost}:${uri.port}"
|
||||||
wireguard.mtu = Utils.parseInt(queryParam["mtu"] ?: WIREGUARD_LOCAL_MTU)
|
wireguard.mtu = Utils.parseInt(queryParam["mtu"] ?: WIREGUARD_LOCAL_MTU)
|
||||||
wireguard.reserved =
|
wireguard.reserved =
|
||||||
(queryParam["reserved"] ?: "0,0,0").replace(" ", "").split(",")
|
(queryParam["reserved"] ?: "0,0,0").removeWhiteSpace().split(",")
|
||||||
.map { it.toInt() }
|
.map { it.toInt() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user