Moved isEncrypted() check into KryoExtra
This commit is contained in:
parent
d39930a700
commit
b4394e6755
@ -44,6 +44,18 @@ class KryoExtra<C extends ICryptoConnection> extends Kryo {
|
|||||||
*/
|
*/
|
||||||
static final byte crypto = (byte) (1 << 1);
|
static final byte crypto = (byte) (1 << 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if this buffer is encrypted or not.
|
||||||
|
*/
|
||||||
|
public static
|
||||||
|
boolean isEncrypted(final ByteBuf buffer) {
|
||||||
|
// read off the magic byte
|
||||||
|
byte magicByte = buffer.getByte(buffer.readerIndex());
|
||||||
|
return (magicByte & crypto) == crypto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// snappycomp : 7.534 micros/op; 518.5 MB/s (output: 55.1%)
|
// snappycomp : 7.534 micros/op; 518.5 MB/s (output: 55.1%)
|
||||||
// snappyuncomp : 1.391 micros/op; 2808.1 MB/s
|
// snappyuncomp : 1.391 micros/op; 2808.1 MB/s
|
||||||
// lz4comp : 6.210 micros/op; 629.0 MB/s (output: 55.4%)
|
// lz4comp : 6.210 micros/op; 629.0 MB/s (output: 55.4%)
|
||||||
|
@ -25,8 +25,8 @@ import org.slf4j.Logger;
|
|||||||
import dorkbox.network.Broadcast;
|
import dorkbox.network.Broadcast;
|
||||||
import dorkbox.network.connection.Connection;
|
import dorkbox.network.connection.Connection;
|
||||||
import dorkbox.network.connection.ConnectionImpl;
|
import dorkbox.network.connection.ConnectionImpl;
|
||||||
import dorkbox.network.connection.CryptoSerializationManager;
|
|
||||||
import dorkbox.network.connection.EndPointBase;
|
import dorkbox.network.connection.EndPointBase;
|
||||||
|
import dorkbox.network.connection.KryoExtra;
|
||||||
import dorkbox.network.connection.RegistrationWrapper;
|
import dorkbox.network.connection.RegistrationWrapper;
|
||||||
import dorkbox.network.connection.registration.MetaChannel;
|
import dorkbox.network.connection.registration.MetaChannel;
|
||||||
import dorkbox.network.connection.registration.Registration;
|
import dorkbox.network.connection.registration.Registration;
|
||||||
@ -178,7 +178,7 @@ class RegistrationRemoteHandlerServerUDP<C extends Connection> extends MessageTo
|
|||||||
RegistrationWrapper<C> registrationWrapper2 = this.registrationWrapper;
|
RegistrationWrapper<C> registrationWrapper2 = this.registrationWrapper;
|
||||||
dorkbox.network.util.CryptoSerializationManager serializationManager2 = this.serializationManager;
|
dorkbox.network.util.CryptoSerializationManager serializationManager2 = this.serializationManager;
|
||||||
|
|
||||||
if (CryptoSerializationManager.isEncrypted(message)) {
|
if (KryoExtra.isEncrypted(message)) {
|
||||||
// we need to FORWARD this message "down the pipeline".
|
// we need to FORWARD this message "down the pipeline".
|
||||||
|
|
||||||
ConnectionImpl connection = registrationWrapper2.getServerUDP(udpRemoteAddress);
|
ConnectionImpl connection = registrationWrapper2.getServerUDP(udpRemoteAddress);
|
||||||
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import dorkbox.network.connection.CryptoSerializationManager;
|
import dorkbox.network.connection.KryoExtra;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandler.Sharable;
|
import io.netty.channel.ChannelHandler.Sharable;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
@ -48,7 +48,7 @@ class KryoDecoderUdp extends MessageToMessageDecoder<DatagramPacket> {
|
|||||||
// there is a REMOTE possibility that UDP traffic BEAT the TCP registration traffic, which means that THIS packet
|
// there is a REMOTE possibility that UDP traffic BEAT the TCP registration traffic, which means that THIS packet
|
||||||
// COULD be encrypted!
|
// COULD be encrypted!
|
||||||
|
|
||||||
if (CryptoSerializationManager.isEncrypted(data)) {
|
if (KryoExtra.isEncrypted(data)) {
|
||||||
String message = "Encrypted UDP packet received before registration complete.";
|
String message = "Encrypted UDP packet received before registration complete.";
|
||||||
LoggerFactory.getLogger(this.getClass()).error(message);
|
LoggerFactory.getLogger(this.getClass()).error(message);
|
||||||
throw new IOException(message);
|
throw new IOException(message);
|
||||||
|
Loading…
Reference in New Issue
Block a user