From abcbe430e1477bd01237d18eb259557c445b7102 Mon Sep 17 00:00:00 2001 From: webwarrior Date: Wed, 18 Jan 2023 10:39:41 +0100 Subject: [PATCH] Http,Network,Services.Utitlity: rename FSharpUtil Renamed FSharpUtil module to AsyncUtil. --- NOnion/Http/TorHttpClient.fs | 4 ++-- NOnion/NOnion.fsproj | 2 +- NOnion/Network/TorCircuit.fs | 12 ++++++------ NOnion/Network/TorGuard.fs | 6 +++--- NOnion/Network/TorStream.fs | 4 ++-- NOnion/Services/TorServiceHost.fs | 2 +- NOnion/Utility/{FSharpUtil.fs => AsyncUtil.fs} | 4 +--- 7 files changed, 16 insertions(+), 18 deletions(-) rename NOnion/Utility/{FSharpUtil.fs => AsyncUtil.fs} (93%) diff --git a/NOnion/Http/TorHttpClient.fs b/NOnion/Http/TorHttpClient.fs index e863ab00..57141dca 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 + |> AsyncUtil.WithTimeout Constants.HttpGetResponseTimeout let httpResponse = memStream.ToArray() @@ -145,7 +145,7 @@ type TorHttpClient(stream: TorStream, host: string) = do! ReceiveAll memStream - |> FSharpUtil.WithTimeout Constants.HttpPostResponseTimeout + |> AsyncUtil.WithTimeout Constants.HttpPostResponseTimeout let httpResponse = memStream.ToArray() diff --git a/NOnion/NOnion.fsproj b/NOnion/NOnion.fsproj index e3e280ef..93142f51 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..77cea288 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 + |> AsyncUtil.WithTimeout Constants.CircuitOperationTimeout } member __.Extend(nodeDetail: CircuitNodeDetail) = @@ -1130,7 +1130,7 @@ and TorCircuit completionTaskRes |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout + |> AsyncUtil.WithTimeout Constants.CircuitOperationTimeout } member __.RegisterAsIntroductionPoint @@ -1156,7 +1156,7 @@ and TorCircuit completionTaskRes |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout + |> AsyncUtil.WithTimeout Constants.CircuitOperationTimeout } member __.RegisterAsRendezvousPoint(cookie: array) = @@ -1177,7 +1177,7 @@ and TorCircuit completionTaskRes |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout + |> AsyncUtil.WithTimeout Constants.CircuitOperationTimeout } member self.ExtendAsync nodeDetail = @@ -1203,7 +1203,7 @@ and TorCircuit completionTaskRes |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout + |> AsyncUtil.WithTimeout Constants.CircuitOperationTimeout } member __.WaitingForRendezvousJoin @@ -1231,7 +1231,7 @@ and TorCircuit completionTaskRes |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitRendezvousTimeout + |> AsyncUtil.WithTimeout Constants.CircuitRendezvousTimeout } diff --git a/NOnion/Network/TorGuard.fs b/NOnion/Network/TorGuard.fs index 5c1109cc..2d59696b 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 + |> AsyncUtil.WithTimeout Constants.GuardConnectionTimeout } @@ -148,7 +148,7 @@ type TorGuard private (client: TcpClient, sslStream: SslStream) = false ) |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout + |> AsyncUtil.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 + |> AsyncUtil.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..74c0e78f 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 + |> AsyncUtil.WithTimeout Constants.StreamCreationTimeout } member self.ConnectToDirectory() = @@ -480,7 +480,7 @@ type TorStream(circuit: TorCircuit) = completionTaskResult |> UnwrapResult |> Async.AwaitTask - |> FSharpUtil.WithTimeout Constants.StreamCreationTimeout + |> AsyncUtil.WithTimeout Constants.StreamCreationTimeout } member self.ConnectToDirectoryAsync() = diff --git a/NOnion/Services/TorServiceHost.fs b/NOnion/Services/TorServiceHost.fs index a36cba24..d2ce04b0 100644 --- a/NOnion/Services/TorServiceHost.fs +++ b/NOnion/Services/TorServiceHost.fs @@ -247,7 +247,7 @@ type TorServiceHost introEncPubKey do! - FSharpUtil.Retry + AsyncUtil.Retry connectToRendezvousJob maxRendezvousConnectRetryCount diff --git a/NOnion/Utility/FSharpUtil.fs b/NOnion/Utility/AsyncUtil.fs similarity index 93% rename from NOnion/Utility/FSharpUtil.fs rename to NOnion/Utility/AsyncUtil.fs index b5002f00..7480b7a3 100644 --- a/NOnion/Utility/FSharpUtil.fs +++ b/NOnion/Utility/AsyncUtil.fs @@ -1,14 +1,12 @@ namespace NOnion.Utility open System -open System.Runtime.ExceptionServices -open FSharpx.Collections open Fsdk open NOnion -module FSharpUtil = +module AsyncUtil = let WithTimeout (timeSpan: TimeSpan) (job: Async<'R>) : Async<'R> = async { let! result = FSharpUtil.WithTimeout timeSpan job