@@ -29,6 +29,8 @@ import androidx.compose.ui.text.style.TextAlign
2929import androidx.compose.ui.unit.dp
3030import androidx.compose.ui.unit.sp
3131import androidx.hilt.navigation.compose.hiltViewModel
32+ import com.google.gson.Gson
33+ import com.google.gson.reflect.TypeToken
3234import com.masterdns.vpn.ui.theme.*
3335import com.masterdns.vpn.util.VpnManager
3436
@@ -43,6 +45,14 @@ fun HomeScreen(
4345 val scanStatus by VpnManager .scanStatus.collectAsState()
4446 val selectedProfile by viewModel.selectedProfile.collectAsState()
4547 val context = LocalContext .current
48+ val advanced = remember(selectedProfile?.advancedJson) {
49+ parseAdvanced(selectedProfile?.advancedJson.orEmpty())
50+ }
51+ val proxyHost = advanced[" LISTEN_IP" ]?.trim().takeUnless { it.isNullOrEmpty() } ? : " 127.0.0.1"
52+ val proxyPort = selectedProfile?.listenPort ? : 18000
53+ val socksAuthEnabled = advanced[" SOCKS5_AUTH" ].equals(" true" , ignoreCase = true )
54+ val socksUser = advanced[" SOCKS5_USER" ]?.trim().orEmpty()
55+ val socksPass = advanced[" SOCKS5_PASS" ]?.trim().orEmpty()
4656
4757 val vpnPermissionLauncher = rememberLauncherForActivityResult(
4858 ActivityResultContracts .StartActivityForResult ()
@@ -275,6 +285,18 @@ fun HomeScreen(
275285 text = " Download: ${formatSpeed(downBps)} Upload: ${formatSpeed(upBps)} " ,
276286 style = MaterialTheme .typography.bodySmall
277287 )
288+ Spacer (modifier = Modifier .height(8 .dp))
289+ Text (
290+ text = " SOCKS5: $proxyHost :$proxyPort " ,
291+ style = MaterialTheme .typography.bodySmall.copy(fontWeight = FontWeight .SemiBold )
292+ )
293+ if (socksAuthEnabled && socksUser.isNotBlank() && socksPass.isNotBlank()) {
294+ Spacer (modifier = Modifier .height(2 .dp))
295+ Text (
296+ text = " Auth: $socksUser / $socksPass " ,
297+ style = MaterialTheme .typography.bodySmall
298+ )
299+ }
278300 }
279301 }
280302
@@ -350,3 +372,12 @@ private fun formatSpeed(bps: Long): String {
350372 else -> " ${bps} B/s"
351373 }
352374}
375+
376+ private fun parseAdvanced (json : String ): Map <String , String > {
377+ return try {
378+ val type = object : TypeToken <Map <String , String >>() {}.type
379+ Gson ().fromJson<Map <String , String >>(json, type) ? : emptyMap()
380+ } catch (_: Exception ) {
381+ emptyMap()
382+ }
383+ }
0 commit comments