Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
105a41eeea | ||
|
|
9a9d315e62 | ||
|
|
c42aa93bf7 | ||
|
|
a7664f03aa | ||
|
|
fa341c9a5a | ||
|
|
a15ab4759e |
@@ -3,7 +3,7 @@
|
|||||||
A V2Ray client for Android, support [Xray core](https://github.com/XTLS/Xray-core) and [v2fly core](https://github.com/v2fly/v2ray-core)
|
A V2Ray client for Android, support [Xray core](https://github.com/XTLS/Xray-core) and [v2fly core](https://github.com/v2fly/v2ray-core)
|
||||||
|
|
||||||
[](https://developer.android.com/about/versions/lollipop)
|
[](https://developer.android.com/about/versions/lollipop)
|
||||||
[](https://kotlinlang.org)
|
[](https://kotlinlang.org)
|
||||||
[](https://github.com/2dust/v2rayNG/commits/master)
|
[](https://github.com/2dust/v2rayNG/commits/master)
|
||||||
[](https://www.codefactor.io/repository/github/2dust/v2rayng)
|
[](https://www.codefactor.io/repository/github/2dust/v2rayng)
|
||||||
[](https://github.com/2dust/v2rayNG/releases)
|
[](https://github.com/2dust/v2rayNG/releases)
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ android {
|
|||||||
applicationId = "com.v2ray.ang"
|
applicationId = "com.v2ray.ang"
|
||||||
minSdk = 21
|
minSdk = 21
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 583
|
versionCode = 586
|
||||||
versionName = "1.8.38"
|
versionName = "1.8.40"
|
||||||
multiDexEnabled = true
|
multiDexEnabled = true
|
||||||
splits {
|
splits {
|
||||||
abi {
|
abi {
|
||||||
|
|||||||
@@ -179,7 +179,8 @@
|
|||||||
<service
|
<service
|
||||||
android:name=".service.V2RayTestService"
|
android:name=".service.V2RayTestService"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:process=":RunSoLibV2RayDaemon"></service>
|
android:process=":RunSoLibV2RayDaemon"
|
||||||
|
/>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ data class V2rayConfig(
|
|||||||
data class OutSettingsBean(
|
data class OutSettingsBean(
|
||||||
var vnext: List<VnextBean>? = null,
|
var vnext: List<VnextBean>? = null,
|
||||||
var fragment: FragmentBean? = null,
|
var fragment: FragmentBean? = null,
|
||||||
|
var noise: NoiseBean? = null,
|
||||||
var servers: List<ServersBean>? = null,
|
var servers: List<ServersBean>? = null,
|
||||||
/*Blackhole*/
|
/*Blackhole*/
|
||||||
var response: Response? = null,
|
var response: Response? = null,
|
||||||
@@ -127,6 +128,11 @@ data class V2rayConfig(
|
|||||||
var interval: String? = null
|
var interval: String? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class NoiseBean(
|
||||||
|
var packet: String? = null,
|
||||||
|
var delay: String? = null
|
||||||
|
)
|
||||||
|
|
||||||
data class ServersBean(
|
data class ServersBean(
|
||||||
var address: String = "",
|
var address: String = "",
|
||||||
var method: String = "chacha20-poly1305",
|
var method: String = "chacha20-poly1305",
|
||||||
|
|||||||
@@ -517,6 +517,13 @@ object AngConfigManager {
|
|||||||
val key = MmkvManager.encodeServerConfig("", config)
|
val key = MmkvManager.encodeServerConfig("", config)
|
||||||
serverRawStorage?.encode(key, server)
|
serverRawStorage?.encode(key, server)
|
||||||
return 1
|
return 1
|
||||||
|
} else if (server.startsWith("[Interface]") && server.contains("[Peer]")) {
|
||||||
|
val config = WireguardFmt.parseWireguardConfFile(server)
|
||||||
|
?: return R.string.toast_incorrect_protocol
|
||||||
|
config.fullConfig?.remarks ?: System.currentTimeMillis().toString()
|
||||||
|
val key = MmkvManager.encodeServerConfig("", config)
|
||||||
|
serverRawStorage?.encode(key, server)
|
||||||
|
return 1
|
||||||
} else {
|
} else {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -640,7 +640,11 @@ object V2rayConfigUtil {
|
|||||||
?: "50-100",
|
?: "50-100",
|
||||||
interval = settingsStorage?.decodeString(AppConfig.PREF_FRAGMENT_INTERVAL)
|
interval = settingsStorage?.decodeString(AppConfig.PREF_FRAGMENT_INTERVAL)
|
||||||
?: "10-20"
|
?: "10-20"
|
||||||
)
|
),
|
||||||
|
noise = V2rayConfig.OutboundBean.OutSettingsBean.NoiseBean(
|
||||||
|
packet = "rand:100-200",
|
||||||
|
delay = "10-20",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
fragmentOutbound.streamSettings = V2rayConfig.OutboundBean.StreamSettingsBean(
|
fragmentOutbound.streamSettings = V2rayConfig.OutboundBean.StreamSettingsBean(
|
||||||
sockopt = V2rayConfig.OutboundBean.StreamSettingsBean.SockoptBean(
|
sockopt = V2rayConfig.OutboundBean.StreamSettingsBean.SockoptBean(
|
||||||
|
|||||||
@@ -38,6 +38,40 @@ object WireguardFmt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun parseWireguardConfFile(str: String): ServerConfig? {
|
||||||
|
val config = ServerConfig.create(EConfigType.WIREGUARD)
|
||||||
|
val queryParam: MutableMap<String, String> = mutableMapOf()
|
||||||
|
|
||||||
|
var currentSection: String? = null
|
||||||
|
|
||||||
|
str.lines().forEach { line ->
|
||||||
|
val trimmedLine = line.trim()
|
||||||
|
|
||||||
|
when {
|
||||||
|
trimmedLine.startsWith("[Interface]", ignoreCase = true) -> currentSection = "Interface"
|
||||||
|
trimmedLine.startsWith("[Peer]", ignoreCase = true) -> currentSection = "Peer"
|
||||||
|
trimmedLine.isBlank() || trimmedLine.startsWith("#") -> Unit // Skip blank lines or comments
|
||||||
|
currentSection != null -> {
|
||||||
|
val (key, value) = trimmedLine.split("=").map { it.trim() }
|
||||||
|
queryParam[key.lowercase()] = value // Store the key in lowercase for case-insensitivity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config.outboundBean?.settings?.let { wireguard ->
|
||||||
|
wireguard.secretKey = queryParam["privatekey"].orEmpty()
|
||||||
|
wireguard.address = (queryParam["address"] ?: AppConfig.WIREGUARD_LOCAL_ADDRESS_V4).removeWhiteSpace().split(",")
|
||||||
|
wireguard.peers?.getOrNull(0)?.publicKey = queryParam["publickey"].orEmpty()
|
||||||
|
wireguard.peers?.getOrNull(0)?.endpoint = queryParam["endpoint"].orEmpty()
|
||||||
|
wireguard.mtu = Utils.parseInt(queryParam["mtu"] ?: AppConfig.WIREGUARD_LOCAL_MTU)
|
||||||
|
wireguard.reserved = (queryParam["reserved"] ?: "0,0,0").removeWhiteSpace().split(",").map { it.toInt() }
|
||||||
|
}
|
||||||
|
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun toUri(config: ServerConfig): String {
|
fun toUri(config: ServerConfig): String {
|
||||||
val outbound = config.getProxyOutbound() ?: return ""
|
val outbound = config.getProxyOutbound() ?: return ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user