44using BHD_ServerManager . Classes . Instances ;
55using BHD_ServerManager . Classes . ObjectClasses ;
66using BHD_ServerManager . Classes . SupportClasses ;
7+ using BHD_ServerManager . Classes . Services ;
78using System . Diagnostics ;
89using System . Net ;
910using System . Text ;
@@ -18,6 +19,7 @@ public partial class PlayerCard : UserControl
1819 private const string EncodingName = "Windows-1252" ;
1920
2021 private static chatInstance ChatInstance = CommonCore . instanceChat ! ;
22+ private static theInstance TheInstance = CommonCore . theInstance ! ;
2123 private playerObject Player { get ; set ; } = new playerObject ( ) ;
2224 private int SlotNumber = 0 ;
2325 private ContextMenuStrip ContextMenu ;
@@ -362,10 +364,71 @@ private ToolStripMenuItem CreateSwitchTeamMenuItem()
362364 }
363365
364366 // ================================================================================
365- // PLAYER CARD UI UPDATE METHODS (No changes needed)
367+ // PROXY/VPN DETECTION METHODS
366368 // ================================================================================
367369
368- public void UpdateStatus ( playerObject playerInfo )
370+ /// <summary>
371+ /// Check if player's IP is flagged as proxy/VPN/TOR
372+ /// </summary>
373+ private async Task < bool > IsProxyDetectedAsync ( string ipAddress )
374+ {
375+ try
376+ {
377+ // Check if proxy detection is enabled
378+ if ( ! TheInstance . proxyCheckEnabled || ! ProxyCheckManager . IsInitialized )
379+ return false ;
380+
381+ if ( ! IPAddress . TryParse ( ipAddress , out IPAddress ? ip ) )
382+ return false ;
383+
384+ var result = await ProxyCheckManager . CheckIPAsync ( ip ) ;
385+
386+ if ( result . Success )
387+ {
388+ // Check if any proxy/VPN/TOR flag is set
389+ return result . IsProxy || result . IsVpn || result . IsTor ;
390+ }
391+
392+ return false ;
393+ }
394+ catch ( Exception ex )
395+ {
396+ AppDebug . Log ( "PlayerCard" , $ "Error checking proxy status: { ex } ") ;
397+ return false ;
398+ }
399+ }
400+
401+ /// <summary>
402+ /// Update player icon based on team and proxy status
403+ /// </summary>
404+ private async Task UpdatePlayerIconAsync ( string ipAddress , int team )
405+ {
406+ bool isProxyDetected = await IsProxyDetectedAsync ( ipAddress ) ;
407+
408+ if ( isProxyDetected )
409+ {
410+ // Show warning icon for proxy/VPN/TOR
411+ playerTeamIcon . IconChar = FontAwesome . Sharp . IconChar . PersonCircleExclamation ;
412+ playerTeamIcon . IconColor = Color . Yellow ;
413+ }
414+ else
415+ {
416+ // Show default team icon
417+ playerTeamIcon . IconChar = FontAwesome . Sharp . IconChar . PersonHiking ;
418+ playerTeamIcon . IconColor = team switch
419+ {
420+ 1 => Color . Blue ,
421+ 2 => Color . Red ,
422+ _ => Color . Black
423+ } ;
424+ }
425+ }
426+
427+ // ================================================================================
428+ // PLAYER CARD UI UPDATE METHODS
429+ // ================================================================================
430+
431+ public async void UpdateStatus ( playerObject playerInfo )
369432 {
370433 Player = playerInfo ;
371434
@@ -378,12 +441,9 @@ public void UpdateStatus(playerObject playerInfo)
378441 label_dataPlayerNameRole . Text = decodedPlayerName ;
379442
380443 label_dataIPinfo . Text = Player . PlayerIPAddress ;
381- playerTeamIcon . IconColor = Player . PlayerTeam switch
382- {
383- 1 => Color . Blue ,
384- 2 => Color . Red ,
385- _ => Color . Black
386- } ;
444+
445+ // Update icon based on proxy detection and team
446+ await UpdatePlayerIconAsync ( Player . PlayerIPAddress , Player . PlayerTeam ) ;
387447
388448 ContextMenu . Items [ 0 ] . Text = decodedPlayerName ;
389449 ContextMenu . Items [ 1 ] . Text = $ "Ping: { Player . PlayerPing } ms";
@@ -407,7 +467,11 @@ public void ResetStatus()
407467 label_dataPlayerNameRole . UseCompatibleTextRendering = true ;
408468 label_dataPlayerNameRole . Text = Player . PlayerName ;
409469 label_dataSlotNum . Text = Player . PlayerSlot . ToString ( ) ;
470+
471+ // Reset to default icon
472+ playerTeamIcon . IconChar = FontAwesome . Sharp . IconChar . PersonHiking ;
410473 playerTeamIcon . IconColor = Color . Black ;
474+
411475 playerContextMenuIcon . Visible = false ;
412476 }
413477
0 commit comments