From ab8da66f1c86385593e98caa5b22fe9ee1896c59 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Wed, 28 Sep 2022 00:19:48 +0800 Subject: [PATCH] WIP --- NOnion/Cells/CellAuthChallenge.fs | 2 +- NOnion/Cells/CellCerts.fs | 2 +- NOnion/Cells/CellVersions.fs | 2 +- NOnion/Cells/Relay/RelayIntroduce.fs | 6 ++-- NOnion/Cells/Relay/RelayIntroduceAck.fs | 3 +- NOnion/Network/TorCircuit.fs | 40 +++++++++++-------------- NOnion/Utility/Base32Util.fs | 2 +- 7 files changed, 25 insertions(+), 32 deletions(-) diff --git a/NOnion/Cells/CellAuthChallenge.fs b/NOnion/Cells/CellAuthChallenge.fs index a3c54c36..24fc0659 100644 --- a/NOnion/Cells/CellAuthChallenge.fs +++ b/NOnion/Cells/CellAuthChallenge.fs @@ -20,7 +20,7 @@ type CellAuthChallenge = methods else readMethod - (methods @ [ ReadBigEndianUInt16 reader ]) + (ReadBigEndianUInt16 reader :: methods) (remainingCount - 1) let challenge = reader.ReadBytes Constants.ChallangeLength diff --git a/NOnion/Cells/CellCerts.fs b/NOnion/Cells/CellCerts.fs index ea2ba8ab..afd1f674 100644 --- a/NOnion/Cells/CellCerts.fs +++ b/NOnion/Cells/CellCerts.fs @@ -33,7 +33,7 @@ type CellCerts = } readCertificates - (certificates @ [ certificate ]) + (certificate :: certificates) (remainingCount - 1) let certificatesCount = reader.ReadByte() |> int diff --git a/NOnion/Cells/CellVersions.fs b/NOnion/Cells/CellVersions.fs index 99111348..1c32caa3 100644 --- a/NOnion/Cells/CellVersions.fs +++ b/NOnion/Cells/CellVersions.fs @@ -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 diff --git a/NOnion/Cells/Relay/RelayIntroduce.fs b/NOnion/Cells/Relay/RelayIntroduce.fs index d45f3ada..181b3ff1 100644 --- a/NOnion/Cells/Relay/RelayIntroduce.fs +++ b/NOnion/Cells/Relay/RelayIntroduce.fs @@ -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 @@ -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 diff --git a/NOnion/Cells/Relay/RelayIntroduceAck.fs b/NOnion/Cells/Relay/RelayIntroduceAck.fs index 41407d8c..2f4f6e7f 100644 --- a/NOnion/Cells/Relay/RelayIntroduceAck.fs +++ b/NOnion/Cells/Relay/RelayIntroduceAck.fs @@ -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 diff --git a/NOnion/Network/TorCircuit.fs b/NOnion/Network/TorCircuit.fs index 0b81f7e4..234db142 100644 --- a/NOnion/Network/TorCircuit.fs +++ b/NOnion/Network/TorCircuit.fs @@ -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! @@ -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 diff --git a/NOnion/Utility/Base32Util.fs b/NOnion/Utility/Base32Util.fs index 2cb496a7..c9422f89 100644 --- a/NOnion/Utility/Base32Util.fs +++ b/NOnion/Utility/Base32Util.fs @@ -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