Organize packets in to their own packages

Also remove legacy CryptoStateManager
This commit is contained in:
Chord 2016-05-03 20:11:45 -04:00
parent e41d0ac9c4
commit ff4ea792ce
23 changed files with 65 additions and 90 deletions

View file

@ -11,6 +11,9 @@ import scodec.{Attempt, Codec, Err}
import scodec.codecs.{bytes, uint16L, uint8L}
import java.security.SecureRandom
import net.psforever.packet.control.{ClientStart, ServerStart}
import net.psforever.packet.crypto._
/**
* Actor that stores crypto state for a connection and filters away any packet metadata.
*/

View file

@ -3,6 +3,8 @@ import java.net.{InetAddress, InetSocketAddress}
import akka.actor.{Actor, ActorLogging, ActorRef, Identify, MDCContextAware}
import net.psforever.packet._
import net.psforever.packet.control.{ConnectionClose, SlottedMetaPacket}
import net.psforever.packet.game._
import scodec.Attempt.{Failure, Successful}
import scodec.bits._
@ -61,7 +63,7 @@ class LoginSessionActor extends Actor with MDCContextAware {
}
def handleGamePkt(pkt : PlanetSideGamePacket) = {
log.debug(s"Unhandled GamePacket ${pkt}")
}
def failWithError(error : String) = {

View file

@ -1,41 +0,0 @@
// Copyright (c) 2016 PSForever.net to present
package net.psforever.crypto
import akka.actor.{Actor, ActorLogging, FSM}
import akka.util.ByteString
import scodec.Codec
import scodec.bits.ByteVector
sealed trait CryptoState
final case class ClientStart() extends CryptoState
final case class ServerStart() extends CryptoState
final case class ClientChallengeXchg() extends CryptoState
final case class ServerChallengeXchg() extends CryptoState
final case class ClientFinished() extends CryptoState
final case class ServerFinished() extends CryptoState
sealed trait CryptoData
final case class Uninitialized() extends CryptoData
class CryptoStateManager extends Actor with ActorLogging with FSM[CryptoState, CryptoData] {
startWith(ClientStart(), Uninitialized())
when(ClientStart()) {
/*case Event(RawPacket(msg), _) => {
val decoded = Codec.decode[net.psforever.net.ClientStart](msg.bits)
try {
val packet = decoded.require.value
println("Got cNonce: " + packet.clientNonce)
}
catch {
case e : Exception =>
println("Invalid packet: " + e.getMessage)
}
stay
}*/
case _ => stay
}
initialize()
}