Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
knocte committed Sep 30, 2022
1 parent d9d9f43 commit 6223f85
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 41 deletions.
2 changes: 1 addition & 1 deletion NOnion/Cells/CellAuthChallenge.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type CellAuthChallenge =
methods
else
readMethod
(methods @ [ ReadBigEndianUInt16 reader ])
(ReadBigEndianUInt16 reader :: methods)
(remainingCount - 1)

let challenge = reader.ReadBytes Constants.ChallangeLength
Expand Down
2 changes: 1 addition & 1 deletion NOnion/Cells/CellCerts.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type CellCerts =
}

readCertificates
(certificates @ [ certificate ])
(certificate :: certificates)
(remainingCount - 1)

let certificatesCount = reader.ReadByte() |> int
Expand Down
2 changes: 1 addition & 1 deletion NOnion/Cells/CellNetInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type CellNetInfo =
addresses
else
readAddresses
(addresses @ [ readAddress() ])
(readAddress() :: addresses)
(remainingCount - 1uy)

let time = ReadBigEndianUInt32 reader
Expand Down
2 changes: 1 addition & 1 deletion NOnion/Cells/CellVersions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type CellVersions =
if reader.BaseStream.Length = reader.BaseStream.Position then
versions
else
readVersions(versions @ [ ReadBigEndianUInt16 reader ])
readVersions((ReadBigEndianUInt16 reader) :: versions)

let versions = readVersions List.empty

Expand Down
3 changes: 1 addition & 2 deletions NOnion/Cells/Relay/RelayEstablishIntro.fs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ type RelayEstablishIntro =
state
else
readExtensionsList
(state
@ List.singleton(RelayIntroExtension.FromBytes reader))
((RelayIntroExtension.FromBytes reader) :: state)
(remainingCount - 1uy)

readExtensionsList List.empty extensionCount
Expand Down
6 changes: 2 additions & 4 deletions NOnion/Cells/Relay/RelayIntroduce.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ type RelayIntroduceInnerData =
state
else
readExtensionsList
(state
@ List.singleton(RelayIntroExtension.FromBytes reader))
((RelayIntroExtension.FromBytes reader) :: state)
(remainingCount - 1uy)

readExtensionsList List.empty extensionCount
Expand Down Expand Up @@ -105,8 +104,7 @@ type RelayIntroduce =
state
else
readExtensionsList
(state
@ List.singleton(RelayIntroExtension.FromBytes reader))
((RelayIntroExtension.FromBytes reader)::state)
(remainingCount - 1uy)

readExtensionsList List.empty extensionCount
Expand Down
3 changes: 1 addition & 2 deletions NOnion/Cells/Relay/RelayIntroduceAck.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ type RelayIntroduceAck =
state
else
readExtensionsList
(state
@ List.singleton(RelayIntroExtension.FromBytes reader))
(((RelayIntroExtension.FromBytes reader)) :: state)
(remainingCount - 1uy)

readExtensionsList List.empty extensionCount
Expand Down
3 changes: 1 addition & 2 deletions NOnion/Directory/HiddenServiceDescriptorDocument.fs
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ type HiddenServiceDescriptorDocument =
| "introduction-point" ->
{ state with
IntroductionPoints =
state.IntroductionPoints
@ List.singleton(IntroductionPointEntry.Parse lines)
(IntroductionPointEntry.Parse lines) :: state.IntroductionPoints
}
| _ ->
lines.Dequeue() |> ignore<string>
Expand Down
44 changes: 19 additions & 25 deletions NOnion/Network/TorCircuit.fs
Original file line number Diff line number Diff line change
Expand Up @@ -673,17 +673,15 @@ type TorCircuit
circuitState <-
Ready(
circuitId,
nodes
@ List.singleton
{
TorCircuitNode.CryptoState =
TorCryptoState.FromKdfResult
(Kdf.ComputeHSKdf ntorKeySeed)
true
Window =
TorWindow
Constants.DefaultCircuitLevelWindowParams
}
{
TorCircuitNode.CryptoState =
TorCryptoState.FromKdfResult
(Kdf.ComputeHSKdf ntorKeySeed)
true
Window =
TorWindow
Constants.DefaultCircuitLevelWindowParams
} :: nodes
)

do!
Expand Down Expand Up @@ -785,17 +783,15 @@ type TorCircuit
circuitState <-
Ready(
circuitId,
nodes
@ List.singleton
{
TorCircuitNode.CryptoState =
TorCryptoState.FromKdfResult
kdfResult
false
Window =
TorWindow
Constants.DefaultCircuitLevelWindowParams
}
{
TorCircuitNode.CryptoState =
TorCryptoState.FromKdfResult
kdfResult
false
Window =
TorWindow
Constants.DefaultCircuitLevelWindowParams
} :: nodes
)

tcs.SetResult circuitId
Expand Down Expand Up @@ -960,8 +956,6 @@ type TorCircuit
circuitState <-
Ready(
circuitId,
nodes
@ List.singleton
{
TorCircuitNode.CryptoState =
TorCryptoState.FromKdfResult
Expand All @@ -971,7 +965,7 @@ type TorCircuit
Window =
TorWindow
Constants.DefaultCircuitLevelWindowParams
}
} :: nodes
)

tcs.SetResult()
Expand Down
4 changes: 2 additions & 2 deletions NOnion/Utility/Base32Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module Base32Util =
| x0 :: [] -> result @ quintupletToList 1 (x0, 0uy, 0uy, 0uy, 0uy)
| [] -> result

data |> Array.toList |> parse [] |> List.toArray |> System.String.Concat
data |> Array.toList |> parse List.Empty |> List.toArray |> System.String.Concat

/// Decodes a Base32 string to a UTF8 string
let DecodeBase32 text =
Expand Down Expand Up @@ -163,4 +163,4 @@ module Base32Util =
tail
| _ -> result

[ for c in text -> c ] |> parse [] |> List.toArray
[ for c in text -> c ] |> parse List.Empty |> List.toArray

0 comments on commit 6223f85

Please sign in to comment.