diff --git a/NOnion/Http/TorHttpClient.fs b/NOnion/Http/TorHttpClient.fs index e863ab00..f36565eb 100644 --- a/NOnion/Http/TorHttpClient.fs +++ b/NOnion/Http/TorHttpClient.fs @@ -51,7 +51,7 @@ type TorHttpClient(stream: TorStream, host: string) = do! ReceiveAll memStream - |> FSharpUtil.WithTimeout Constants.HttpGetResponseTimeout + |> NetworkUtils.WithTimeout Constants.HttpGetResponseTimeout let httpResponse = memStream.ToArray() @@ -145,7 +145,7 @@ type TorHttpClient(stream: TorStream, host: string) = do! ReceiveAll memStream - |> FSharpUtil.WithTimeout Constants.HttpPostResponseTimeout + |> NetworkUtils.WithTimeout Constants.HttpPostResponseTimeout let httpResponse = memStream.ToArray() diff --git a/NOnion/NOnion.fsproj b/NOnion/NOnion.fsproj index e3e280ef..a24c6a21 100644 --- a/NOnion/NOnion.fsproj +++ b/NOnion/NOnion.fsproj @@ -18,7 +18,7 @@ - + diff --git a/NOnion/Network/TorCircuit.fs b/NOnion/Network/TorCircuit.fs index 57c9f691..105dc246 100644 --- a/NOnion/Network/TorCircuit.fs +++ b/NOnion/Network/TorCircuit.fs @@ -1113,7 +1113,7 @@ and TorCircuit completionTaskRes |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout + |> NetworkUtils.WithTimeout Constants.CircuitOperationTimeout } member __.Extend(nodeDetail: CircuitNodeDetail) = @@ -1130,7 +1130,7 @@ and TorCircuit completionTaskRes |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout + |> NetworkUtils.WithTimeout Constants.CircuitOperationTimeout } member __.RegisterAsIntroductionPoint @@ -1156,7 +1156,7 @@ and TorCircuit completionTaskRes |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout + |> NetworkUtils.WithTimeout Constants.CircuitOperationTimeout } member __.RegisterAsRendezvousPoint(cookie: array) = @@ -1177,7 +1177,7 @@ and TorCircuit completionTaskRes |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout + |> NetworkUtils.WithTimeout Constants.CircuitOperationTimeout } member self.ExtendAsync nodeDetail = @@ -1203,7 +1203,7 @@ and TorCircuit completionTaskRes |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout + |> NetworkUtils.WithTimeout Constants.CircuitOperationTimeout } member __.WaitingForRendezvousJoin @@ -1231,7 +1231,7 @@ and TorCircuit completionTaskRes |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitRendezvousTimeout + |> NetworkUtils.WithTimeout Constants.CircuitRendezvousTimeout } diff --git a/NOnion/Network/TorGuard.fs b/NOnion/Network/TorGuard.fs index 5c1109cc..129a670d 100644 --- a/NOnion/Network/TorGuard.fs +++ b/NOnion/Network/TorGuard.fs @@ -120,7 +120,7 @@ type TorGuard private (client: TcpClient, sslStream: SslStream) = do! client.ConnectAsync(ipEndpoint.Address, ipEndpoint.Port) |> Async.AwaitTask - |> FSharpUtil.WithTimeout + |> NetworkUtils.WithTimeout Constants.GuardConnectionTimeout } @@ -148,7 +148,7 @@ type TorGuard private (client: TcpClient, sslStream: SslStream) = false ) |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout + |> NetworkUtils.WithTimeout Constants.CircuitOperationTimeout do! ExceptionUtil.RunGuardJobWithExceptionHandling( @@ -391,7 +391,7 @@ type TorGuard private (client: TcpClient, sslStream: SslStream) = TorLogger.Log "TorGuard: finished handshake process" //TODO: do security checks on handshake data } - |> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout + |> NetworkUtils.WithTimeout Constants.CircuitOperationTimeout member internal __.RegisterCircuit(circuit: ITorCircuit) : uint16 = let rec createCircuitId(retry: int) = diff --git a/NOnion/Network/TorStream.fs b/NOnion/Network/TorStream.fs index e29866c1..96d6a9f5 100644 --- a/NOnion/Network/TorStream.fs +++ b/NOnion/Network/TorStream.fs @@ -460,7 +460,7 @@ type TorStream(circuit: TorCircuit) = completionTaskRes |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.StreamCreationTimeout + |> NetworkUtils.WithTimeout Constants.StreamCreationTimeout } member self.ConnectToDirectory() = @@ -480,7 +480,7 @@ type TorStream(circuit: TorCircuit) = completionTaskResult |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.StreamCreationTimeout + |> NetworkUtils.WithTimeout Constants.StreamCreationTimeout } member self.ConnectToDirectoryAsync() = diff --git a/NOnion/Services/TorServiceHost.fs b/NOnion/Services/TorServiceHost.fs index a36cba24..627fd0eb 100644 --- a/NOnion/Services/TorServiceHost.fs +++ b/NOnion/Services/TorServiceHost.fs @@ -247,7 +247,7 @@ type TorServiceHost introEncPubKey do! - FSharpUtil.Retry + NetworkUtils.Retry connectToRendezvousJob maxRendezvousConnectRetryCount diff --git a/NOnion/Utility/FSharpUtil.fs b/NOnion/Utility/NetworkUtils.fs similarity index 93% rename from NOnion/Utility/FSharpUtil.fs rename to NOnion/Utility/NetworkUtils.fs index b5002f00..383ceeac 100644 --- a/NOnion/Utility/FSharpUtil.fs +++ b/NOnion/Utility/NetworkUtils.fs @@ -1,14 +1,12 @@ namespace NOnion.Utility open System -open System.Runtime.ExceptionServices -open FSharpx.Collections open Fsdk open NOnion -module FSharpUtil = +module NetworkUtils = let WithTimeout (timeSpan: TimeSpan) (job: Async<'R>) : Async<'R> = async { let! result = FSharpUtil.WithTimeout timeSpan job