Add share 4 Wireguard
This commit is contained in:
@@ -12,6 +12,8 @@ import com.v2ray.ang.AppConfig
|
|||||||
import com.v2ray.ang.AppConfig.ANG_CONFIG
|
import com.v2ray.ang.AppConfig.ANG_CONFIG
|
||||||
import com.v2ray.ang.AppConfig.HTTPS_PROTOCOL
|
import com.v2ray.ang.AppConfig.HTTPS_PROTOCOL
|
||||||
import com.v2ray.ang.AppConfig.HTTP_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.R
|
||||||
import com.v2ray.ang.dto.*
|
import com.v2ray.ang.dto.*
|
||||||
import com.v2ray.ang.dto.V2rayConfig.Companion.DEFAULT_SECURITY
|
import com.v2ray.ang.dto.V2rayConfig.Companion.DEFAULT_SECURITY
|
||||||
@@ -432,6 +434,28 @@ object AngConfigManager {
|
|||||||
queryParam["security"] ?: "", allowInsecure,
|
queryParam["security"] ?: "", allowInsecure,
|
||||||
queryParam["sni"] ?: sni, fingerprint, queryParam["alpn"], pbk, sid, spx
|
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) {
|
if (config == null) {
|
||||||
return R.string.toast_incorrect_protocol
|
return R.string.toast_incorrect_protocol
|
||||||
@@ -443,7 +467,8 @@ object AngConfigManager {
|
|||||||
?.getServerAddress() == removedSelectedServer.getProxyOutbound()
|
?.getServerAddress() == removedSelectedServer.getProxyOutbound()
|
||||||
?.getServerAddress() &&
|
?.getServerAddress() &&
|
||||||
config.getProxyOutbound()
|
config.getProxyOutbound()
|
||||||
?.getServerPort() == removedSelectedServer.getProxyOutbound()?.getServerPort()
|
?.getServerPort() == removedSelectedServer.getProxyOutbound()
|
||||||
|
?.getServerPort()
|
||||||
) {
|
) {
|
||||||
mainStorage?.encode(KEY_SELECTED_SERVER, guid)
|
mainStorage?.encode(KEY_SELECTED_SERVER, guid)
|
||||||
}
|
}
|
||||||
@@ -680,7 +705,8 @@ object AngConfigManager {
|
|||||||
dicQuery["spx"] = Utils.urlEncode(tlsSetting.spiderX!!)
|
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 ->
|
outbound.getTransportSettingDetails()?.let { transportDetails ->
|
||||||
when (streamSetting.network) {
|
when (streamSetting.network) {
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ object Utils {
|
|||||||
|
|
||||||
fun urlDecode(url: String): String {
|
fun urlDecode(url: String): String {
|
||||||
return try {
|
return try {
|
||||||
URLDecoder.decode(URLDecoder.decode(url), "utf-8")
|
URLDecoder.decode(url, "UTF-8")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
url
|
url
|
||||||
|
|||||||
@@ -34,12 +34,12 @@ object V2rayConfigUtil {
|
|||||||
} else {
|
} else {
|
||||||
raw
|
raw
|
||||||
}
|
}
|
||||||
Log.d(ANG_PACKAGE, customConfig)
|
//Log.d(ANG_PACKAGE, customConfig)
|
||||||
return Result(true, customConfig)
|
return Result(true, customConfig)
|
||||||
}
|
}
|
||||||
val outbound = config.getProxyOutbound() ?: return Result(false, "")
|
val outbound = config.getProxyOutbound() ?: return Result(false, "")
|
||||||
val result = getV2rayNonCustomConfig(context, outbound)
|
val result = getV2rayNonCustomConfig(context, outbound)
|
||||||
Log.d(ANG_PACKAGE, result.content)
|
//Log.d(ANG_PACKAGE, result.content)
|
||||||
return result
|
return result
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
|||||||
@@ -88,11 +88,10 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/server_lab_public_key" />
|
android:text="@string/server_lab_secret_key" />
|
||||||
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/et_public_key"
|
android:id="@+id/et_id"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/edit_height"
|
android:layout_height="@dimen/edit_height"
|
||||||
android:inputType="text" />
|
android:inputType="text" />
|
||||||
@@ -108,10 +107,11 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/server_lab_secret_key" />
|
android:text="@string/server_lab_public_key" />
|
||||||
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/et_id"
|
android:id="@+id/et_public_key"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/edit_height"
|
android:layout_height="@dimen/edit_height"
|
||||||
android:inputType="text" />
|
android:inputType="text" />
|
||||||
|
|||||||
Reference in New Issue
Block a user