From 5bcbdf72cd2a6bbbd123b3425183f0f82a14fff1 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Wed, 21 Jun 2023 13:49:22 +0200 Subject: [PATCH 01/17] ChecksMode - Defined as the mode describes how birchwood will act when encounterin invalid characters that were provided BY the user TO birchwood ConnectionInfo - Use `ChecksMode.EASY` by default --- source/birchwood/config/conninfo.d | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/birchwood/config/conninfo.d b/source/birchwood/config/conninfo.d index 8960a54..e0e9fff 100644 --- a/source/birchwood/config/conninfo.d +++ b/source/birchwood/config/conninfo.d @@ -7,6 +7,27 @@ import std.socket : SocketException, Address, getAddress; import birchwood.client.exceptions; import std.conv : to, ConvException; +/** + * The mode describes how birchwood will act + * when encounterin invalid characters that + * were provided BY the user TO birchwood + */ +public enum ChecksMode +{ + /** + * In this mode any invalid characters + * will be automatically stripped + */ + EASY, + + /** + * In this mode any invalid characters + * will result in the throwing of a + * `BirchwoodException` + */ + HARDCORE +} + /** * Represents the connection details for a server * to connect to @@ -59,6 +80,8 @@ public shared struct ConnectionInfo /* TODO: before publishing change this bulk size */ + private ChecksMode mode; + /** * Constructs a new ConnectionInfo instance with the * provided details @@ -81,6 +104,9 @@ public shared struct ConnectionInfo // Set the default fakelag to 1 this.fakeLag = 1; + + // Set the validity mode to easy + this.mode = ChecksMode.EASY; } /** From e833cf7a934ba3969ee61611683b67479336a4cb Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Wed, 21 Jun 2023 13:49:36 +0200 Subject: [PATCH 02/17] ConnectionInfo - Added `getMode()` and `setMode(ChecksMode)` --- source/birchwood/config/conninfo.d | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/birchwood/config/conninfo.d b/source/birchwood/config/conninfo.d index e0e9fff..29649cb 100644 --- a/source/birchwood/config/conninfo.d +++ b/source/birchwood/config/conninfo.d @@ -109,6 +109,16 @@ public shared struct ConnectionInfo this.mode = ChecksMode.EASY; } + public ChecksMode getMode() + { + return this.mode; + } + + public void setMode(ChecksMode mode) + { + this.mode = mode; + } + /** * Retrieve the read-dequeue size * From 06efa23c85a2964644fd0b45ad2cdda48c9ee1eb Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Wed, 21 Jun 2023 14:09:32 +0200 Subject: [PATCH 03/17] Messages - Implemented `stripIllegalCharacters(string)` which provided an input string this will strip any illegal characters present within it --- source/birchwood/protocol/messages.d | 38 +++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/source/birchwood/protocol/messages.d b/source/birchwood/protocol/messages.d index 9cfdd8e..e143181 100644 --- a/source/birchwood/protocol/messages.d +++ b/source/birchwood/protocol/messages.d @@ -146,13 +146,49 @@ public final class Message parameterParse(); } - /* TODO: Implement encoder function */ + /** + * Encodes this `Message` into a CRLF delimited + * byte array + * + * If `ChecksMode` is set to `EASY` (default) then + * any invalid characters will be stripped prior + * to encoding + * + * Throws: + * `BirchwoodException` if `ChecksMode` is set to + * `HARDCORE` and invalid characters are present + * Returns: + */ public string encode() { string fullLine = from~" "~command~" "~params; return fullLine; } + /** + * Provided an input string this will strip any illegal + * characters present within it + * + * Params: + * input = the string to filter + * Returns: the filtered string + */ + private static string stripIllegalCharacters(string input) + { + string stripped; + foreach(char character; input) + { + if(character == '\n' || character == '\r') + { + continue; + } + + stripped ~= character; + } + + return stripped; + } + public static Message parseReceivedMessage(string message) { /* TODO: testing */ From 67520c257469c5c1f9f20ed427c1606057454a23 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Wed, 21 Jun 2023 14:22:48 +0200 Subject: [PATCH 04/17] Messages - Implemented `hasIllegalCharacters(string)` which checks whether the provided input string contains any invalid characters - Updated `encode()` to `encode(ChecksMode)` --- source/birchwood/protocol/messages.d | 76 ++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 3 deletions(-) diff --git a/source/birchwood/protocol/messages.d b/source/birchwood/protocol/messages.d index e143181..603708e 100644 --- a/source/birchwood/protocol/messages.d +++ b/source/birchwood/protocol/messages.d @@ -9,6 +9,9 @@ import std.string; import std.conv : to, ConvException; import birchwood.protocol.constants : ReplyType; +import birchwood.client.exceptions; +import birchwood.config.conninfo : ChecksMode; + // TODO: Before release we should remove this import import std.stdio : writeln; @@ -154,17 +157,83 @@ public final class Message * any invalid characters will be stripped prior * to encoding * + * Params: + * mode = the `ChecksMode` to use + * * Throws: * `BirchwoodException` if `ChecksMode` is set to * `HARDCORE` and invalid characters are present - * Returns: + * Returns: the encoded format */ - public string encode() + public string encode(ChecksMode mode) { - string fullLine = from~" "~command~" "~params; + string fullLine; + + /** + * Copy over the values (they might be updated and we + * want to leave the originals intact) + */ + string fFrom = from, fCommand = command, fParams = params; + + /** + * If in `HARDCORE` mode then and illegal characters + * are present, throw an exception + */ + if(mode == ChecksMode.HARDCORE && ( + hic(fFrom) || + hic(fCommand) || + hic(fParams) + )) + { + throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS, "Invalid characters present"); + } + /** + * If in `EASY` mode and illegal characters have + * been found, then fix them up + */ + else + { + // Strip illegal characters from all + fFrom = sic(fFrom); + fCommand = sic(fCommand); + fParams = sic(fParams); + } + + /* Combine */ + fullLine = fFrom~" "~fCommand~" "~fParams; + + + return fullLine; } + // TODO: comemnt + private alias sic = stripIllegalCharacters; + // TODO: comemnt + private alias hic = hasIllegalCharacters; + + /** + * Checks whether the provided input string contains + * any invalid characters + * + * Params: + * input = the string to check + * Returns: `true` if so, `false` otherwise + */ + // TODO: Add unittest + private static bool hasIllegalCharacters(string input) + { + foreach(char character; input) + { + if(character == '\n' || character == '\r') + { + return true; + } + } + + return false; + } + /** * Provided an input string this will strip any illegal * characters present within it @@ -173,6 +242,7 @@ public final class Message * input = the string to filter * Returns: the filtered string */ + // TODO: Add unittest private static string stripIllegalCharacters(string input) { string stripped; From 80a6baf0f9466bacba3adbdc6c5b5777b97c5582 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Wed, 21 Jun 2023 14:23:12 +0200 Subject: [PATCH 05/17] Client - `sendMessage(Message)` now uses the new `Message(this).encode(ChecksMode)` --- source/birchwood/client/client.d | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/birchwood/client/client.d b/source/birchwood/client/client.d index 55e7453..46f2e17 100644 --- a/source/birchwood/client/client.d +++ b/source/birchwood/client/client.d @@ -883,18 +883,22 @@ public class Client : Thread * Sends a message to the server by enqueuing it on * the client-side send queue. * - * A BirchwoodException is thrown if the messages - * final length exceeds 512 bytes + * Any invalid characters will be stripped prior + * to encoding IF `ChecksMode` is set to `EASY` (default) * * Params: * message = the message to send + * Throws: + * A `BirchwoodException` is thrown if the messages + * final length exceeds 512 bytes of if `ChecksMode` + * is set to `HARDCORE` */ private void sendMessage(Message message) { // TODO: Do message splits here /* Encode the message */ - ubyte[] encodedMessage = encodeMessage(message.encode()); + ubyte[] encodedMessage = encodeMessage(message.encode(connInfo.getMode())); /* If the message is 512 bytes or less then send */ if(encodedMessage.length <= 512) From 229a137e34bb896b872dc6425bbfc02bad42cb85 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Wed, 21 Jun 2023 14:39:05 +0200 Subject: [PATCH 06/17] Messages - Added unit test for `hasIllegalCharacters(string)` --- source/birchwood/protocol/messages.d | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/birchwood/protocol/messages.d b/source/birchwood/protocol/messages.d index 603708e..e91226e 100644 --- a/source/birchwood/protocol/messages.d +++ b/source/birchwood/protocol/messages.d @@ -608,4 +608,17 @@ public final class Message { return replyType; } +} + +version(unittest) +{ + // Contains illegal characters + string badString1 = "doos"~"bruh"~"lek"~cast(string)[10]~"ker"; + string badString2 = "doos"~"bruh"~"lek"~cast(string)[13]~"ker"; +} + +unittest +{ + assert(Message.hasIllegalCharacters(badString1) == true); + assert(Message.hasIllegalCharacters(badString2) == true); } \ No newline at end of file From 4655584fa50349009aadc239092f4df17c2040d5 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Wed, 21 Jun 2023 14:39:23 +0200 Subject: [PATCH 07/17] Client - Let unit test for client call `quit()` eventually --- source/birchwood/client/client.d | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/birchwood/client/client.d b/source/birchwood/client/client.d index 46f2e17..a527e28 100644 --- a/source/birchwood/client/client.d +++ b/source/birchwood/client/client.d @@ -1269,12 +1269,12 @@ public class Client : Thread // TODO: Don't forget to re-enable this when done testing! Thread.sleep(dur!("seconds")(4)); - client.joinChannel("#birchwood"); - while(true) - { - Thread.sleep(dur!("seconds")(15)); - } + // client.joinChannel("#birchwood"); + // while(true) + // { + // Thread.sleep(dur!("seconds")(15)); + // } - // client.quit(); + client.quit(); } } \ No newline at end of file From 2a09edd578e7a333fbf7d67e7b04f787f381ad08 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 3 Jul 2023 16:37:08 +0200 Subject: [PATCH 08/17] Messages - Made `hasIllegalCharacters(string)` and `stripIllegalCharacters(string)` public --- source/birchwood/protocol/messages.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/birchwood/protocol/messages.d b/source/birchwood/protocol/messages.d index e91226e..ec73251 100644 --- a/source/birchwood/protocol/messages.d +++ b/source/birchwood/protocol/messages.d @@ -221,7 +221,7 @@ public final class Message * Returns: `true` if so, `false` otherwise */ // TODO: Add unittest - private static bool hasIllegalCharacters(string input) + public static bool hasIllegalCharacters(string input) { foreach(char character; input) { @@ -243,7 +243,7 @@ public final class Message * Returns: the filtered string */ // TODO: Add unittest - private static string stripIllegalCharacters(string input) + public static string stripIllegalCharacters(string input) { string stripped; foreach(char character; input) From 499e53d19d85a2f208779b596b3d5167dd657931 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 3 Jul 2023 16:37:49 +0200 Subject: [PATCH 09/17] Client - Implemented `ref-string`-based `textpass(ref string)` which can validate and strip at the same time - Replaced all calls to `isValidText(string)` with `textPass(ref string)` --- source/birchwood/client/client.d | 75 +++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/source/birchwood/client/client.d b/source/birchwood/client/client.d index 600416f..4e6ef4a 100644 --- a/source/birchwood/client/client.d +++ b/source/birchwood/client/client.d @@ -241,7 +241,7 @@ public class Client : Thread public void nick(string nickname) { /* Ensure no illegal characters in nick name */ - if(isValidText(nickname)) + if(textPass(nickname)) { // TODO: We could investigate this later if we want to be safer ulong maxNickLen = connInfo.getDB!(ulong)("MAXNICKLEN"); @@ -276,7 +276,7 @@ public class Client : Thread public void joinChannel(string channel) { /* Ensure no illegal characters in channel name */ - if(isValidText(channel)) + if(textPass(channel)) { /* Channel name must start with a `#` */ if(channel[0] == '#') @@ -296,6 +296,49 @@ public class Client : Thread } } + + /** + * Provided with a reference to a string + * this will check to see if it contains + * any illegal characters and then if so + * it will strip them if the `ChecksMode` + * is set to `EASY` (and return `true`) + * else it will return `false` if set to + * `HARDCORE` whilst illegal characters + * are present. + * + * Params: + * text = the ref'd `string` + * Returns: `true` if validated, `false` + * otherwise + */ + private bool textPass(ref string text) + { + /* If there are any invalid characters */ + if(Message.hasIllegalCharacters(text)) + { + + import birchwood.config.conninfo : ChecksMode; + if(connInfo.getMode() == ChecksMode.EASY) + { + // TODO: Filter text here + text = Message.stripIllegalCharacters(text); + + return true; + } + else + { + return false; + } + } + /* If there are no invalid characters prewsent */ + else + { + return true; + } + } + + /** * Joins the requested channels * @@ -319,7 +362,7 @@ public class Client : Thread string channelLine = channels[0]; /* Ensure valid characters in first channel */ - if(isValidText(channelLine)) + if(textPass(channelLine)) { //TODO: Add check for # @@ -331,7 +374,7 @@ public class Client : Thread string currentChannel = channels[i]; /* Ensure the character channel is valid */ - if(isValidText(currentChannel)) + if(textPass(currentChannel)) { //TODO: Add check for # @@ -391,7 +434,7 @@ public class Client : Thread string channelLine = channels[0]; /* Ensure valid characters in first channel */ - if(isValidText(channelLine)) + if(textPass(channelLine)) { //TODO: Add check for # @@ -403,7 +446,7 @@ public class Client : Thread string currentChannel = channels[i]; /* Ensure the character channel is valid */ - if(isValidText(currentChannel)) + if(textPass(currentChannel)) { //TODO: Add check for # @@ -450,7 +493,7 @@ public class Client : Thread public void leaveChannel(string channel) { /* Ensure the channel name contains only valid characters */ - if(isValidText(channel)) + if(textPass(channel)) { /* Leave the channel */ Message leaveMessage = new Message("", "PART", channel); @@ -485,12 +528,12 @@ public class Client : Thread else if(recipients.length > 1) { /* Ensure message is valid */ - if(isValidText(message)) + if(textPass(message)) { string recipientLine = recipients[0]; /* Ensure valid characters in first recipient */ - if(isValidText(recipientLine)) + if(textPass(recipientLine)) { /* Append on a trailing `,` */ recipientLine ~= ","; @@ -500,7 +543,7 @@ public class Client : Thread string currentRecipient = recipients[i]; /* Ensure valid characters in the current recipient */ - if(isValidText(currentRecipient)) + if(textPass(currentRecipient)) { if(i == recipients.length-1) { @@ -551,7 +594,7 @@ public class Client : Thread public void directMessage(string message, string recipient) { /* Ensure the message and recipient are valid text */ - if(isValidText(message) && isValidText(recipient)) + if(textPass(message) && textPass(recipient)) { /* Ensure the recipient does NOT start with a # (as that is reserved for channels) */ if(recipient[0] != '#') @@ -592,12 +635,12 @@ public class Client : Thread else if(channels.length > 1) { /* Ensure message is valid */ - if(isValidText(message)) + if(textPass(message)) { string channelLine = channels[0]; /* Ensure valid characters in first channel */ - if(isValidText(channelLine)) + if(textPass(channelLine)) { /* Append on a trailing `,` */ channelLine ~= ","; @@ -607,7 +650,7 @@ public class Client : Thread string currentChannel = channels[i]; /* Ensure valid characters in current channel */ - if(isValidText(currentChannel)) + if(textPass(currentChannel)) { if(i == channels.length-1) { @@ -659,7 +702,7 @@ public class Client : Thread { //TODO: Add check on recipient //TODO: Add emptiness check - if(isValidText(message) && isValidText(channel)) + if(textPass(message) && textPass(channel)) { if(channel[0] == '#') { @@ -917,7 +960,7 @@ public class Client : Thread { // TODO: Implement me properly with all required checks - if(isValidText(username) && isValidText(hostname) && isValidText(servername) && isValidText(realname)) + if(textPass(username) && textPass(hostname) && textPass(servername) && textPass(realname)) { /* User message */ Message userMessage = new Message("", "USER", username~" "~hostname~" "~servername~" "~":"~realname); From 0e6c5fb0139ee1c176ffdc071a1bb419f1fbe3c4 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 3 Jul 2023 16:42:26 +0200 Subject: [PATCH 10/17] Client - Cleaned up and removed now-completed TODOs --- source/birchwood/client/client.d | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/source/birchwood/client/client.d b/source/birchwood/client/client.d index 4e6ef4a..f9f3c44 100644 --- a/source/birchwood/client/client.d +++ b/source/birchwood/client/client.d @@ -317,13 +317,11 @@ public class Client : Thread /* If there are any invalid characters */ if(Message.hasIllegalCharacters(text)) { - import birchwood.config.conninfo : ChecksMode; if(connInfo.getMode() == ChecksMode.EASY) { - // TODO: Filter text here + // Filter the text and update it in-place text = Message.stripIllegalCharacters(text); - return true; } else @@ -338,7 +336,6 @@ public class Client : Thread } } - /** * Joins the requested channels * From 95505af624ff80767fd75b8c2ea965293fb8db76 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 6 Jul 2023 19:11:37 +0200 Subject: [PATCH 11/17] Unit tests (`messages`) - Added a unit test which tests if a message containing bad characters, once stripped, is then valid. - Essentially, tests the stripper. --- source/birchwood/protocol/messages.d | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/birchwood/protocol/messages.d b/source/birchwood/protocol/messages.d index ec73251..d8e21eb 100644 --- a/source/birchwood/protocol/messages.d +++ b/source/birchwood/protocol/messages.d @@ -621,4 +621,16 @@ unittest { assert(Message.hasIllegalCharacters(badString1) == true); assert(Message.hasIllegalCharacters(badString2) == true); +} + +/** + * Tests if a message containing bad characters, + * once stripped, is then valid. + * + * Essentially, tests the stripper. + */ +unittest +{ + assert(Message.hasIllegalCharacters(Message.stripIllegalCharacters(badString1)) == false); + assert(Message.hasIllegalCharacters(Message.stripIllegalCharacters(badString2)) == false); } \ No newline at end of file From 4b1c8270650d69da6197fe0db6fdc4d3ec8c0a56 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 6 Jul 2023 19:12:13 +0200 Subject: [PATCH 12/17] Unit tests (`messages`) - Added description to unit test which tests the detection of illegal characters --- source/birchwood/protocol/messages.d | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/birchwood/protocol/messages.d b/source/birchwood/protocol/messages.d index d8e21eb..ee4f330 100644 --- a/source/birchwood/protocol/messages.d +++ b/source/birchwood/protocol/messages.d @@ -617,6 +617,9 @@ version(unittest) string badString2 = "doos"~"bruh"~"lek"~cast(string)[13]~"ker"; } +/** + * Tests the detection of illegal characters in messages + */ unittest { assert(Message.hasIllegalCharacters(badString1) == true); From 81c6cc701039a69f287f404fb8d99e77feeaa622 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 6 Jul 2023 19:25:28 +0200 Subject: [PATCH 13/17] Unoit tests (`messages`) - Test the `ChecksMode.HARDCORE` and `ChecksMode.EASY` integration of `Message`'s `encode(ChecksMode)` function --- source/birchwood/protocol/messages.d | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/source/birchwood/protocol/messages.d b/source/birchwood/protocol/messages.d index ee4f330..85b351a 100644 --- a/source/birchwood/protocol/messages.d +++ b/source/birchwood/protocol/messages.d @@ -615,6 +615,8 @@ version(unittest) // Contains illegal characters string badString1 = "doos"~"bruh"~"lek"~cast(string)[10]~"ker"; string badString2 = "doos"~"bruh"~"lek"~cast(string)[13]~"ker"; + + import birchwood.config.conninfo : ChecksMode; } /** @@ -636,4 +638,44 @@ unittest { assert(Message.hasIllegalCharacters(Message.stripIllegalCharacters(badString1)) == false); assert(Message.hasIllegalCharacters(Message.stripIllegalCharacters(badString2)) == false); +} + +/** + * Tests the ability, at the `Message`-level, to detect + * illegal characters and automatically strip them when + * in `ChecksMode.EASY` + */ +unittest +{ + Message message = new Message(badString1, "fine", "fine"); + + try + { + string encoded = message.encode(ChecksMode.EASY); + assert(Message.hasIllegalCharacters(encoded) == false); + } + catch(BirchwoodException e) + { + assert(false); + } +} + +/** + * Tests the ability, at the `Message`-level, to detect + * illegal characters and throw an exception when in + * `ChecksMode.HARDCORE` + */ +unittest +{ + Message message = new Message(badString1, "fine", "fine"); + + try + { + message.encode(ChecksMode.EASY); + assert(false); + } + catch(BirchwoodException e) + { + assert(e.getType() == ErrorType.ILLEGAL_CHARACTERS); + } } \ No newline at end of file From 9849fd834b94de27c9092bc21853c1e12346262c Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 6 Jul 2023 19:28:10 +0200 Subject: [PATCH 14/17] Unit tests (`messages`) - Fixed unit test for `ChecksMode.HARDCORE` --- source/birchwood/protocol/messages.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/birchwood/protocol/messages.d b/source/birchwood/protocol/messages.d index 85b351a..3edeb4e 100644 --- a/source/birchwood/protocol/messages.d +++ b/source/birchwood/protocol/messages.d @@ -671,7 +671,7 @@ unittest try { - message.encode(ChecksMode.EASY); + message.encode(ChecksMode.HARCORE); assert(false); } catch(BirchwoodException e) From f2b0c3484275ab5cf99cc5accc00d75f44931bb6 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 6 Jul 2023 19:30:14 +0200 Subject: [PATCH 15/17] Unit tests (`messages`) - Fixed unit test for `ChecksMode.HARDCORE` (typo fix) --- source/birchwood/protocol/messages.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/birchwood/protocol/messages.d b/source/birchwood/protocol/messages.d index 3edeb4e..a289c4f 100644 --- a/source/birchwood/protocol/messages.d +++ b/source/birchwood/protocol/messages.d @@ -671,7 +671,7 @@ unittest try { - message.encode(ChecksMode.HARCORE); + message.encode(ChecksMode.HARDCORE); assert(false); } catch(BirchwoodException e) From 0d38a8439d506cb02b27f3ae5d3ebbf93232e362 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 6 Jul 2023 19:38:07 +0200 Subject: [PATCH 16/17] ConnInfo - Set the default send fake lag to 0 seconds (i.e. no send lag) --- source/birchwood/config/conninfo.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/birchwood/config/conninfo.d b/source/birchwood/config/conninfo.d index 29649cb..25379cb 100644 --- a/source/birchwood/config/conninfo.d +++ b/source/birchwood/config/conninfo.d @@ -102,8 +102,8 @@ public shared struct ConnectionInfo this.bulkReadSize = bulkReadSize; this.quitMessage = quitMessage; - // Set the default fakelag to 1 - this.fakeLag = 1; + // Set the default fakelag to 0 seconds (no send lag) + this.fakeLag = 0; // Set the validity mode to easy this.mode = ChecksMode.EASY; From 84adc020f39be4aabc932ef3509292c013c4b3ab Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 6 Jul 2023 19:41:35 +0200 Subject: [PATCH 17/17] Unit tests (`client`) - Use 1 second fakelag when doing unit tests else my server kicks me (results in error I still need to handle) --- source/birchwood/client/client.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/birchwood/client/client.d b/source/birchwood/client/client.d index f9f3c44..41a40dd 100644 --- a/source/birchwood/client/client.d +++ b/source/birchwood/client/client.d @@ -1303,8 +1303,8 @@ public class Client : Thread //bonobonet: fd08:8441:e254::5 ConnectionInfo connInfo = ConnectionInfo.newConnection("worcester.community.networks.deavmi.assigned.network", 6667, "birchwood", "doggie", "Tristan B. Kildaire"); - // // Set the fakelag to 1 second - // connInfo.setFakeLag(1); + // Set the fakelag to 1 second (server kicks me for spam me thinks if not) + connInfo.setFakeLag(1); // Create a new Client Client client = new Client(connInfo);