From c18ec5c6ba826736c17c038dd61fb9f43ffa35d1 Mon Sep 17 00:00:00 2001 From: Chord Date: Sat, 4 Jun 2016 03:15:27 -0400 Subject: [PATCH] Work around scodec-akka bug and remove old UDP packet --- pslogin/src/main/scala/SessionRouter.scala | 3 --- pslogin/src/main/scala/UdpListener.scala | 6 ++++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pslogin/src/main/scala/SessionRouter.scala b/pslogin/src/main/scala/SessionRouter.scala index 1ef4a33f8..d2e7c5cb7 100644 --- a/pslogin/src/main/scala/SessionRouter.scala +++ b/pslogin/src/main/scala/SessionRouter.scala @@ -56,9 +56,6 @@ class SessionRouter(pipeline : List[SessionPipeline]) extends Actor with MDCCont def initializing : Receive = { case Hello() => inputRef = sender() - - inputRef ! SendPacket(hex"41414141", new InetSocketAddress("8.8.8.8", 51000)) - context.become(started) case default => log.error(s"Unknown message $default. Stopping...") diff --git a/pslogin/src/main/scala/UdpListener.scala b/pslogin/src/main/scala/UdpListener.scala index 06d9dbddf..029bbaf05 100644 --- a/pslogin/src/main/scala/UdpListener.scala +++ b/pslogin/src/main/scala/UdpListener.scala @@ -4,8 +4,9 @@ import java.net.{InetAddress, InetSocketAddress} import akka.actor.SupervisorStrategy.{Restart, Stop} import akka.actor.{Actor, ActorRef, OneForOneStrategy, Props, Terminated} import akka.io._ -import scodec.bits.ByteVector +import scodec.bits._ import scodec.interop.akka._ +import akka.util.ByteString final case class ReceivedPacket(msg : ByteVector, from : InetSocketAddress) final case class SendPacket(msg : ByteVector, to : InetSocketAddress) @@ -40,7 +41,8 @@ class UdpListener(nextActorProps : Props, nextActorName : String, address : Inet def ready(socket: ActorRef): Receive = { case SendPacket(msg, to) => bytesSent += msg.size - socket ! Udp.Send(msg.toByteString, to) + // XXX: revert back to msg.toByteString when scodec-akka is unbroken... (this is doing a copy) + socket ! Udp.Send(ByteString(msg.toByteBuffer), to) case Udp.Received(data, remote) => bytesRecevied += data.size nextActor ! ReceivedPacket(data.toByteVector, remote)