From 2a33c2828aaa89fcb01e9ffc44f87dbb1a00bd97 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 3 Feb 2021 11:43:04 +0100 Subject: [PATCH 01/26] New attempt to update MySql.Data to 8 --- Backend/app.config | 20 ++++++--- Database/Database.csproj | 1 + Database/app.config | 19 +++++--- Database/packages.config | 12 ++++- DebugConsole/App.config | 16 ++++++- FrontSocket/App.config | 16 ++++++- Interface/app.config | 20 ++++++--- Logic/app.config | 24 ++++++---- Site/web.config | 96 ++++++++++++++++++++++------------------ Tests/app.config | 20 ++++++--- Utility/app.config | 20 ++++++--- 11 files changed, 177 insertions(+), 87 deletions(-) diff --git a/Backend/app.config b/Backend/app.config index d41a13a5..2a4839d4 100644 --- a/Backend/app.config +++ b/Backend/app.config @@ -1,15 +1,23 @@ - + - + - - + + - - + + + + + + + + + + diff --git a/Database/Database.csproj b/Database/Database.csproj index e269c336..03859fa3 100644 --- a/Database/Database.csproj +++ b/Database/Database.csproj @@ -54,6 +54,7 @@ + diff --git a/Database/app.config b/Database/app.config index e4fd3e88..53f17993 100644 --- a/Database/app.config +++ b/Database/app.config @@ -18,9 +18,16 @@ - - - - - - + + + + + + + + + + + + + diff --git a/Database/packages.config b/Database/packages.config index d3e2b595..44b7724f 100644 --- a/Database/packages.config +++ b/Database/packages.config @@ -1,4 +1,14 @@  - + + + + + + + + + + + \ No newline at end of file diff --git a/DebugConsole/App.config b/DebugConsole/App.config index bae5d6d8..4a387c89 100644 --- a/DebugConsole/App.config +++ b/DebugConsole/App.config @@ -1,6 +1,18 @@ - + - + + + + + + + + + + + + + diff --git a/FrontSocket/App.config b/FrontSocket/App.config index bae5d6d8..4a387c89 100644 --- a/FrontSocket/App.config +++ b/FrontSocket/App.config @@ -1,6 +1,18 @@ - + - + + + + + + + + + + + + + diff --git a/Interface/app.config b/Interface/app.config index 09bf17d4..dc66cfe8 100644 --- a/Interface/app.config +++ b/Interface/app.config @@ -1,15 +1,23 @@ - + - - + + - - + + + + + + + + + + - + diff --git a/Logic/app.config b/Logic/app.config index 0e42e3e5..234843ed 100644 --- a/Logic/app.config +++ b/Logic/app.config @@ -1,20 +1,28 @@ - + - - + + - - + + + + + + + + + + - - + + - + diff --git a/Site/web.config b/Site/web.config index 9cef4d95..06ec0ccd 100644 --- a/Site/web.config +++ b/Site/web.config @@ -1,4 +1,4 @@ - + - + - - - + + + - - + + - + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - + - - - - + + + + - + - + - + - - + + - - - - + + + + + + + + + + + + - + - + diff --git a/Tests/app.config b/Tests/app.config index 09bf17d4..dc66cfe8 100644 --- a/Tests/app.config +++ b/Tests/app.config @@ -1,15 +1,23 @@ - + - - + + - - + + + + + + + + + + - + diff --git a/Utility/app.config b/Utility/app.config index 09bf17d4..dc66cfe8 100644 --- a/Utility/app.config +++ b/Utility/app.config @@ -1,15 +1,23 @@ - + - - + + - - + + + + + + + + + + - + From 09f4051f438d812c5d46d6893d20e767970527d2 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 3 Feb 2021 12:05:51 +0100 Subject: [PATCH 02/26] Update README.md --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 73f89943..2d03835b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@ -Swarmops +SOFTWARE BEING REVISED +====================== + +**This repo is undergoing changes to resume development.** The information below is legacy and subject to change as this software clarifies its direction. + + +Swarmops ======== -**This repo is undergoing changes to resume development.** - - **Swarmops is a necessary tool to enable any bitcoin-native or decentralized gamechanger.** Swarmops is an admin system for swarm-type organizations. It's a bureaucracy system for people who thoroughly dislike bureaucracy, so it removes all visibility of it and focuses on the ops aspects. It manages decentralized authority, volunteers, members, activists, budgets, mass communications, expenses, payroll, invoices, and complete financials/bookkeeping. From e9ea52937edbfa0fcb32250db5acaea19da839e7 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 3 Feb 2021 12:14:29 +0100 Subject: [PATCH 03/26] Yet another attempt to get the right MySql.Data version --- Database/Database.csproj | 56 ++++++++++++++++++++++++++++++++++++++-- Logic/Logic.csproj | 13 ++++++++-- Logic/app.config | 7 +---- Logic/packages.config | 1 - 4 files changed, 66 insertions(+), 11 deletions(-) diff --git a/Database/Database.csproj b/Database/Database.csproj index 03859fa3..87300e1d 100644 --- a/Database/Database.csproj +++ b/Database/Database.csproj @@ -47,18 +47,70 @@ false + + ..\packages\BouncyCastle.1.8.5\lib\BouncyCastle.Crypto.dll + True + + + ..\packages\Google.Protobuf.3.11.4\lib\net45\Google.Protobuf.dll + True + + + ..\packages\K4os.Compression.LZ4.1.1.11\lib\net46\K4os.Compression.LZ4.dll + True + + + ..\packages\K4os.Compression.LZ4.Streams.1.1.11\lib\net46\K4os.Compression.LZ4.Streams.dll + True + + + ..\packages\K4os.Hash.xxHash.1.0.6\lib\net46\K4os.Hash.xxHash.dll + True + - - ..\packages\MySql.Data.6.9.9\lib\net45\MySql.Data.dll + + ..\packages\MySql.Data.8.0.23\lib\net452\MySql.Data.dll + True + + + ..\packages\SSH.NET.2020.0.0\lib\net40\Renci.SshNet.dll True + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + True + + + + + + ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll + True + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + True + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + True + + + + ..\packages\MySql.Data.8.0.23\lib\net452\Ubiety.Dns.Core.dll + True + + + ..\packages\MySql.Data.8.0.23\lib\net452\Zstandard.Net.dll + True + diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index 3b10846a..252b863a 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -78,11 +78,12 @@ ..\packages\Markdig.0.10.3\lib\net40\Markdig.dll True + ..\External Libraries\Mono.Posix.dll - - ..\packages\MySql.Data.6.9.9\lib\net45\MySql.Data.dll + + ..\packages\MySql.Data.8.0.23\lib\net452\MySql.Data.dll True @@ -118,10 +119,18 @@ + + ..\packages\MySql.Data.8.0.23\lib\net452\Ubiety.Dns.Core.dll + True + ..\packages\WebSocketSharp.1.0.3-rc11\lib\websocket-sharp.dll True + + ..\packages\MySql.Data.8.0.23\lib\net452\Zstandard.Net.dll + True + diff --git a/Logic/app.config b/Logic/app.config index 234843ed..dc66cfe8 100644 --- a/Logic/app.config +++ b/Logic/app.config @@ -20,9 +20,4 @@ - - - - - - + diff --git a/Logic/packages.config b/Logic/packages.config index 26c0c94d..c9482108 100644 --- a/Logic/packages.config +++ b/Logic/packages.config @@ -6,7 +6,6 @@ - From f043f281d89e1d0ed8830a5e3c81ded05b71c5f1 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 3 Feb 2021 12:29:36 +0100 Subject: [PATCH 04/26] Adding temporary debug code --- Database/Database-ConnectionsCommands.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Database/Database-ConnectionsCommands.cs b/Database/Database-ConnectionsCommands.cs index a85a0ab7..8fac28ac 100644 --- a/Database/Database-ConnectionsCommands.cs +++ b/Database/Database-ConnectionsCommands.cs @@ -15,6 +15,7 @@ namespace Swarmops.Database { DbConnection connection = this.ProviderFactory.CreateConnection(); connection.ConnectionString = this.ConnectionString; + Console.WriteLine("DEBUG: " + this.ConnectionString); // debug return connection; } From 29bb3ef018e711f664eb378c209bb0c79116505e Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 3 Feb 2021 16:20:44 +0100 Subject: [PATCH 05/26] Adding temporary debug code --- Database/Database-BackendServiceOrders.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Database/Database-BackendServiceOrders.cs b/Database/Database-BackendServiceOrders.cs index 4f1aabae..fd5c373c 100644 --- a/Database/Database-BackendServiceOrders.cs +++ b/Database/Database-BackendServiceOrders.cs @@ -78,6 +78,8 @@ namespace Swarmops.Database using (DbConnection connection = GetMySqlDbConnection()) { + Console.WriteLine("DEBUG: " + connection.ConnectionString); // TODO/HACK: Temporary debug code + connection.Open(); string sql = "SELECT " + backendServiceOrderFieldSequence + From a56c669b1c3545cd9df817c94340fad91285e5ac Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 3 Feb 2021 16:22:00 +0100 Subject: [PATCH 06/26] Removing the hacky disabling of SSL/TLS --- Backend/BackendLoop.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Backend/BackendLoop.cs b/Backend/BackendLoop.cs index 2bf2918c..8f980707 100644 --- a/Backend/BackendLoop.cs +++ b/Backend/BackendLoop.cs @@ -223,10 +223,6 @@ namespace Swarmops.Backend BotLog.Write(0, "MainCycle", "Backend STARTING"); - // Disable certificate checking due to Mono not installing with a certificate repository - this is UTTERLY broken - - SupportFunctions.DisableSslCertificateChecks(); // MONO BUG/MISFEATURE: Mono has no root certificates, so can't verify cert - // Tell sysop we're starting OutboundComm.CreateNotification (null, NotificationResource.System_Startup_Backend); From ac0e48ff231ffc636b21ef1d6dfc2c8707aa7417 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 11:00:41 +0100 Subject: [PATCH 07/26] Trying new format connect string --- Database/Database-Constructors.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Database/Database-Constructors.cs b/Database/Database-Constructors.cs index 0adf1008..f6442a99 100644 --- a/Database/Database-Constructors.cs +++ b/Database/Database-Constructors.cs @@ -87,7 +87,7 @@ namespace Swarmops.Database { return "server=" + credentials.ServerSet.ServerPriorities[0].Split (';')[0] + ";database=" + credentials.Database + - ";user=" + credentials.Username + ";password=" + credentials.Password; + ";uid=" + credentials.Username + ";pwd=" + credentials.Password + ";SslMode=Preferred;"; } From 2aad8e6313660753669d2e27a63f84af1f9e362e Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 11:12:07 +0100 Subject: [PATCH 08/26] Adding lots of debug code --- Database/Database-BackendServiceOrders.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Database/Database-BackendServiceOrders.cs b/Database/Database-BackendServiceOrders.cs index fd5c373c..78dfcf87 100644 --- a/Database/Database-BackendServiceOrders.cs +++ b/Database/Database-BackendServiceOrders.cs @@ -78,9 +78,12 @@ namespace Swarmops.Database using (DbConnection connection = GetMySqlDbConnection()) { + Console.WriteLine("--------------------------------------------------------"); Console.WriteLine("DEBUG: " + connection.ConnectionString); // TODO/HACK: Temporary debug code - + Console.WriteLine("--------------------------------------------------------"); + Console.WriteLine("Before Open"); connection.Open(); + Console.WriteLine("Between Open and GetDbCommand"); string sql = "SELECT " + backendServiceOrderFieldSequence + ConstructWhereClause("BackendServiceOrders", conditions) + @@ -90,9 +93,11 @@ namespace Swarmops.Database // this ORDERBY + LIMIT gets the oldest first in a FIFO queue DbCommand command = GetDbCommand(sql, connection); + Console.WriteLine("Between GetDbCommand and ExecuteReader"); using (DbDataReader reader = command.ExecuteReader()) { + Console.WriteLine("Between ExecuteReader and reader.Read"); while (reader.Read()) { result.Add(ReadBackendServiceOrderFromDataReader(reader)); From ff7f4a57f267151c2d90f221976328b320c0fb74 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 11:51:13 +0100 Subject: [PATCH 09/26] Trying new format connect string --- Logic/Support/PayloadBase.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Logic/Support/PayloadBase.cs b/Logic/Support/PayloadBase.cs index cc1a0ad4..0051a31a 100644 --- a/Logic/Support/PayloadBase.cs +++ b/Logic/Support/PayloadBase.cs @@ -37,16 +37,23 @@ namespace Swarmops.Logic.Support xml = xml.Replace ("�", ""); xml = xml.Replace ("\x00", ""); + Console.WriteLine("XML: " + xml); + Console.WriteLine("FromXml before new XmlSerializer()"); + XmlSerializer serializer = new XmlSerializer (typeof (T)); MemoryStream stream = new MemoryStream(); byte[] xmlBytes = Encoding.UTF8.GetBytes (xml); stream.Write (xmlBytes, 0, xmlBytes.Length); + Console.WriteLine("Before Deserialize()"); + stream.Position = 0; T result = (T) serializer.Deserialize (stream); stream.Close(); + Console.WriteLine("Before Returning"); + return result; } } From a85d93f57c84f407302e72b8840e4fa186e790fc Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 12:01:20 +0100 Subject: [PATCH 10/26] Tracking down empty XML error --- Database/Database-BackendServiceOrders.cs | 1 + Database/Database-Constructors.cs | 84 +---------------------- 2 files changed, 2 insertions(+), 83 deletions(-) diff --git a/Database/Database-BackendServiceOrders.cs b/Database/Database-BackendServiceOrders.cs index 78dfcf87..09158929 100644 --- a/Database/Database-BackendServiceOrders.cs +++ b/Database/Database-BackendServiceOrders.cs @@ -103,6 +103,7 @@ namespace Swarmops.Database result.Add(ReadBackendServiceOrderFromDataReader(reader)); } + Console.WriteLine("Returning {0} records", result.Count); return result.ToArray(); } } diff --git a/Database/Database-Constructors.cs b/Database/Database-Constructors.cs index f6442a99..bfdfa988 100644 --- a/Database/Database-Constructors.cs +++ b/Database/Database-Constructors.cs @@ -100,89 +100,7 @@ namespace Swarmops.Database [Obsolete ("Do not use. Use GetDatabaseForAdmin().", true)] public static SwarmDb GetDatabaseAsAdmin() { - string connectionString = string.Empty; - - try - { - if (Path.DirectorySeparatorChar == '/' && HttpContext.Current == null) - { - // We are running under mono in a backend environment - - using (StreamReader reader = new StreamReader (MonoConfigFile.Replace (".config", "-admin.config"))) - { - connectionString = reader.ReadLine(); - - Logging.LogInformation (LogSource.PirateDb, - "SwarmDb initialized for Linux Backend: [" + connectionString + "]"); - } - } - else if (HttpContext.Current != null) - { - // We are running a web application, under Mono (production) or Windows (development) - using ( - StreamReader reader = - new StreamReader ( - HttpContext.Current.Server.MapPath (WebConfigFile.Replace (".config", "-admin.config"))) - ) - { - connectionString = reader.ReadLine(); - - Logging.LogInformation (LogSource.PirateDb, - "SwarmDb initialized for web: [" + connectionString + "]"); - } - } - else - { - // We are running an application, presumably directly from Visual Studio. - // If so, the current working directory is "PirateWeb/30/Console/bin". - using (StreamReader reader = new StreamReader (AppConfigFile.Replace (".config", "-admin.config"))) - { - connectionString = reader.ReadLine(); - - Logging.LogInformation (LogSource.PirateDb, - "SwarmDb initialized for application: [" + connectionString + - "]"); - } - } - } - catch (Exception) - { - Logging.LogWarning (LogSource.PirateDb, "Unable to read Database.Config - defaulting"); - // Ignore if we can't read the Database.config - } - - // To simplify future checks - if (connectionString != null && connectionString.Length == 0) - { - connectionString = null; - } - - // If we still have nothing, and we're running from web, then assume we have a dev environment and use the hostname as db, user, and pass. - if (String.IsNullOrEmpty (connectionString)) - { - if (HttpContext.Current != null) // dummy comment to force build, remove on sight - { - string hostName = HttpContext.Current.Request.Url.Host; - - connectionString = "server=peregrine;database=" + hostName + ";user=" + hostName + - "-admin;password=" + hostName + "-admin"; - // TODO: Replace "peregrine" with "localhost" - } - else - { - throw new InvalidOperationException ( - "No database-as-admin connection string found -- write a connect string into the \"ActivizrAdminConnect\" environment var, or on one line into a file named database-admin.config; see connectionstrings.com for examples"); - // TODO: Replace with custom exception to present config screen - } - } - - // Now write the correct data to the cache, for faster lookup next time - if (_cachedConnectionString == null) - { - _cachedConnectionString = connectionString; - } - - return new SwarmDb (DbProviderFactories.GetFactory (DefaultProviderName), connectionString); + throw new InvalidOperationException(); } } } \ No newline at end of file From 3d955434dd1a049a4bc737e3f0cbbfa6174f4fe6 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 12:18:50 +0100 Subject: [PATCH 11/26] More debug code --- Logic/Support/PayloadBase.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Logic/Support/PayloadBase.cs b/Logic/Support/PayloadBase.cs index 0051a31a..d5a10ce6 100644 --- a/Logic/Support/PayloadBase.cs +++ b/Logic/Support/PayloadBase.cs @@ -40,6 +40,11 @@ namespace Swarmops.Logic.Support Console.WriteLine("XML: " + xml); Console.WriteLine("FromXml before new XmlSerializer()"); + if (xml.Trim().Length < 1) + { + throw new InvalidOperationException("xml is empty"); // Catch a weird empty-XML error and try to get a stack trace + } + XmlSerializer serializer = new XmlSerializer (typeof (T)); MemoryStream stream = new MemoryStream(); From aca58edaa50fd939c4c84f5c1123da9d6dbb9d0f Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 12:21:49 +0100 Subject: [PATCH 12/26] Increased cycle time to 1/2 second --- Backend/BackendLoop.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Backend/BackendLoop.cs b/Backend/BackendLoop.cs index 8f980707..51c9ecb0 100644 --- a/Backend/BackendLoop.cs +++ b/Backend/BackendLoop.cs @@ -332,11 +332,13 @@ namespace Swarmops.Backend // Wait for a maximum of ten seconds (the difference between cycleStartTime and cycleEndTime) + const int cycleTimeMilliseconds = 500; + int iterationCount = 0; DateTime utcNow = DateTime.UtcNow; while (utcNow < cycleEndTime && !exitFlag) { - int signalIndex = 250; + int signalIndex = cycleTimeMilliseconds; // Handle important service orders (those that can't be lost in a random loss // of connection of a socket): @@ -344,14 +346,14 @@ namespace Swarmops.Backend BackendServiceOrders backendOrders = BackendServiceOrders.GetNextBatch(5); backendOrders.Execute(); // takes at most 250ms per BSO reqs - // Block until a SIGINT or SIGTERM signal is generated, or 1/4 second has passed. + // Block until a SIGINT or SIGTERM signal is generated, or 1/2 second has passed. // However, we can't do that in a development environment - it won't have the // Mono.Posix assembly, and won't understand UnixSignals. So people running this in // a dev environment will need to stop it manually. if (!Debugger.IsAttached) { - signalIndex = UnixSignal.WaitAny(killSignals, 250); + signalIndex = UnixSignal.WaitAny(killSignals, cycleTimeMilliseconds); } else { @@ -361,10 +363,10 @@ namespace Swarmops.Backend string.Format(CultureInfo.InvariantCulture, "Waiting for {0:F2} more seconds for cycle end", timeLeft.TotalMilliseconds/1000.0)); - Thread.Sleep(250); + Thread.Sleep(cycleTimeMilliseconds); } - if (signalIndex < 250) + if (signalIndex < cycleTimeMilliseconds) { exitFlag = true; Console.WriteLine("Caught signal " + killSignals[signalIndex].Signum + ", exiting"); @@ -374,7 +376,7 @@ namespace Swarmops.Backend utcNow = DateTime.UtcNow; - // Every second, send an internal heartbeat + // Every four loops, send an internal heartbeat if (iterationCount++%4 == 0) { From 2803de3f7c5a10ef0f92d27c82e2ac675a2af4e5 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 12:31:43 +0100 Subject: [PATCH 13/26] More debug code --- Backend/CommsTransmitter.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Backend/CommsTransmitter.cs b/Backend/CommsTransmitter.cs index 6b71fc6c..573d1e2d 100644 --- a/Backend/CommsTransmitter.cs +++ b/Backend/CommsTransmitter.cs @@ -136,8 +136,18 @@ namespace Swarmops.Backend { // Resolve recipients + if (comm.ResolverDataXml.Trim().Length < 1) + { + throw new InvalidOperationException("comm.ResolverDataXml is empty"); + } + ResolverEnvelope resolverEnvelope = ResolverEnvelope.FromXml(comm.ResolverDataXml); + if (resolverEnvelope.ResolverDataXml.Trim().Length < 1) + { + throw new InvalidOperationException("resolverEnvelope.ResolverDataXml is empty"); + } + // Create the resolver via reflection of the static FromXml method Assembly assembly = typeof(ResolverEnvelope).Assembly; From 4d69f022334d4b6f255e2f7678b6373506bfd012 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 13:17:16 +0100 Subject: [PATCH 14/26] Hopefully the last debug code --- Backend/CommsTransmitter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backend/CommsTransmitter.cs b/Backend/CommsTransmitter.cs index 573d1e2d..4a22df71 100644 --- a/Backend/CommsTransmitter.cs +++ b/Backend/CommsTransmitter.cs @@ -145,7 +145,7 @@ namespace Swarmops.Backend if (resolverEnvelope.ResolverDataXml.Trim().Length < 1) { - throw new InvalidOperationException("resolverEnvelope.ResolverDataXml is empty"); + throw new InvalidOperationException("resolverEnvelope.ResolverDataXml is empty with envelope type " + resolverEnvelope.GetType().ToString() + " and envelope XML " + comm.ResolverDataXml); } // Create the resolver via reflection of the static FromXml method From 3c2be36fe14fcdf75975da5453b62c14fa022ce2 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 14:13:46 +0100 Subject: [PATCH 15/26] Probably fixed root problem --- Backend/CommsTransmitter.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Backend/CommsTransmitter.cs b/Backend/CommsTransmitter.cs index 4a22df71..a732c417 100644 --- a/Backend/CommsTransmitter.cs +++ b/Backend/CommsTransmitter.cs @@ -24,8 +24,11 @@ namespace Swarmops.Backend { BotLog.Write(2, "CommsTx", "--resolving"); - ICommsResolver resolver = FindResolver(comm); - resolver.Resolve(comm); + if (comm.ResolverDataXml.Trim().Length > 0) + { + ICommsResolver resolver = FindResolver(comm); + resolver.Resolve(comm); + } comm.Resolved = true; int recipientCount = comm.Recipients.Count; From d805bda057997af236df48a0e5112257989050ea Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 14:14:43 +0100 Subject: [PATCH 16/26] Even better with correct syntax --- Backend/CommsTransmitter.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Backend/CommsTransmitter.cs b/Backend/CommsTransmitter.cs index a732c417..a3b6db1a 100644 --- a/Backend/CommsTransmitter.cs +++ b/Backend/CommsTransmitter.cs @@ -23,10 +23,11 @@ namespace Swarmops.Backend if (!comm.Resolved) { BotLog.Write(2, "CommsTx", "--resolving"); + ICommsResolver resolver = null; if (comm.ResolverDataXml.Trim().Length > 0) { - ICommsResolver resolver = FindResolver(comm); + resolver = FindResolver(comm); resolver.Resolve(comm); } comm.Resolved = true; From 94fc0e8d6c581b78aa03b389e2e25145c96d5ce2 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 14:16:25 +0100 Subject: [PATCH 17/26] Better catchall method --- Backend/CommsTransmitter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backend/CommsTransmitter.cs b/Backend/CommsTransmitter.cs index a3b6db1a..4c855dda 100644 --- a/Backend/CommsTransmitter.cs +++ b/Backend/CommsTransmitter.cs @@ -25,7 +25,7 @@ namespace Swarmops.Backend BotLog.Write(2, "CommsTx", "--resolving"); ICommsResolver resolver = null; - if (comm.ResolverDataXml.Trim().Length > 0) + if (!String.IsNullOrWhiteSpace(comm.ResolverDataXml) { resolver = FindResolver(comm); resolver.Resolve(comm); From cbb6482f44966c0b070f778b0f2c5a1e2b58f869 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 14:16:41 +0100 Subject: [PATCH 18/26] Even better with correct syntax --- Backend/CommsTransmitter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backend/CommsTransmitter.cs b/Backend/CommsTransmitter.cs index 4c855dda..826301f1 100644 --- a/Backend/CommsTransmitter.cs +++ b/Backend/CommsTransmitter.cs @@ -25,7 +25,7 @@ namespace Swarmops.Backend BotLog.Write(2, "CommsTx", "--resolving"); ICommsResolver resolver = null; - if (!String.IsNullOrWhiteSpace(comm.ResolverDataXml) + if (!String.IsNullOrWhiteSpace(comm.ResolverDataXml)) { resolver = FindResolver(comm); resolver.Resolve(comm); From 36ebbf952bb663fb922357fa8b3201014f24877e Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 16:14:20 +0100 Subject: [PATCH 19/26] Removed one set of debug console.writelines --- Backend/BackendLoop.cs | 2 +- Logic/Support/PayloadBase.cs | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Backend/BackendLoop.cs b/Backend/BackendLoop.cs index 51c9ecb0..e3055b0c 100644 --- a/Backend/BackendLoop.cs +++ b/Backend/BackendLoop.cs @@ -72,7 +72,7 @@ namespace Swarmops.Backend if (!Debugger.IsAttached) { - killSignals = new UnixSignal[] {new UnixSignal (Signum.SIGINT), new UnixSignal (Signum.SIGTERM)}; + killSignals = new UnixSignal[] {new UnixSignal (Signum.SIGINT), new UnixSignal (Signum.SIGTERM), new UnixSignal(Signum.SIGKILL) }; } BotLog.Write (0, "MainCycle", string.Empty); diff --git a/Logic/Support/PayloadBase.cs b/Logic/Support/PayloadBase.cs index d5a10ce6..16a80512 100644 --- a/Logic/Support/PayloadBase.cs +++ b/Logic/Support/PayloadBase.cs @@ -37,12 +37,9 @@ namespace Swarmops.Logic.Support xml = xml.Replace ("�", ""); xml = xml.Replace ("\x00", ""); - Console.WriteLine("XML: " + xml); - Console.WriteLine("FromXml before new XmlSerializer()"); - - if (xml.Trim().Length < 1) + if (String.IsNullOrWhiteSpace(xml)) { - throw new InvalidOperationException("xml is empty"); // Catch a weird empty-XML error and try to get a stack trace + throw new ArgumentException("xml is empty"); // Catch a weird empty-XML error and try to get a stack trace } XmlSerializer serializer = new XmlSerializer (typeof (T)); @@ -51,14 +48,10 @@ namespace Swarmops.Logic.Support byte[] xmlBytes = Encoding.UTF8.GetBytes (xml); stream.Write (xmlBytes, 0, xmlBytes.Length); - Console.WriteLine("Before Deserialize()"); - stream.Position = 0; T result = (T) serializer.Deserialize (stream); stream.Close(); - Console.WriteLine("Before Returning"); - return result; } } From da7f007c00ff1077b3af4eab38806286ed05c8a8 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 16:23:35 +0100 Subject: [PATCH 20/26] Added more termination signals --- Backend/BackendLoop.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backend/BackendLoop.cs b/Backend/BackendLoop.cs index e3055b0c..4f2db683 100644 --- a/Backend/BackendLoop.cs +++ b/Backend/BackendLoop.cs @@ -72,7 +72,7 @@ namespace Swarmops.Backend if (!Debugger.IsAttached) { - killSignals = new UnixSignal[] {new UnixSignal (Signum.SIGINT), new UnixSignal (Signum.SIGTERM), new UnixSignal(Signum.SIGKILL) }; + killSignals = new UnixSignal[] {new UnixSignal (Signum.SIGINT), new UnixSignal (Signum.SIGTERM), new UnixSignal(Signum.SIGKILL), new UnixSignal(Signum.SIGABRT), new UnixSignal(Signum.SIGQUIT), new UnixSignal(Signum.SIGSTOP), new UnixSignal(Signum.SIGPWR) }; } BotLog.Write (0, "MainCycle", string.Empty); From 03a3575b8e09a8d8dff12ecf1593361b340adb5e Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 16:25:07 +0100 Subject: [PATCH 21/26] Let's add the HUP signal too --- Backend/BackendLoop.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backend/BackendLoop.cs b/Backend/BackendLoop.cs index 4f2db683..3a4b1243 100644 --- a/Backend/BackendLoop.cs +++ b/Backend/BackendLoop.cs @@ -72,7 +72,7 @@ namespace Swarmops.Backend if (!Debugger.IsAttached) { - killSignals = new UnixSignal[] {new UnixSignal (Signum.SIGINT), new UnixSignal (Signum.SIGTERM), new UnixSignal(Signum.SIGKILL), new UnixSignal(Signum.SIGABRT), new UnixSignal(Signum.SIGQUIT), new UnixSignal(Signum.SIGSTOP), new UnixSignal(Signum.SIGPWR) }; + killSignals = new UnixSignal[] {new UnixSignal (Signum.SIGINT), new UnixSignal (Signum.SIGTERM), new UnixSignal(Signum.SIGKILL), new UnixSignal(Signum.SIGABRT), new UnixSignal(Signum.SIGQUIT), new UnixSignal(Signum.SIGSTOP), new UnixSignal(Signum.SIGPWR), new UnixSignal(Signum.SIGHUP) }; } BotLog.Write (0, "MainCycle", string.Empty); From a43bdb08744549556cc98802e4834694a6eb08f3 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 19:06:36 +0100 Subject: [PATCH 22/26] Apparently those signals can't be caught --- Backend/BackendLoop.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backend/BackendLoop.cs b/Backend/BackendLoop.cs index 3a4b1243..b4db2c63 100644 --- a/Backend/BackendLoop.cs +++ b/Backend/BackendLoop.cs @@ -72,7 +72,7 @@ namespace Swarmops.Backend if (!Debugger.IsAttached) { - killSignals = new UnixSignal[] {new UnixSignal (Signum.SIGINT), new UnixSignal (Signum.SIGTERM), new UnixSignal(Signum.SIGKILL), new UnixSignal(Signum.SIGABRT), new UnixSignal(Signum.SIGQUIT), new UnixSignal(Signum.SIGSTOP), new UnixSignal(Signum.SIGPWR), new UnixSignal(Signum.SIGHUP) }; + killSignals = new UnixSignal[] {new UnixSignal (Signum.SIGINT), new UnixSignal (Signum.SIGTERM), new UnixSignal(Signum.SIGABRT), new UnixSignal(Signum.SIGQUIT), new UnixSignal(Signum.SIGPWR), new UnixSignal(Signum.SIGHUP) }; } BotLog.Write (0, "MainCycle", string.Empty); From 29e2867db38cff989a24f4971cd1e06419a78275 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 4 Feb 2021 19:18:58 +0100 Subject: [PATCH 23/26] Removing debug code --- Database/Database-BackendServiceOrders.cs | 8 -------- Database/Database-ConnectionsCommands.cs | 1 - 2 files changed, 9 deletions(-) diff --git a/Database/Database-BackendServiceOrders.cs b/Database/Database-BackendServiceOrders.cs index 09158929..4f1aabae 100644 --- a/Database/Database-BackendServiceOrders.cs +++ b/Database/Database-BackendServiceOrders.cs @@ -78,12 +78,7 @@ namespace Swarmops.Database using (DbConnection connection = GetMySqlDbConnection()) { - Console.WriteLine("--------------------------------------------------------"); - Console.WriteLine("DEBUG: " + connection.ConnectionString); // TODO/HACK: Temporary debug code - Console.WriteLine("--------------------------------------------------------"); - Console.WriteLine("Before Open"); connection.Open(); - Console.WriteLine("Between Open and GetDbCommand"); string sql = "SELECT " + backendServiceOrderFieldSequence + ConstructWhereClause("BackendServiceOrders", conditions) + @@ -93,17 +88,14 @@ namespace Swarmops.Database // this ORDERBY + LIMIT gets the oldest first in a FIFO queue DbCommand command = GetDbCommand(sql, connection); - Console.WriteLine("Between GetDbCommand and ExecuteReader"); using (DbDataReader reader = command.ExecuteReader()) { - Console.WriteLine("Between ExecuteReader and reader.Read"); while (reader.Read()) { result.Add(ReadBackendServiceOrderFromDataReader(reader)); } - Console.WriteLine("Returning {0} records", result.Count); return result.ToArray(); } } diff --git a/Database/Database-ConnectionsCommands.cs b/Database/Database-ConnectionsCommands.cs index 8fac28ac..a85a0ab7 100644 --- a/Database/Database-ConnectionsCommands.cs +++ b/Database/Database-ConnectionsCommands.cs @@ -15,7 +15,6 @@ namespace Swarmops.Database { DbConnection connection = this.ProviderFactory.CreateConnection(); connection.ConnectionString = this.ConnectionString; - Console.WriteLine("DEBUG: " + this.ConnectionString); // debug return connection; } From 5c41c31f970d496ee0378b098ef81455c243319d Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Fri, 5 Feb 2021 09:53:31 +0100 Subject: [PATCH 24/26] Changing to same signals on Frontend Socket server --- FrontSocket/FrontendLoop.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/FrontSocket/FrontendLoop.cs b/FrontSocket/FrontendLoop.cs index 319e850e..7f4387af 100644 --- a/FrontSocket/FrontendLoop.cs +++ b/FrontSocket/FrontendLoop.cs @@ -60,7 +60,7 @@ namespace Swarmops.Frontend.Socket if (!Debugger.IsAttached) { - killSignals = new UnixSignal[] {new UnixSignal(Signum.SIGINT), new UnixSignal(Signum.SIGTERM)}; + killSignals = new UnixSignal[] { new UnixSignal(Signum.SIGINT), new UnixSignal(Signum.SIGTERM), new UnixSignal(Signum.SIGABRT), new UnixSignal(Signum.SIGQUIT), new UnixSignal(Signum.SIGPWR), new UnixSignal(Signum.SIGHUP) }; } Console.WriteLine(" * Swarmops Frontend Socket Server starting up."); @@ -162,13 +162,14 @@ namespace Swarmops.Frontend.Socket lastSecond = cycleStartTime.Second; lastMinute = cycleStartTime.Minute; lastHour = cycleStartTime.Hour; + const int cycleIntervalMilliseconds = 500; // Wait for a maximum of ten seconds (the difference between cycleStartTime and cycleEndTime) DateTime utcNow = DateTime.UtcNow; while (utcNow < cycleEndTime && !exitFlag) { - int signalIndex = 250; + int signalIndex = cycleIntervalMilliseconds; // Block until a SIGINT or SIGTERM signal is generated, or 1/4 second has passed. // However, we can't do that in a development environment - it won't have the @@ -177,14 +178,14 @@ namespace Swarmops.Frontend.Socket if (!Debugger.IsAttached) { - signalIndex = UnixSignal.WaitAny(killSignals, 250); + signalIndex = UnixSignal.WaitAny(killSignals, cycleIntervalMilliseconds); } else { - Thread.Sleep(250); + Thread.Sleep(cycleIntervalMilliseconds); } - if (signalIndex < 250) + if (signalIndex < cycleIntervalMilliseconds) { exitFlag = true; Console.WriteLine(" * Swarmops Frontend Socket Server caught signal " + From e23b5ae7ebd6bca42da93a3fb0498e0300a7163e Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 10 Feb 2021 03:33:23 +0100 Subject: [PATCH 25/26] Version changes to config.web for 4.6.1 --- Site/web.config | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/Site/web.config b/Site/web.config index 06ec0ccd..7b8a20f7 100644 --- a/Site/web.config +++ b/Site/web.config @@ -1,38 +1,26 @@  - - - - - + + + - + - + @@ -63,9 +51,9 @@ - + From 3e88f29571c943f89c219f08ada9735aadb2763a Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 13 Feb 2021 12:35:42 +0100 Subject: [PATCH 26/26] Testing sharing violations --- Site/Pages/v5/Admin/Hacks/EmptyPage.aspx | 16 ++++++++++++ Site/Pages/v5/Admin/Hacks/EmptyPage.aspx.cs | 17 ++++++++++++ .../v5/Admin/Hacks/EmptyPage.aspx.designer.cs | 26 +++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 Site/Pages/v5/Admin/Hacks/EmptyPage.aspx create mode 100644 Site/Pages/v5/Admin/Hacks/EmptyPage.aspx.cs create mode 100644 Site/Pages/v5/Admin/Hacks/EmptyPage.aspx.designer.cs diff --git a/Site/Pages/v5/Admin/Hacks/EmptyPage.aspx b/Site/Pages/v5/Admin/Hacks/EmptyPage.aspx new file mode 100644 index 00000000..a2e7839a --- /dev/null +++ b/Site/Pages/v5/Admin/Hacks/EmptyPage.aspx @@ -0,0 +1,16 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EmptyPage.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.Hacks.EmptyPage" %> + + + + + + + + +
+
+ This is an empty page to check for sharing violations. +
+
+ + diff --git a/Site/Pages/v5/Admin/Hacks/EmptyPage.aspx.cs b/Site/Pages/v5/Admin/Hacks/EmptyPage.aspx.cs new file mode 100644 index 00000000..6cf053c6 --- /dev/null +++ b/Site/Pages/v5/Admin/Hacks/EmptyPage.aspx.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Swarmops.Frontend.Pages.v5.Admin.Hacks +{ + public partial class EmptyPage : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/Site/Pages/v5/Admin/Hacks/EmptyPage.aspx.designer.cs b/Site/Pages/v5/Admin/Hacks/EmptyPage.aspx.designer.cs new file mode 100644 index 00000000..bf7205f1 --- /dev/null +++ b/Site/Pages/v5/Admin/Hacks/EmptyPage.aspx.designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swarmops.Frontend.Pages.v5.Admin.Hacks +{ + + + public partial class EmptyPage + { + + /// + /// form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + } +}