summaryrefslogtreecommitdiff
path: root/src/main/scala/com/tylerstonge/honeypot/http/HttpListener.scala
blob: 8943ee0ec5a1254c5fd78aade83ef581c326f802 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.tylerstonge.honeypot.http

import java.net.InetSocketAddress

import akka.actor.{Actor, Props}
import akka.event.Logging
import akka.io.Tcp._
import akka.io.{IO, Tcp}


class HttpListener extends Actor {
  val log = Logging(context.system, this)

  import context.system

  IO(Tcp) ! Bind(self, new InetSocketAddress("localhost", 7333))

  override def receive: Receive = {
    case b@Bound(localAddress) => context.parent ! b
    case CommandFailed(_: Bind) => context.stop(self)
    case c@Connected(remote, local) =>
      val handler = context.actorOf(Props[SimplisticHandler])
      val connection = sender()
      connection ! Register(handler)
  }

}