@@ -264,7 +264,7 @@ async ValueTask InnerOnLogin(ILoginClient localClient, LoginArgs localArgs)
264264 {
265265 var ipLocal = IPAddress . Parse ( ServerSetup . Instance . InternalAddress ) ;
266266
267- if ( GameMastersIPs . Any ( ip => localClient . RemoteIp . Equals ( IPAddress . Parse ( ip ) ) )
267+ if ( GameMastersIPs . Any ( ip => localClient . RemoteIp . Equals ( IPAddress . Parse ( ip ) ) )
268268 || IPAddress . IsLoopback ( localClient . RemoteIp ) || localClient . RemoteIp . Equals ( ipLocal ) )
269269 {
270270 _ = Login ( result , redirect , localClient ) ;
@@ -275,16 +275,16 @@ async ValueTask InnerOnLogin(ILoginClient localClient, LoginArgs localArgs)
275275 return ;
276276 }
277277 default :
278- {
279- if ( result . Hacked )
280278 {
281- localClient . SendLoginMessage ( LoginMessageType . CharacterDoesntExist , "Bruteforce detected, we've locked the account to protect it; If this is your account, please contact the GM." ) ;
282- return ;
283- }
279+ if ( result . Hacked )
280+ {
281+ localClient . SendLoginMessage ( LoginMessageType . CharacterDoesntExist , "Bruteforce detected, we've locked the account to protect it; If this is your account, please contact the GM." ) ;
282+ return ;
283+ }
284284
285- _ = Login ( result , redirect , localClient ) ;
286- break ;
287- }
285+ _ = Login ( result , redirect , localClient ) ;
286+ break ;
287+ }
288288 }
289289 }
290290 }
@@ -484,41 +484,52 @@ protected override void OnConnected(Socket clientSocket)
484484 var client = _clientProvider . CreateClient ( clientSocket ) ;
485485 client . OnDisconnected += OnDisconnect ;
486486
487- if ( ! ClientRegistry . TryAdd ( client ) )
487+ // Check for banned IPs
488+ var banned = BadActor . BannedIpCheck ( ipAddress . ToString ( ) ) ;
489+ if ( banned )
488490 {
489- ServerSetup . ConnectionLogger ( "Two clients ended up with the same id - newest client disconnected" ) ;
490491 try
491492 {
493+ ServerSetup . ConnectionLogger ( $ "Banned connection attempt on Login Server from { ip } ") ;
492494 client . Disconnect ( ) ;
493495 }
494- catch
496+ catch { }
497+
498+ return ;
499+ }
500+
501+ // Register client and check for ID collisions
502+ if ( ! ClientRegistry . TryAdd ( client ) )
503+ {
504+ try
495505 {
496- // ignored
506+ ServerSetup . ConnectionLogger ( "ID Collision - Login Server" ) ;
507+ client . Disconnect ( ) ;
497508 }
509+ catch { }
498510
499511 return ;
500512 }
501513
514+ // Verify connection passed through appropriate port access
502515 var lobbyCheck = ServerSetup . Instance . GlobalLobbyConnection . TryGetValue ( ipAddress , out _ ) ;
503516
504517 if ( ! lobbyCheck )
505518 {
506519 try
507520 {
508521 client . Disconnect ( ) ;
522+ ServerSetup . ConnectionLogger ( "---------Login-Server---------" ) ;
523+ var comment = $ "{ ipAddress } has been blocked for violating security protocols through improper port access.";
524+ ServerSetup . ConnectionLogger ( comment , LogLevel . Warning ) ;
525+ Task . Run ( ( ) => BadActor . ReportMaliciousEndpoint ( ipAddress . ToString ( ) , comment ) ) ;
509526 }
510- catch
511- {
512- // ignored
513- }
527+ catch { }
514528
515- ServerSetup . ConnectionLogger ( "---------Login-Server---------" ) ;
516- var comment = $ "{ ipAddress } has been blocked for violating security protocols through improper port access.";
517- ServerSetup . ConnectionLogger ( comment , LogLevel . Warning ) ;
518- Task . Run ( ( ) => BadActor . ReportMaliciousEndpoint ( ipAddress . ToString ( ) , comment ) ) ;
519529 return ;
520530 }
521531
532+ // Add to passed checks cache for Login Server
522533 ServerSetup . Instance . GlobalLoginConnection . TryAdd ( ipAddress , ipAddress ) ;
523534 client . BeginReceive ( ) ;
524535 // 0x7E - Handshake
0 commit comments