SSXray for Android (#885)
This commit is contained in:
parent
ae4b33d042
commit
74ae4f3e67
5 changed files with 22 additions and 5 deletions
|
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR)
|
||||||
|
|
||||||
set(PROJECT AmneziaVPN)
|
set(PROJECT AmneziaVPN)
|
||||||
|
|
||||||
project(${PROJECT} VERSION 4.6.0.1
|
project(${PROJECT} VERSION 4.6.0.3
|
||||||
DESCRIPTION "AmneziaVPN"
|
DESCRIPTION "AmneziaVPN"
|
||||||
HOMEPAGE_URL "https://amnezia.org/"
|
HOMEPAGE_URL "https://amnezia.org/"
|
||||||
)
|
)
|
||||||
|
|
@ -11,7 +11,7 @@ string(TIMESTAMP CURRENT_DATE "%Y-%m-%d")
|
||||||
set(RELEASE_DATE "${CURRENT_DATE}")
|
set(RELEASE_DATE "${CURRENT_DATE}")
|
||||||
|
|
||||||
set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
|
set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
|
||||||
set(APP_ANDROID_VERSION_CODE 54)
|
set(APP_ANDROID_VERSION_CODE 55)
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||||
set(MZ_PLATFORM_NAME "linux")
|
set(MZ_PLATFORM_NAME "linux")
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,8 @@ class AmneziaActivity : QtActivity() {
|
||||||
getVpnProto(vpnConfig)?.let { proto ->
|
getVpnProto(vpnConfig)?.let { proto ->
|
||||||
Log.d(TAG, "Proto from config: $proto, current proto: $vpnProto")
|
Log.d(TAG, "Proto from config: $proto, current proto: $vpnProto")
|
||||||
if (isServiceConnected) {
|
if (isServiceConnected) {
|
||||||
if (proto == vpnProto) {
|
if (proto.serviceClass == vpnProto?.serviceClass) {
|
||||||
|
vpnProto = proto
|
||||||
connectToVpn(vpnConfig)
|
connectToVpn(vpnConfig)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,15 @@ enum class VpnProto(
|
||||||
"org.amnezia.vpn:amneziaXrayService",
|
"org.amnezia.vpn:amneziaXrayService",
|
||||||
XrayService::class.java
|
XrayService::class.java
|
||||||
) {
|
) {
|
||||||
override fun createProtocol(): Protocol = Xray()
|
override fun createProtocol(): Protocol = Xray.instance
|
||||||
|
},
|
||||||
|
|
||||||
|
SSXRAY(
|
||||||
|
"SSXRay",
|
||||||
|
"org.amnezia.vpn:amneziaXrayService",
|
||||||
|
XrayService::class.java
|
||||||
|
) {
|
||||||
|
override fun createProtocol(): Protocol = Xray.instance
|
||||||
};
|
};
|
||||||
|
|
||||||
private var _protocol: Protocol? = null
|
private var _protocol: Protocol? = null
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import android.net.VpnService.Builder
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import go.Seq
|
import go.Seq
|
||||||
|
import org.amnezia.vpn.protocol.BadConfigException
|
||||||
import org.amnezia.vpn.protocol.Protocol
|
import org.amnezia.vpn.protocol.Protocol
|
||||||
import org.amnezia.vpn.protocol.ProtocolState.CONNECTED
|
import org.amnezia.vpn.protocol.ProtocolState.CONNECTED
|
||||||
import org.amnezia.vpn.protocol.ProtocolState.DISCONNECTED
|
import org.amnezia.vpn.protocol.ProtocolState.DISCONNECTED
|
||||||
|
|
@ -114,7 +115,9 @@ class Xray : Protocol() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val xrayJsonConfig = config.getJSONObject("xray_config_data")
|
val xrayJsonConfig = config.optJSONObject("xray_config_data")
|
||||||
|
?: config.optJSONObject("ssxray_config_data")
|
||||||
|
?: throw BadConfigException("config_data not found")
|
||||||
val xrayConfig = parseConfig(config, xrayJsonConfig)
|
val xrayConfig = parseConfig(config, xrayJsonConfig)
|
||||||
|
|
||||||
(xrayJsonConfig.optJSONObject("log") ?: JSONObject().also { xrayJsonConfig.put("log", it) })
|
(xrayJsonConfig.optJSONObject("log") ?: JSONObject().also { xrayJsonConfig.put("log", it) })
|
||||||
|
|
@ -223,6 +226,10 @@ class Xray : Protocol() {
|
||||||
throw VpnStartException("Failed to start tun2socks: $err")
|
throw VpnStartException("Failed to start tun2socks: $err")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val instance: Xray by lazy { Xray() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String?.isNotNullOrBlank(block: (String) -> Unit) {
|
private fun String?.isNotNullOrBlank(block: (String) -> Unit) {
|
||||||
|
|
|
||||||
|
|
@ -306,6 +306,7 @@ bool ContainerProps::isSupportedByCurrentPlatform(DockerContainer c)
|
||||||
case DockerContainer::Awg: return true;
|
case DockerContainer::Awg: return true;
|
||||||
case DockerContainer::Cloak: return true;
|
case DockerContainer::Cloak: return true;
|
||||||
case DockerContainer::Xray: return true;
|
case DockerContainer::Xray: return true;
|
||||||
|
case DockerContainer::SSXray: return true;
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue