Skip to content

Commit

Permalink
migration to akka-streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Karasiq committed May 27, 2016
1 parent 4d1628b commit a50cada
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 245 deletions.
30 changes: 18 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@ name := "proxychain"

organization := "com.github.karasiq"

version := "1.5"
version := "2.0.0"

isSnapshot := false
isSnapshot := version.value.endsWith("SNAPSHOT")

scalaVersion := "2.11.7"
scalaVersion := "2.11.8"

resolvers += "softprops-maven" at "http://dl.bintray.com/content/softprops/maven"

libraryDependencies ++= Seq(
"commons-io" % "commons-io" % "2.4",
"org.apache.httpcomponents" % "httpclient" % "4.3.3",
"com.typesafe.akka" %% "akka-actor" % "2.3.11",
"org.scalatest" %% "scalatest" % "2.2.4" % "test",
"com.github.karasiq" %% "cryptoutils" % "1.2",
"com.github.karasiq" %% "proxyutils" % "1.0",
"com.github.karasiq" %% "coffeescript" % "1.0"
)
// resolvers += Resolver.sonatypeRepo("snapshots")

libraryDependencies ++= {
val akkaV = "2.4.6"
Seq(
"commons-io" % "commons-io" % "2.4",
"org.apache.httpcomponents" % "httpclient" % "4.3.3",
"com.typesafe.akka" %% "akka-actor" % akkaV,
"com.typesafe.akka" %% "akka-stream" % akkaV,
"org.scalatest" %% "scalatest" % "2.2.4" % "test",
"com.github.karasiq" %% "cryptoutils" % "1.2",
"com.github.karasiq" %% "proxyutils" % "2.0.2",
"com.github.karasiq" %% "coffeescript" % "1.0"
)
}

scalacOptions ++= Seq("-optimize", "-deprecation", "-feature")

Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
logLevel := Level.Warn

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.5-M3")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.1")
25 changes: 5 additions & 20 deletions src/main/scala/com/karasiq/proxychain/AppConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package com.karasiq.proxychain
import java.net.InetSocketAddress

import com.karasiq.fileutils.PathUtils._
import com.karasiq.proxy.{ProxyChain, ProxyChainFactory, ProxyConnectorFactory}
import com.karasiq.networkutils.proxy.Proxy
import com.karasiq.proxy.ProxyChain
import com.karasiq.tls.x509.CertificateVerifier
import com.karasiq.tls.{TLS, TLSKeyStore}
import com.typesafe.config.{Config, ConfigFactory}
Expand All @@ -12,8 +13,8 @@ object AppConfig {
def apply(cfg: Config): AppConfig = new AppConfig {
override def firewall(): Firewall = Firewall(cfg)

override def proxyChainsFor(address: InetSocketAddress): Seq[ProxyChain] = {
def loadChain(): ProxyChain = AppConfig.proxyChainFactory().config(cfg)
override def proxyChainsFor(address: InetSocketAddress): Seq[Seq[Proxy]] = {
def loadChain(): Seq[Proxy] = ProxyChain.chainFromConfig(cfg)
val maxChains: Int = cfg.getInt("maxTriedChains")

Seq.fill(maxChains)(loadChain()).distinct
Expand Down Expand Up @@ -46,25 +47,9 @@ object AppConfig {
val keySet = keyStore.getKeySet(config.getString("key"))
TLSConfig(keyStore, verifier, keySet, clientAuth)
}

def proxyConnectorFactory(): ProxyConnectorFactory = new ProxyConnectorFactory {
private val tls = tlsConfig()

override protected def keyStore: TLSKeyStore = {
tls.keyStore
}

override protected def certificateVerifier: CertificateVerifier = {
tls.verifier
}
}

def proxyChainFactory(): ProxyChainFactory = new ProxyChainFactory {
override protected val proxyConnectorFactory: ProxyConnectorFactory = AppConfig.proxyConnectorFactory()
}
}

trait AppConfig {
def firewall(): Firewall
def proxyChainsFor(address: InetSocketAddress): Seq[ProxyChain]
def proxyChainsFor(address: InetSocketAddress): Seq[Seq[Proxy]]
}
6 changes: 5 additions & 1 deletion src/main/scala/com/karasiq/proxychain/app/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import com.karasiq.proxychain.AppConfig
import com.karasiq.proxychain.script.ScriptEngine
import com.typesafe.config.Config

import scala.concurrent.Await
import scala.concurrent.duration._
import scala.language.postfixOps

object Boot extends App {
val configFile: Config = AppConfig.externalConfig()
val actorSystem: ActorSystem = ActorSystem("ProxyChain", configFile.resolve())
Expand Down Expand Up @@ -44,7 +48,7 @@ object Boot extends App {
Runtime.getRuntime.addShutdownHook(new Thread(new Runnable {
override def run(): Unit = {
actorSystem.log.debug("Shutting down proxychain daemon")
actorSystem.shutdown()
Await.result(actorSystem.terminate(), 5 minutes)
}
}))
}
44 changes: 0 additions & 44 deletions src/main/scala/com/karasiq/proxychain/app/ConnectionWatcher.scala

This file was deleted.

Loading

0 comments on commit a50cada

Please sign in to comment.