Add the ability to set secret sending for NetworkEncryptionUpgradePackets on or off.
This commit is contained in:
parent
dfa921fa41
commit
bde5860b47
@ -24,6 +24,7 @@ public class NetworkEncryptionUpgradePacket implements IPacket, IAcknowledgement
|
||||
protected boolean upgrade;
|
||||
protected boolean base64ed;
|
||||
protected ICipherFactory cipherFactory;
|
||||
protected boolean sendSecrets;
|
||||
|
||||
protected final Object slock = new Object();
|
||||
|
||||
@ -82,7 +83,7 @@ public class NetworkEncryptionUpgradePacket implements IPacket, IAcknowledgement
|
||||
synchronized (slock) {
|
||||
if (acknowledgement == null) throw new PacketException("no data");
|
||||
|
||||
byte[] cipherBytes = (cipherFactory == null) ? null : cipherFactory.getSettings();
|
||||
byte[] cipherBytes = (cipherFactory == null) ? null : (sendSecrets) ? cipherFactory.getSettings() : cipherFactory.getSettingsNoSecrets();
|
||||
byte[] toret = new byte[2 + ((cipherBytes == null) ? 0 : cipherBytes.length)];
|
||||
toret[0] = (acknowledgement) ? (byte) 1 : (byte) 0;
|
||||
toret[1] = (byte) (((upgrade) ? 1 : 0) + ((base64ed) ? 2 : 0));
|
||||
@ -196,4 +197,24 @@ public class NetworkEncryptionUpgradePacket implements IPacket, IAcknowledgement
|
||||
public boolean isAcknowledgement() {
|
||||
return (acknowledgement != null && acknowledgement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if secrets are sent as part of cipher settings.
|
||||
*
|
||||
* @return If the secrets are part of the cipher settings.
|
||||
*/
|
||||
public boolean areSecretsSent() {
|
||||
return sendSecrets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if secrets should be sent as part of cipher settings.
|
||||
*
|
||||
* @param sendSecrets If secrets are part of the cipher settings.
|
||||
*/
|
||||
public void setIfSecretsSent(boolean sendSecrets) {
|
||||
synchronized (slock) {
|
||||
this.sendSecrets = sendSecrets;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user