summary refs log tree commit diff
path: root/MatrixLogFwd/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixLogFwd/Program.cs')
-rw-r--r--MatrixLogFwd/Program.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/MatrixLogFwd/Program.cs b/MatrixLogFwd/Program.cs

index c3765b2..ec90a07 100644 --- a/MatrixLogFwd/Program.cs +++ b/MatrixLogFwd/Program.cs
@@ -2,6 +2,7 @@ using System.Text; using System.Text.Json; +using System.Text.RegularExpressions; using ArcaneLibs; using LibMatrix.Helpers; using LibMatrix.Homeservers; @@ -19,6 +20,7 @@ Console.WriteLine(hs); string mode = "lines"; int chunkSize = 1000; +bool stripIpv4 = false; string? command = null; GenericRoom? room = null; @@ -40,6 +42,9 @@ while (argsEnum.MoveNext()) return; } break; + case "--strip-ipv4": + stripIpv4 = true; + break; case "--chunk-size": argsEnum.MoveNext(); chunkSize = Conversions.ToInteger(argsEnum.Current); @@ -109,6 +114,14 @@ if (mode == "lines") linesInBuffer++; if (linesInBuffer > chunkSize) { + if (stripIpv4) + { + var lineStr = line.ToString(); + lineStr = Ipv4Regex().Replace(lineStr, "[REDACTED_IP]"); + line.Clear(); + line.Append(lineStr); + } + await room.SendMessageEventAsync(new MessageBuilder().WithCodeBlock(line.ToString()).Build()); line.Clear(); linesInBuffer = 0; @@ -142,4 +155,10 @@ else } } +partial class Program +{ + [GeneratedRegex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b")] + private static partial Regex Ipv4Regex(); +} + // await room.LeaveAsync(); \ No newline at end of file