Bug fixes
This commit is contained in:
@@ -129,11 +129,9 @@ public final class AuthPacket extends OACPacket {
|
||||
setResponseCode(INSResponseStatus.RESPONSE_AUTH_SUCCESS);
|
||||
|
||||
CustomConnectedClient client = protocolBridge.getProtocolServer().getClientByID(clientID);
|
||||
if (client != null) {
|
||||
client.setClientVersion(clientVersion);
|
||||
protocolBridge.getProtocolValues().eventManager.executeEvent(new S_CustomClientConnectedEvent(client));
|
||||
client.getConnection().sendPacket(new AuthPacket(protocolBridge), TransportProtocol.TCP);
|
||||
}
|
||||
client.setClientVersion(clientVersion);
|
||||
protocolBridge.getProtocolValues().eventManager.executeEvent(new S_CustomClientConnectedEvent(client));
|
||||
client.getConnection().sendPacket(new AuthPacket(protocolBridge), TransportProtocol.TCP);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -142,7 +140,12 @@ public final class AuthPacket extends OACPacket {
|
||||
boolean fromINS = objectInputStream.readBoolean();
|
||||
ProtocolVersion serverVersion = ProtocolVersion.valueOf(objectInputStream.readUTF());
|
||||
|
||||
if (fromINS) {
|
||||
if (!fromINS) {
|
||||
protocolBridge.getProtocolClient().setServerVersion(serverVersion);
|
||||
protocolBridge.getProtocolValues().eventManager.executeEvent(
|
||||
new ConnectedToProtocolServerEvent(protocolBridge.getProtocolClient())
|
||||
);
|
||||
} else {
|
||||
if (!protocolBridge.isVersionSupported(serverVersion)) {
|
||||
setResponseCode(INSResponseStatus.RESPONSE_AUTH_FAILED);
|
||||
if (protocolBridge.getProtocolClient() != null && protocolBridge.getProtocolClient().getClientINSConnection() != null) {
|
||||
@@ -159,7 +162,10 @@ public final class AuthPacket extends OACPacket {
|
||||
|
||||
if (caPem.equalsIgnoreCase("N/A")) {
|
||||
setResponseCode(INSResponseStatus.RESPONSE_AUTH_FAILED);
|
||||
} else {
|
||||
protocolBridge.getProtocolClient().getClientINSConnection().disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] caBytes = caPem.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
String fp = "N/A";
|
||||
|
||||
@@ -178,45 +184,36 @@ public final class AuthPacket extends OACPacket {
|
||||
protocolBridge.getProtocolClient().getFolderStructure().publicCAFolder,
|
||||
caPrefix + ".fp");
|
||||
|
||||
|
||||
if (fpFile.exists()) {
|
||||
if (!fpFile.exists()) {
|
||||
if (!protocolBridge.getProtocolClient().trustINS(fp)) {
|
||||
setResponseCode(INSResponseStatus.RESPONSE_AUTH_FAILED);
|
||||
protocolBridge.getProtocolClient().getClientINSConnection().disconnect();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
String existing = FileUtils.readFileLines(fpFile).getFirst();
|
||||
if (!existing.equalsIgnoreCase(fp)) {
|
||||
if (!protocolBridge.getProtocolClient().trustNewINSFingerprint(existing, fp)) {
|
||||
setResponseCode(INSResponseStatus.RESPONSE_AUTH_FAILED);
|
||||
protocolBridge.getProtocolClient().getClientINSConnection().disconnect();
|
||||
return;
|
||||
} else {
|
||||
FileUtils.writeFile(fpFile, fp + System.lineSeparator());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!protocolBridge.getProtocolClient().trustINS(fp)) {
|
||||
setResponseCode(INSResponseStatus.RESPONSE_AUTH_FAILED);
|
||||
protocolBridge.getProtocolClient().getClientINSConnection().disconnect();
|
||||
return;
|
||||
} else {
|
||||
FileUtils.writeFile(fpFile, fp + System.lineSeparator());
|
||||
}
|
||||
}
|
||||
|
||||
FileUtils.writeFile(fpFile, fp + System.lineSeparator());
|
||||
|
||||
try {
|
||||
FileUtils.writeFile(caPemFile, caPem);
|
||||
} catch (Exception exception) {
|
||||
protocolBridge.getLogger().exception("Failed to create/save ca-files", exception);
|
||||
setResponseCode(INSResponseStatus.RESPONSE_AUTH_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
protocolBridge.getProtocolClient().setInsVersion(serverVersion);
|
||||
protocolBridge.getProtocolValues().eventManager.executeEvent(
|
||||
new ConnectedToProtocolINSServerEvent(protocolBridge.getProtocolClient())
|
||||
);
|
||||
} else {
|
||||
protocolBridge.getProtocolClient().setServerVersion(serverVersion);
|
||||
protocolBridge.getProtocolValues().eventManager.executeEvent(
|
||||
new ConnectedToProtocolServerEvent(protocolBridge.getProtocolClient())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user