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 May 29, 2023
1 parent 92e5466 commit 67a8ec0
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion NOnion/Directory/KeyCertificatesDocument.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open System.Text
open Org.BouncyCastle.Asn1

open NOnion.Crypto.DirectoryCipher
open NOnion.Utility.FSharpUtil
open NOnion.Utility.AsyncUtil
open NOnion.Utility.PemUtility

type KeyCertificateEntry =
Expand Down
2 changes: 1 addition & 1 deletion NOnion/Directory/TorDirectory.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ open NOnion.Crypto
open NOnion.Network
open NOnion.Http
open NOnion.Utility
open NOnion.Utility.FSharpUtil
open NOnion.Utility.AsyncUtil

type RouterType =
| Normal
Expand Down
4 changes: 2 additions & 2 deletions NOnion/Http/TorHttpClient.fs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type TorHttpClient(stream: Stream, host: string) =

do!
ReceiveAll memStream
|> FSharpUtil.WithTimeout Constants.HttpGetResponseTimeout
|> AsyncUtil.WithTimeout Constants.HttpGetResponseTimeout

let httpResponse = memStream.ToArray()

Expand Down Expand Up @@ -135,7 +135,7 @@ type TorHttpClient(stream: Stream, 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 @@ -19,9 +19,9 @@
<Compile Include="RelayIntroduceStatus.fs" />
<Compile Include="Exceptions.fs" />
<Compile Include="HandshakeType.fs" />
<Compile Include="Utility\AsyncUtil.fs" />
<Compile Include="Utility\EmbeddedResourceUtility.fs" />
<Compile Include="Utility\PemUtility.fs" />
<Compile Include="Utility\FSharpUtil.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 @@ -1118,7 +1118,7 @@ and TorCircuit
completionTaskRes
|> UnwrapResult
|> Async.AwaitTask
|> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout
|> AsyncUtil.WithTimeout Constants.CircuitOperationTimeout
}

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

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

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

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

member __.WaitingForRendezvousJoin
Expand Down Expand Up @@ -1236,7 +1236,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 @@ -131,7 +131,7 @@ type TorGuard
do!
client.ConnectAsync(ipEndpoint.Address, ipEndpoint.Port)
|> Async.AwaitTask
|> FSharpUtil.WithTimeout
|> AsyncUtil.WithTimeout
Constants.GuardConnectionTimeout
}

Expand Down Expand Up @@ -159,7 +159,7 @@ type TorGuard
false
)
|> Async.AwaitTask
|> FSharpUtil.WithTimeout Constants.CircuitOperationTimeout
|> AsyncUtil.WithTimeout Constants.CircuitOperationTimeout

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

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

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

member self.ConnectToOutsideAsync(address, port) =
Expand Down
2 changes: 1 addition & 1 deletion NOnion/Services/TorServiceHost.fs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,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 67a8ec0

Please sign in to comment.