Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network: return exception when addresses is empty #50

Merged
merged 1 commit into from
Nov 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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