-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
87 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...om/karasiq/proxychain/app/AppConfig.scala → ...la/com/karasiq/proxychain/AppConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...com/karasiq/proxychain/app/Firewall.scala → ...ala/com/karasiq/proxychain/Firewall.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/scala/com/karasiq/proxychain/app/ConnectionWatcher.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.karasiq.proxychain.app | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
import akka.actor._ | ||
import akka.io.Tcp | ||
import com.karasiq.proxychain.AppConfig | ||
|
||
import scala.concurrent.duration._ | ||
|
||
private[app] object ConnectionWatcher { | ||
case object Refresh | ||
|
||
def closeFrozenConnectionsAfter(): Option[FiniteDuration] = { | ||
val config = AppConfig.externalConfig().getConfig("proxyChain") | ||
val ms = config.getDuration("frozen-connection-close", TimeUnit.MILLISECONDS) | ||
if (ms > 0) Some(FiniteDuration(ms, TimeUnit.MILLISECONDS)) else None | ||
} | ||
} | ||
|
||
private[app] final class ConnectionWatcher(connection: ActorRef) extends Actor { | ||
import context.dispatcher | ||
|
||
context.watch(connection) | ||
private val closeAfter = ConnectionWatcher.closeFrozenConnectionsAfter() | ||
private var task = createTask() | ||
|
||
def createTask(): Cancellable = { | ||
closeAfter.map { ca ⇒ | ||
context.system.scheduler.scheduleOnce(ca) { | ||
connection ! Tcp.Close | ||
} | ||
}.orNull | ||
} | ||
|
||
override def receive: Receive = { | ||
case Terminated(`connection`) ⇒ | ||
task.cancel() | ||
context.stop(self) | ||
|
||
case ConnectionWatcher.Refresh if task != null && (task.cancel() || task.isCancelled) ⇒ | ||
task = createTask() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../proxychain/app/script/ChainBuilder.scala → ...asiq/proxychain/script/ChainBuilder.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...proxychain/app/script/ChainSelector.scala → ...siq/proxychain/script/ChainSelector.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...q/proxychain/app/script/Conversions.scala → ...rasiq/proxychain/script/Conversions.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rasiq/proxychain/app/script/Invoker.scala → ...m/karasiq/proxychain/script/Invoker.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.karasiq.proxychain.app.script | ||
package com.karasiq.proxychain.script | ||
|
||
import javax.script.Invocable | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...q/proxychain/app/script/ProxySource.scala → ...rasiq/proxychain/script/ProxySource.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters