Skip to content

Commit

Permalink
Network: return exception when addresses is empty (#50)
Browse files Browse the repository at this point in the history
This fix is necessary for fixing [1].

[1] nblockchain/geewallet#186
  • Loading branch information
parhamsaremi committed Nov 11, 2022
1 parent 59a6127 commit ff391a8
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions NOnion/Network/TorGuard.fs
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,25 @@ type TorGuard private (client: TcpClient, sslStream: SslStream) =
//TODO: Client authentication isn't implemented yet!
do! self.ReceiveExpected<CellAuthChallenge>() |> Async.Ignore
let! netInfo = self.ReceiveExpected<CellNetInfo>()
let maybeOtherAddress = netInfo.MyAddresses |> Seq.tryHead

do!
self.Send
Constants.DefaultCircuitId
{
CellNetInfo.Time =
DateTimeUtils.ToUnixTimestamp DateTime.UtcNow
OtherAddress = netInfo.MyAddresses |> Seq.head
MyAddresses = List.singleton netInfo.OtherAddress
}
match maybeOtherAddress with
| None ->
return
raise
<| GuardConnectionFailedException(
"TorGuard.Handshake: problem in initializing the handshake process"
)
| Some otherAddress ->
do!
self.Send
Constants.DefaultCircuitId
{
CellNetInfo.Time =
DateTimeUtils.ToUnixTimestamp DateTime.UtcNow
OtherAddress = otherAddress
MyAddresses = List.singleton netInfo.OtherAddress
}

TorLogger.Log "TorGuard: finished handshake process"
//TODO: do security checks on handshake data
Expand Down

0 comments on commit ff391a8

Please sign in to comment.