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 7b1cf159..7e749cc8 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
@@ -12,6 +12,8 @@ import com.v2ray.ang.AppConfig
import com.v2ray.ang.AppConfig.ANG_CONFIG
import com.v2ray.ang.AppConfig.HTTPS_PROTOCOL
import com.v2ray.ang.AppConfig.HTTP_PROTOCOL
+import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_ADDRESS_V4
+import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_MTU
import com.v2ray.ang.R
import com.v2ray.ang.dto.*
import com.v2ray.ang.dto.V2rayConfig.Companion.DEFAULT_SECURITY
@@ -432,6 +434,28 @@ object AngConfigManager {
queryParam["security"] ?: "", allowInsecure,
queryParam["sni"] ?: sni, fingerprint, queryParam["alpn"], pbk, sid, spx
)
+ } else if (str.startsWith(EConfigType.WIREGUARD.protocolScheme)) {
+ val uri = URI(Utils.fixIllegalUrl(str))
+ config = ServerConfig.create(EConfigType.WIREGUARD)
+ config.remarks = Utils.urlDecode(uri.fragment ?: "")
+
+ if (uri.rawQuery != null) {
+ val queryParam = uri.rawQuery.split("&")
+ .associate { it.split("=").let { (k, v) -> k to Utils.urlDecode(v) } }
+
+ config.outboundBean?.settings?.let { wireguard ->
+ wireguard.secretKey = uri.userInfo
+ wireguard.address =
+ (queryParam["address"] ?: WIREGUARD_LOCAL_ADDRESS_V4).replace(" ", "")
+ .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(",")
+ .map { it.toInt() }
+ }
+ }
}
if (config == null) {
return R.string.toast_incorrect_protocol
@@ -443,7 +467,8 @@ object AngConfigManager {
?.getServerAddress() == removedSelectedServer.getProxyOutbound()
?.getServerAddress() &&
config.getProxyOutbound()
- ?.getServerPort() == removedSelectedServer.getProxyOutbound()?.getServerPort()
+ ?.getServerPort() == removedSelectedServer.getProxyOutbound()
+ ?.getServerPort()
) {
mainStorage?.encode(KEY_SELECTED_SERVER, guid)
}
@@ -680,7 +705,8 @@ object AngConfigManager {
dicQuery["spx"] = Utils.urlEncode(tlsSetting.spiderX!!)
}
}
- dicQuery["type"] = streamSetting.network.ifEmpty { V2rayConfig.DEFAULT_NETWORK }
+ dicQuery["type"] =
+ streamSetting.network.ifEmpty { V2rayConfig.DEFAULT_NETWORK }
outbound.getTransportSettingDetails()?.let { transportDetails ->
when (streamSetting.network) {
diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt
index b0f01eb0..faa2d91c 100644
--- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt
+++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt
@@ -283,7 +283,7 @@ object Utils {
fun urlDecode(url: String): String {
return try {
- URLDecoder.decode(URLDecoder.decode(url), "utf-8")
+ URLDecoder.decode(url, "UTF-8")
} catch (e: Exception) {
e.printStackTrace()
url
diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/V2rayConfigUtil.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/V2rayConfigUtil.kt
index 24fea77a..79bf6e8c 100644
--- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/V2rayConfigUtil.kt
+++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/V2rayConfigUtil.kt
@@ -34,12 +34,12 @@ object V2rayConfigUtil {
} else {
raw
}
- Log.d(ANG_PACKAGE, customConfig)
+ //Log.d(ANG_PACKAGE, customConfig)
return Result(true, customConfig)
}
val outbound = config.getProxyOutbound() ?: return Result(false, "")
val result = getV2rayNonCustomConfig(context, outbound)
- Log.d(ANG_PACKAGE, result.content)
+ //Log.d(ANG_PACKAGE, result.content)
return result
} catch (e: Exception) {
e.printStackTrace()
diff --git a/V2rayNG/app/src/main/res/layout/activity_server_wireguard.xml b/V2rayNG/app/src/main/res/layout/activity_server_wireguard.xml
index 4b5f2c1d..5cc66505 100644
--- a/V2rayNG/app/src/main/res/layout/activity_server_wireguard.xml
+++ b/V2rayNG/app/src/main/res/layout/activity_server_wireguard.xml
@@ -88,11 +88,10 @@
-
+ android:text="@string/server_lab_secret_key" />
@@ -108,10 +107,11 @@
+ android:text="@string/server_lab_public_key" />
+