transforming payload of ResetSequence into flags, sequence, and remainder, along with a test decryption

This commit is contained in:
Jason_DiDonato@yahoo.com 2021-03-24 14:09:55 -04:00
parent bd01fd1695
commit 7cd3f4d63f
3 changed files with 15 additions and 6 deletions

View file

@ -417,7 +417,7 @@ class MiddlewareActor(
case Successful((packet, None)) =>
in(packet)
case Failure(e) =>
log.error(s"Could not decode packet: $e")
log.error(s"Could not decode $connectionId's packet: $e")
}
Behaviors.same

View file

@ -39,6 +39,9 @@ trait PlanetSideCryptoPacket extends PlanetSidePacket {
def opcode: CryptoPacketOpcode.Type
}
/** PlanetSide ResetSequence packets: self-contained? */
trait PlanetSideResetSequencePacket extends PlanetSidePacket { }
/** PlanetSide packet type. Used in more complicated packet headers
*
* ResetSequence - Not sure what this is used for or if the name matches what it actually does

View file

@ -174,10 +174,12 @@ object PacketCoding {
}
case PacketType.Crypto =>
if (flags.secured && crypto.isEmpty) {
return Failure(Err("Unsupported packet type: crypto packets must be unencrypted"))
return Failure(Err("Unsupported packet type: secured crypto packets must be unencrypted"))
}
case PacketType.ResetSequence =>
return Failure(Err(s"Caught a wild ResetSequence when cryptoState is ${crypto.nonEmpty}: $msg -> $flags and $remainder"))
if (!flags.secured || crypto.isEmpty) {
return Failure(Err("Unsupported packet type: reset sequence packets must be encrypted"))
}
case _ =>
return Failure(Err(s"Unsupported packet type: ${flags.packetType.toString}"))
}
@ -187,7 +189,7 @@ object PacketCoding {
case Successful(DecodeResult(value, _remainder)) =>
(value, _remainder.toByteVector)
case Failure(e) =>
return Failure(Err(s"Failed to parse packet sequence number: ${e.message}"))
return Failure(Err(s"Failed to parse ${flags.packetType} packet sequence number: ${e.message}"))
}
(flags.packetType, crypto) match {
@ -201,9 +203,13 @@ object PacketCoding {
case (PacketType.Normal, None) if !flags.secured =>
decodePacket(payload).map(p => (p, sequence))
case (PacketType.Normal, None) =>
Failure(Err(s"Cannot unmarshal encrypted packet without CryptoCoding"))
Failure(Err("Cannot unmarshal encrypted packet without a cipher"))
case (PacketType.ResetSequence, Some(_crypto)) =>
val test = _crypto.decrypt(payload.drop(1))
Failure(Err(s"ResetSequence not completely supported, but: $flags, $sequence, and $payload; decrypt: $test"))
case (ptype, _) =>
Failure(Err(s"Cannot unmarshal $ptype packet at all"))
}
}
/**