Turnabout on Character stats concurrency + Null remote IP patch

Cleared the concurrency conflicts that started occuring after the abstract character's listener code was set to run on new thread, potentally leading to several onStatChange mishaps.
Added a check for remoteHost being possibly null when opening a new session with the client.
This commit is contained in:
ronancpl
2019-04-23 11:14:40 -03:00
parent 1376c295e1
commit e18061ffaf
7 changed files with 48 additions and 42 deletions

View File

@@ -63,16 +63,21 @@ public final class LoginPasswordHandler implements MaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
String remoteHost = getRemoteIp(c.getSession());
if (remoteHost.startsWith("127.")) {
if (!ServerConstants.LOCALSERVER) { // thanks Mills for noting HOST can also have a field named "localhost"
c.announce(MaplePacketCreator.getLoginFailed(13)); // cannot login as localhost if it's not a local server
return;
if (!remoteHost.contentEquals("null")) {
if (remoteHost.startsWith("127.")) {
if (!ServerConstants.LOCALSERVER) { // thanks Mills for noting HOST can also have a field named "localhost"
c.announce(MaplePacketCreator.getLoginFailed(13)); // cannot login as localhost if it's not a local server
return;
}
} else {
if (ServerConstants.LOCALSERVER) {
c.announce(MaplePacketCreator.getLoginFailed(13)); // cannot login as non-localhost if it's a local server
return;
}
}
} else {
if (ServerConstants.LOCALSERVER) {
c.announce(MaplePacketCreator.getLoginFailed(13)); // cannot login as non-localhost if it's a local server
return;
}
c.announce(MaplePacketCreator.getLoginFailed(14)); // thanks Alchemist for noting remoteHost could be null
return;
}
String login = slea.readMapleAsciiString();