diff --git a/Backend/BackendLoop.cs b/Backend/BackendLoop.cs index 2bf2918c..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)}; + 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); @@ -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); @@ -336,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): @@ -348,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 { @@ -365,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"); @@ -378,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) { diff --git a/Backend/CommsTransmitter.cs b/Backend/CommsTransmitter.cs index 6b71fc6c..826301f1 100644 --- a/Backend/CommsTransmitter.cs +++ b/Backend/CommsTransmitter.cs @@ -23,9 +23,13 @@ namespace Swarmops.Backend if (!comm.Resolved) { BotLog.Write(2, "CommsTx", "--resolving"); + ICommsResolver resolver = null; - ICommsResolver resolver = FindResolver(comm); - resolver.Resolve(comm); + if (!String.IsNullOrWhiteSpace(comm.ResolverDataXml)) + { + resolver = FindResolver(comm); + resolver.Resolve(comm); + } comm.Resolved = true; int recipientCount = comm.Recipients.Count; @@ -136,8 +140,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 with envelope type " + resolverEnvelope.GetType().ToString() + " and envelope XML " + comm.ResolverDataXml); + } + // Create the resolver via reflection of the static FromXml method Assembly assembly = typeof(ResolverEnvelope).Assembly; 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-Constructors.cs b/Database/Database-Constructors.cs index 0adf1008..bfdfa988 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;"; } @@ -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 diff --git a/Database/Database.csproj b/Database/Database.csproj index e269c336..87300e1d 100644 --- a/Database/Database.csproj +++ b/Database/Database.csproj @@ -47,17 +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/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/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 " + 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/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/Support/PayloadBase.cs b/Logic/Support/PayloadBase.cs index cc1a0ad4..16a80512 100644 --- a/Logic/Support/PayloadBase.cs +++ b/Logic/Support/PayloadBase.cs @@ -37,6 +37,11 @@ namespace Swarmops.Logic.Support xml = xml.Replace ("�", ""); xml = xml.Replace ("\x00", ""); + if (String.IsNullOrWhiteSpace(xml)) + { + 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)); MemoryStream stream = new MemoryStream(); diff --git a/Logic/app.config b/Logic/app.config index 0e42e3e5..dc66cfe8 100644 --- a/Logic/app.config +++ b/Logic/app.config @@ -1,20 +1,23 @@ - + - - + + - - + + + + + + + + + + - - - - - - + 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 @@ - 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. 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; + } +} diff --git a/Site/web.config b/Site/web.config index 9cef4d95..7b8a20f7 100644 --- a/Site/web.config +++ b/Site/web.config @@ -1,114 +1,110 @@ - - - - + - - - + + + - - + + - + - + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - + - - - - + + + + - + - + - + - - + + - - - - + + + + + + + + + + + + - + - + 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 @@ - + - - + + - - + + + + + + + + + + - +