Compare commits

...

6 Commits

Author SHA1 Message Date
2dust
105a41eeea up 1.8.40 2024-09-08 08:44:21 +08:00
2dust
9a9d315e62 up 1.8.39 2024-08-30 19:12:51 +08:00
2dust
c42aa93bf7 Add UDP noise
002d08bf83
2024-08-30 19:11:51 +08:00
Tamim Hossain
a7664f03aa Update Kotlin Version In Readme.md (#3525)
Update Kotlin Version In Readme.md
2024-08-30 14:53:41 +08:00
Tamim Hossain
fa341c9a5a Added wireguard regular config parsing feature, which we discussed on issue #3497 (#3521) 2024-08-29 19:31:44 +08:00
Tamim Hossain
a15ab4759e Close the service tag correctly (#3519) 2024-08-29 19:29:40 +08:00
7 changed files with 58 additions and 6 deletions

View File

@@ -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)
[![API](https://img.shields.io/badge/API-21%2B-yellow.svg?style=flat)](https://developer.android.com/about/versions/lollipop) [![API](https://img.shields.io/badge/API-21%2B-yellow.svg?style=flat)](https://developer.android.com/about/versions/lollipop)
[![Kotlin Version](https://img.shields.io/badge/Kotlin-1.6.21-blue.svg)](https://kotlinlang.org) [![Kotlin Version](https://img.shields.io/badge/Kotlin-1.9.23-blue.svg)](https://kotlinlang.org)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/2dust/v2rayNG)](https://github.com/2dust/v2rayNG/commits/master) [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/2dust/v2rayNG)](https://github.com/2dust/v2rayNG/commits/master)
[![CodeFactor](https://www.codefactor.io/repository/github/2dust/v2rayng/badge)](https://www.codefactor.io/repository/github/2dust/v2rayng) [![CodeFactor](https://www.codefactor.io/repository/github/2dust/v2rayng/badge)](https://www.codefactor.io/repository/github/2dust/v2rayng)
[![GitHub Releases](https://img.shields.io/github/downloads/2dust/v2rayNG/latest/total?logo=github)](https://github.com/2dust/v2rayNG/releases) [![GitHub Releases](https://img.shields.io/github/downloads/2dust/v2rayNG/latest/total?logo=github)](https://github.com/2dust/v2rayNG/releases)

View File

@@ -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 {

View File

@@ -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"

View File

@@ -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",

View File

@@ -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
} }

View File

@@ -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(

View File

@@ -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 ""