Skip to content

Commit

Permalink
Http,Network,Services.Utitlity: rename FSharpUtil
Browse files Browse the repository at this point in the history
Renamed FSharpUtil module to AsyncUtil.
  • Loading branch information
webwarrior-ws committed Jan 18, 2023
1 parent 35d2ec5 commit abcbe43
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions NOnion/Http/TorHttpClient.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion NOnion/NOnion.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Compile Include="RelayIntroduceStatus.fs" />
<Compile Include="Exceptions.fs" />
<Compile Include="HandshakeType.fs" />
<Compile Include="Utility\FSharpUtil.fs" />
<Compile Include="Utility\AsyncUtil.fs" />
<Compile Include="Utility\ResultUtil.fs" />
<Compile Include="Utility\MailboxUtil.fs" />
<Compile Include="Utility\StreamUtil.fs" />
Expand Down
12 changes: 6 additions & 6 deletions NOnion/Network/TorCircuit.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ and TorCircuit
completionTaskRes
|> UnwrapResult
|> Async.AwaitTask
|> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout
|> AsyncUtil.WithTimeout Constants.CircuitOperationTimeout
}

member __.Extend(nodeDetail: CircuitNodeDetail) =
Expand All @@ -1130,7 +1130,7 @@ and TorCircuit
completionTaskRes
|> UnwrapResult
|> Async.AwaitTask
|> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout
|> AsyncUtil.WithTimeout Constants.CircuitOperationTimeout
}

member __.RegisterAsIntroductionPoint
Expand All @@ -1156,7 +1156,7 @@ and TorCircuit
completionTaskRes
|> UnwrapResult
|> Async.AwaitTask
|> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout
|> AsyncUtil.WithTimeout Constants.CircuitOperationTimeout
}

member __.RegisterAsRendezvousPoint(cookie: array<byte>) =
Expand All @@ -1177,7 +1177,7 @@ and TorCircuit
completionTaskRes
|> UnwrapResult
|> Async.AwaitTask
|> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout
|> AsyncUtil.WithTimeout Constants.CircuitOperationTimeout
}

member self.ExtendAsync nodeDetail =
Expand All @@ -1203,7 +1203,7 @@ and TorCircuit
completionTaskRes
|> UnwrapResult
|> Async.AwaitTask
|> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout
|> AsyncUtil.WithTimeout Constants.CircuitOperationTimeout
}

member __.WaitingForRendezvousJoin
Expand Down Expand Up @@ -1231,7 +1231,7 @@ and TorCircuit
completionTaskRes
|> UnwrapResult
|> Async.AwaitTask
|> FSharpUtil.WithTimeout Constants.CircuitRendezvousTimeout
|> AsyncUtil.WithTimeout Constants.CircuitRendezvousTimeout

}

Expand Down
6 changes: 3 additions & 3 deletions NOnion/Network/TorGuard.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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<unit>(
Expand Down Expand Up @@ -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) =
Expand Down
4 changes: 2 additions & 2 deletions NOnion/Network/TorStream.fs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ type TorStream(circuit: TorCircuit) =
completionTaskRes
|> UnwrapResult
|> Async.AwaitTask
|> FSharpUtil.WithTimeout Constants.StreamCreationTimeout
|> AsyncUtil.WithTimeout Constants.StreamCreationTimeout
}

member self.ConnectToDirectory() =
Expand All @@ -480,7 +480,7 @@ type TorStream(circuit: TorCircuit) =
completionTaskResult
|> UnwrapResult
|> Async.AwaitTask
|> FSharpUtil.WithTimeout Constants.StreamCreationTimeout
|> AsyncUtil.WithTimeout Constants.StreamCreationTimeout
}

member self.ConnectToDirectoryAsync() =
Expand Down
2 changes: 1 addition & 1 deletion NOnion/Services/TorServiceHost.fs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ type TorServiceHost
introEncPubKey

do!
FSharpUtil.Retry<NOnionException>
AsyncUtil.Retry<NOnionException>
connectToRendezvousJob
maxRendezvousConnectRetryCount

Expand Down
4 changes: 1 addition & 3 deletions NOnion/Utility/FSharpUtil.fs → NOnion/Utility/AsyncUtil.fs
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit abcbe43

Please sign in to comment.