|
@@ -19,7 +19,7 @@ import com.flashlink.vpn.XRayApi.Companion.VPN_STATE_ERROR
|
|
|
import com.flashlink.vpn.XRayApi.Companion.VPN_STATE_IDLE
|
|
import com.flashlink.vpn.XRayApi.Companion.VPN_STATE_IDLE
|
|
|
import com.google.gson.Gson
|
|
import com.google.gson.Gson
|
|
|
import go.Seq
|
|
import go.Seq
|
|
|
-import flashlink_mobile.FlashLink_mobile
|
|
|
|
|
|
|
+import flashlink_mobile.Flashlink_mobile
|
|
|
import flashlink_mobile.ProxyConnectorHandler
|
|
import flashlink_mobile.ProxyConnectorHandler
|
|
|
import kotlinx.coroutines.Job
|
|
import kotlinx.coroutines.Job
|
|
|
import kotlinx.coroutines.delay
|
|
import kotlinx.coroutines.delay
|
|
@@ -88,7 +88,7 @@ class XRayService : LifecycleVpnService() {
|
|
|
VLog.i(TAG, "XRayService onCreate")
|
|
VLog.i(TAG, "XRayService onCreate")
|
|
|
|
|
|
|
|
Seq.setContext(applicationContext)
|
|
Seq.setContext(applicationContext)
|
|
|
- FlashLink_mobile.initProxyConnector(0, getXrayLog())
|
|
|
|
|
|
|
+ Flashlink_mobile.initProxyConnector(0, getXrayLog())
|
|
|
registerNotificationChannel(
|
|
registerNotificationChannel(
|
|
|
this,
|
|
this,
|
|
|
NOTIFICATION_CHANNEL_ID,
|
|
NOTIFICATION_CHANNEL_ID,
|
|
@@ -240,7 +240,7 @@ class XRayService : LifecycleVpnService() {
|
|
|
|
|
|
|
|
// 清理资源
|
|
// 清理资源
|
|
|
try {
|
|
try {
|
|
|
- FlashLink_mobile.freeProxyConnector()
|
|
|
|
|
|
|
+ Flashlink_mobile.freeProxyConnector()
|
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
|
VLog.e(TAG, "freeProxyConnector 失败", e)
|
|
VLog.e(TAG, "freeProxyConnector 失败", e)
|
|
|
}
|
|
}
|
|
@@ -325,7 +325,7 @@ class XRayService : LifecycleVpnService() {
|
|
|
tunFd?.let { tfd ->
|
|
tunFd?.let { tfd ->
|
|
|
VLog.i(TAG, "VPN tunnel established, fd: ${tfd.fd}")
|
|
VLog.i(TAG, "VPN tunnel established, fd: ${tfd.fd}")
|
|
|
tunnelService.startTunnel(this, config.socksPort, config.tunnelConfig, tfd.fd)
|
|
tunnelService.startTunnel(this, config.socksPort, config.tunnelConfig, tfd.fd)
|
|
|
- FlashLink_mobile.proxyConnectorStart(config.sessionId, config.startOptions, vpnHandler)
|
|
|
|
|
|
|
+ Flashlink_mobile.proxyConnectorStart(config.sessionId, config.startOptions, vpnHandler)
|
|
|
VLog.i(TAG, "XRay proxy started successfully")
|
|
VLog.i(TAG, "XRay proxy started successfully")
|
|
|
} ?: run {
|
|
} ?: run {
|
|
|
VLog.e(TAG, "Failed to establish VPN tunnel")
|
|
VLog.e(TAG, "Failed to establish VPN tunnel")
|
|
@@ -407,7 +407,7 @@ class XRayService : LifecycleVpnService() {
|
|
|
*/
|
|
*/
|
|
|
private fun queryStats(vararg types: Byte): String? {
|
|
private fun queryStats(vararg types: Byte): String? {
|
|
|
return try {
|
|
return try {
|
|
|
- FlashLink_mobile.proxyConnectorQueryStats(types)
|
|
|
|
|
|
|
+ Flashlink_mobile.proxyConnectorQueryStats(types)
|
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
|
VLog.e(TAG, "queryStats error: ${e.message}")
|
|
VLog.e(TAG, "queryStats error: ${e.message}")
|
|
|
null
|
|
null
|
|
@@ -498,7 +498,7 @@ class XRayService : LifecycleVpnService() {
|
|
|
|
|
|
|
|
private fun stopProxyConnector() {
|
|
private fun stopProxyConnector() {
|
|
|
try {
|
|
try {
|
|
|
- FlashLink_mobile.proxyConnectorStop()
|
|
|
|
|
|
|
+ Flashlink_mobile.proxyConnectorStop()
|
|
|
VLog.i(TAG, "Proxy connector stopped")
|
|
VLog.i(TAG, "Proxy connector stopped")
|
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
|
VLog.e(TAG, "停止 proxy connector 失败", e)
|
|
VLog.e(TAG, "停止 proxy connector 失败", e)
|
|
@@ -612,7 +612,7 @@ class XRayService : LifecycleVpnService() {
|
|
|
*/
|
|
*/
|
|
|
private fun dealStat() {
|
|
private fun dealStat() {
|
|
|
val stats = queryStats(1, 2, 3) // 连接历史、带宽、最大速度
|
|
val stats = queryStats(1, 2, 3) // 连接历史、带宽、最大速度
|
|
|
- val version = FlashLink_mobile.proxyConnectorVersion()
|
|
|
|
|
|
|
+ val version = Flashlink_mobile.proxyConnectorVersion()
|
|
|
VLog.i(TAG, "stats = $stats")
|
|
VLog.i(TAG, "stats = $stats")
|
|
|
|
|
|
|
|
// 将 stats 和 version 写入 core.json 日志文件
|
|
// 将 stats 和 version 写入 core.json 日志文件
|