From 5854596aec268a0b74e85a2c68893a8191440421 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Sep 2022 13:48:59 +0800 Subject: [PATCH 01/14] WIP try prepend instead of append --- NOnion/Cells/CellCerts.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NOnion/Cells/CellCerts.fs b/NOnion/Cells/CellCerts.fs index ea2ba8ab..5ede9ef3 100644 --- a/NOnion/Cells/CellCerts.fs +++ b/NOnion/Cells/CellCerts.fs @@ -33,11 +33,11 @@ type CellCerts = } readCertificates - (certificates @ [ certificate ]) + (certificate :: certificates) (remainingCount - 1) let certificatesCount = reader.ReadByte() |> int - let certs = readCertificates List.empty certificatesCount + let certs = readCertificates List.empty certificatesCount |> Seq.rev { Certs = certs From 248d557c87ab54aa4f133dfa5ec363a71bbde37c Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Sep 2022 13:49:26 +0800 Subject: [PATCH 02/14] WIP2 --- NOnion/Cells/CellVersions.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NOnion/Cells/CellVersions.fs b/NOnion/Cells/CellVersions.fs index 99111348..ec72dda2 100644 --- a/NOnion/Cells/CellVersions.fs +++ b/NOnion/Cells/CellVersions.fs @@ -22,9 +22,9 @@ 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 + let versions = readVersions List.empty |> Seq.rev { Versions = versions From fdad8337984b39691cb63e8bc93787cbeed62184 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Sep 2022 13:49:54 +0800 Subject: [PATCH 03/14] WIP3 --- NOnion/Cells/CellNetInfo.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NOnion/Cells/CellNetInfo.fs b/NOnion/Cells/CellNetInfo.fs index 9e72670f..feb3dd6d 100644 --- a/NOnion/Cells/CellNetInfo.fs +++ b/NOnion/Cells/CellNetInfo.fs @@ -32,13 +32,13 @@ type CellNetInfo = addresses else readAddresses - (addresses @ [ readAddress() ]) + (readAddress() :: addresses) (remainingCount - 1uy) let time = ReadBigEndianUInt32 reader let otherAddress = readAddress() let myAddressesCount = reader.ReadByte() - let myAddresses = readAddresses List.Empty myAddressesCount + let myAddresses = readAddresses List.Empty myAddressesCount |> Seq.rev { Time = time From a1f92b44aa644bec552696e3d85015d1135dfcfe Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Sep 2022 13:51:02 +0800 Subject: [PATCH 04/14] WIP5 --- NOnion/Cells/CellAuthChallenge.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 7895b585ef2ac5ee76a9dbadff1f5c93870dddb8 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Mon, 3 Oct 2022 12:34:51 +0800 Subject: [PATCH 05/14] fixup WIP5 --- NOnion/Cells/CellAuthChallenge.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NOnion/Cells/CellAuthChallenge.fs b/NOnion/Cells/CellAuthChallenge.fs index 24fc0659..d02ed149 100644 --- a/NOnion/Cells/CellAuthChallenge.fs +++ b/NOnion/Cells/CellAuthChallenge.fs @@ -25,7 +25,7 @@ type CellAuthChallenge = let challenge = reader.ReadBytes Constants.ChallangeLength let methodsCount = ReadBigEndianUInt16 reader |> int - let methods = readMethod [] methodsCount + let methods = readMethod [] methodsCount |> Seq.rev { Challenge = challenge From d5615013e9c40dc35d917543b19bd537b5922427 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Sep 2022 13:51:47 +0800 Subject: [PATCH 06/14] WIP6 --- NOnion/Cells/Relay/RelayEstablishIntro.fs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NOnion/Cells/Relay/RelayEstablishIntro.fs b/NOnion/Cells/Relay/RelayEstablishIntro.fs index 73c1871f..07ec3e53 100644 --- a/NOnion/Cells/Relay/RelayEstablishIntro.fs +++ b/NOnion/Cells/Relay/RelayEstablishIntro.fs @@ -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 From b3e4f572b3369cde79fd2f3b11c7bb0567f4e76b Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Mon, 3 Oct 2022 15:07:36 +0800 Subject: [PATCH 07/14] fixup WIP6 --- NOnion/Cells/Relay/RelayEstablishIntro.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NOnion/Cells/Relay/RelayEstablishIntro.fs b/NOnion/Cells/Relay/RelayEstablishIntro.fs index 07ec3e53..454ff216 100644 --- a/NOnion/Cells/Relay/RelayEstablishIntro.fs +++ b/NOnion/Cells/Relay/RelayEstablishIntro.fs @@ -136,7 +136,7 @@ type RelayEstablishIntro = ((RelayIntroExtension.FromBytes reader) :: state) (remainingCount - 1uy) - readExtensionsList List.empty extensionCount + readExtensionsList List.empty extensionCount |> Seq.rev let handshakeAuth = reader.ReadBytes authKey.MacLength From ad6ccfb57e9e6a17d79dc53e49bc0b720568b435 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Sep 2022 13:52:30 +0800 Subject: [PATCH 08/14] WIP7 --- NOnion/Cells/Relay/RelayIntroduce.fs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NOnion/Cells/Relay/RelayIntroduce.fs b/NOnion/Cells/Relay/RelayIntroduce.fs index d45f3ada..b5004cfc 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 From d2d6c5b86c815749c52f4443b9cc648afb00e80a Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Sep 2022 13:50:36 +0800 Subject: [PATCH 09/14] WIP4 --- NOnion/Directory/HiddenServiceDescriptorDocument.fs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NOnion/Directory/HiddenServiceDescriptorDocument.fs b/NOnion/Directory/HiddenServiceDescriptorDocument.fs index 1fe9894e..3eae43ab 100644 --- a/NOnion/Directory/HiddenServiceDescriptorDocument.fs +++ b/NOnion/Directory/HiddenServiceDescriptorDocument.fs @@ -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 From 3a6f2ab60234ae64344e7f7265151cae31a62207 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Sep 2022 13:52:49 +0800 Subject: [PATCH 10/14] WIP8 --- NOnion/Cells/Relay/RelayIntroduce.fs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NOnion/Cells/Relay/RelayIntroduce.fs b/NOnion/Cells/Relay/RelayIntroduce.fs index b5004cfc..181b3ff1 100644 --- a/NOnion/Cells/Relay/RelayIntroduce.fs +++ b/NOnion/Cells/Relay/RelayIntroduce.fs @@ -104,8 +104,7 @@ type RelayIntroduce = state else readExtensionsList - (state - @ List.singleton(RelayIntroExtension.FromBytes reader)) + ((RelayIntroExtension.FromBytes reader)::state) (remainingCount - 1uy) readExtensionsList List.empty extensionCount From 31ad5065aceb2583949acef8b518a8e71ba273a8 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Sep 2022 13:53:32 +0800 Subject: [PATCH 11/14] WIP9 --- NOnion/Cells/Relay/RelayIntroduceAck.fs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NOnion/Cells/Relay/RelayIntroduceAck.fs b/NOnion/Cells/Relay/RelayIntroduceAck.fs index 7de51eda..b4d861ce 100644 --- a/NOnion/Cells/Relay/RelayIntroduceAck.fs +++ b/NOnion/Cells/Relay/RelayIntroduceAck.fs @@ -26,8 +26,7 @@ type RelayIntroduceAck = state else readExtensionsList - (state - @ List.singleton(RelayIntroExtension.FromBytes reader)) + (((RelayIntroExtension.FromBytes reader)) :: state) (remainingCount - 1uy) readExtensionsList List.empty extensionCount From fd21bc89e75b6f083997cfbd3ce0300d016d8e11 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Sep 2022 13:54:17 +0800 Subject: [PATCH 12/14] WIP10 --- NOnion/Network/TorCircuit.fs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/NOnion/Network/TorCircuit.fs b/NOnion/Network/TorCircuit.fs index 0b81f7e4..b59bf0cb 100644 --- a/NOnion/Network/TorCircuit.fs +++ b/NOnion/Network/TorCircuit.fs @@ -960,8 +960,6 @@ type TorCircuit circuitState <- Ready( circuitId, - nodes - @ List.singleton { TorCircuitNode.CryptoState = TorCryptoState.FromKdfResult @@ -971,7 +969,7 @@ type TorCircuit Window = TorWindow Constants.DefaultCircuitLevelWindowParams - } + } :: nodes ) tcs.SetResult() From 5fe8c0b6c2596ea5a689e8e79a9192843307ee82 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Sep 2022 13:54:42 +0800 Subject: [PATCH 13/14] WIP11 --- NOnion/Network/TorCircuit.fs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/NOnion/Network/TorCircuit.fs b/NOnion/Network/TorCircuit.fs index b59bf0cb..581530fa 100644 --- a/NOnion/Network/TorCircuit.fs +++ b/NOnion/Network/TorCircuit.fs @@ -785,17 +785,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 From 820c0044333e4b7adf33628ba98f3a20666af5a1 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Sep 2022 13:55:16 +0800 Subject: [PATCH 14/14] WIP12 --- NOnion/Network/TorCircuit.fs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/NOnion/Network/TorCircuit.fs b/NOnion/Network/TorCircuit.fs index 581530fa..fe6b1a2c 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!