Fix domain name resolution for XRay
This commit is contained in:
parent
87cb5f620a
commit
138e6f70a4
3 changed files with 13 additions and 4 deletions
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR)
|
|||
|
||||
set(PROJECT AmneziaVPN)
|
||||
|
||||
project(${PROJECT} VERSION 4.8.0.4
|
||||
project(${PROJECT} VERSION 4.8.0.5
|
||||
DESCRIPTION "AmneziaVPN"
|
||||
HOMEPAGE_URL "https://amnezia.org/"
|
||||
)
|
||||
|
@ -11,7 +11,7 @@ string(TIMESTAMP CURRENT_DATE "%Y-%m-%d")
|
|||
set(RELEASE_DATE "${CURRENT_DATE}")
|
||||
|
||||
set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
|
||||
set(APP_ANDROID_VERSION_CODE 60)
|
||||
set(APP_ANDROID_VERSION_CODE 61)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
set(MZ_PLATFORM_NAME "linux")
|
||||
|
|
|
@ -60,7 +60,7 @@ private val parseNumericAddressCompat: (String) -> InetAddress =
|
|||
internal fun convertIpv6ToCanonicalForm(ipv6: String): String = ipv6
|
||||
.replace("((?:(?:^|:)0+\\b){2,}):?(?!\\S*\\b\\1:0+\\b)(\\S*)".toRegex(), "::$2")
|
||||
|
||||
internal val InetAddress.ip: String
|
||||
val InetAddress.ip: String
|
||||
get() = if (this is Inet4Address) {
|
||||
hostAddress!!
|
||||
} else {
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.amnezia.vpn.protocol.xray.libXray.Logger
|
|||
import org.amnezia.vpn.protocol.xray.libXray.Tun2SocksConfig
|
||||
import org.amnezia.vpn.util.Log
|
||||
import org.amnezia.vpn.util.net.InetNetwork
|
||||
import org.amnezia.vpn.util.net.ip
|
||||
import org.amnezia.vpn.util.net.parseInetAddress
|
||||
import org.json.JSONObject
|
||||
|
||||
|
@ -61,7 +62,15 @@ class Xray : Protocol() {
|
|||
.put("loglevel", "warning")
|
||||
.put("access", "none") // disable access log
|
||||
|
||||
start(xrayConfig, xrayJsonConfig.toString(), vpnBuilder, protect)
|
||||
var xrayJsonConfigString = xrayJsonConfig.toString()
|
||||
config.getString("hostName").let { hostName ->
|
||||
val ipAddress = parseInetAddress(hostName).ip
|
||||
if (hostName != ipAddress) {
|
||||
xrayJsonConfigString = xrayJsonConfigString.replace(hostName, ipAddress)
|
||||
}
|
||||
}
|
||||
|
||||
start(xrayConfig, xrayJsonConfigString, vpnBuilder, protect)
|
||||
state.value = CONNECTED
|
||||
isRunning = true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue