From 8b76a76a5bd421f11b52826e0c1851a6e7a1e969 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 24 Oct 2017 12:45:30 -0400 Subject: [PATCH 01/12] Reconverts the project to MSIL. Adds seperate bridge .dll --- DMAPI/server_tools.dm | 7 +- TGCommandLine/TGCommandLine.csproj | 16 ++-- TGControlPanel/TGControlPanel.csproj | 16 ++-- .../DreamDaemonBridge.cs | 3 +- .../Properties/AssemblyInfo.cs | 36 +++++++++ .../TGDreamDaemonBridge.csproj | 60 +++++++++++++++ .../packages.config | 2 +- TGInstallerWrapper/Main.Designer.cs | 1 + TGInstallerWrapper/Main.cs | 62 +++++----------- .../Properties/Resources.Designer.cs | 10 --- TGInstallerWrapper/Properties/Resources.resx | 3 - TGInstallerWrapper/TGInstallerWrapper.csproj | 22 ++++-- TGServerService/ServerInstance/Compiler.cs | 16 +++- TGServerService/ServerInstance/DreamDaemon.cs | 70 +++++++++++++++--- TGServerService/ServerInstance/Repository.cs | 4 +- TGServerService/TGServerService.csproj | 16 ++-- TGServiceInstaller/Product.wxs | 3 + TGServiceInstaller/TGServiceInstaller.wixproj | 8 ++ TGServiceInterface/TGServiceInterface.csproj | 26 +++---- TGStationServer3.sln | 73 ++++++++++++++----- Tools/TGS3Build.ps1 | 8 +- 21 files changed, 310 insertions(+), 152 deletions(-) rename {TGServiceInterface => TGDreamDaemonBridge}/DreamDaemonBridge.cs (94%) create mode 100644 TGDreamDaemonBridge/Properties/AssemblyInfo.cs create mode 100644 TGDreamDaemonBridge/TGDreamDaemonBridge.csproj rename {TGServiceInterface => TGDreamDaemonBridge}/packages.config (82%) diff --git a/DMAPI/server_tools.dm b/DMAPI/server_tools.dm index 88daeb3667..6ca145383c 100644 --- a/DMAPI/server_tools.dm +++ b/DMAPI/server_tools.dm @@ -1,4 +1,5 @@ -// /tg/station 13 server tools API v3.1.0.2 +// /tg/station 13 server tools API +#define SERVICE_API_VERSION_STRING "3.2.0.0" //CONFIGURATION //use this define if you want to do configuration outside of this file @@ -64,8 +65,6 @@ //IMPLEMENTATION -#define SERVICE_API_VERSION_STRING "3.1.0.2" - #define REBOOT_MODE_NORMAL 0 #define REBOOT_MODE_HARD 1 #define REBOOT_MODE_SHUTDOWN 2 @@ -73,7 +72,7 @@ #define SERVICE_WORLD_PARAM "server_service" #define SERVICE_VERSION_PARAM "server_service_version" #define SERVICE_PR_TEST_JSON "prtestjob.json" -#define SERVICE_INTERFACE_DLL "TGServiceInterface.dll" +#define SERVICE_INTERFACE_DLL "TGDreamDaemonBridge.dll" #define SERVICE_INTERFACE_FUNCTION "DDEntryPoint" #define SERVICE_CMD_HARD_REBOOT "hard_reboot" diff --git a/TGCommandLine/TGCommandLine.csproj b/TGCommandLine/TGCommandLine.csproj index 528c4e11fd..5ea566ee82 100644 --- a/TGCommandLine/TGCommandLine.csproj +++ b/TGCommandLine/TGCommandLine.csproj @@ -18,27 +18,27 @@ tgs.ico - + true - bin\x86\Debug\ + bin\Debug\ DEBUG;TRACE full - x86 + AnyCPU prompt MinimumRecommendedRules.ruleset true - - bin\x86\Release\ + + bin\Release\ TRACE + bin\x86\Release\TGCommandLine.xml true + true pdbonly - x86 + AnyCPU prompt MinimumRecommendedRules.ruleset true - true - bin\x86\Release\TGCommandLine.xml diff --git a/TGControlPanel/TGControlPanel.csproj b/TGControlPanel/TGControlPanel.csproj index 87c59e1792..7caa85d9cd 100644 --- a/TGControlPanel/TGControlPanel.csproj +++ b/TGControlPanel/TGControlPanel.csproj @@ -17,27 +17,27 @@ tgs.ico - + true - bin\x86\Debug\ + bin\Debug\ DEBUG;TRACE full - x86 + AnyCPU prompt MinimumRecommendedRules.ruleset true - - bin\x86\Release\ + + bin\Release\ TRACE + bin\x86\Release\TGControlPanel.xml true + true pdbonly - x86 + AnyCPU prompt MinimumRecommendedRules.ruleset true - true - bin\x86\Release\TGControlPanel.xml diff --git a/TGServiceInterface/DreamDaemonBridge.cs b/TGDreamDaemonBridge/DreamDaemonBridge.cs similarity index 94% rename from TGServiceInterface/DreamDaemonBridge.cs rename to TGDreamDaemonBridge/DreamDaemonBridge.cs index a85ae6541b..7f95089c7a 100644 --- a/TGServiceInterface/DreamDaemonBridge.cs +++ b/TGDreamDaemonBridge/DreamDaemonBridge.cs @@ -1,9 +1,10 @@ using RGiesecke.DllExport; using System; using System.Runtime.InteropServices; +using TGServiceInterface; using TGServiceInterface.Components; -namespace TGServiceInterface +namespace TGDreamDaemonBridge { /// /// Holds the proc that DD calls to access diff --git a/TGDreamDaemonBridge/Properties/AssemblyInfo.cs b/TGDreamDaemonBridge/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c011f4041f --- /dev/null +++ b/TGDreamDaemonBridge/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TGDreamDaemonBridge")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TGDreamDaemonBridge")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9a01ef03-8eae-45cb-8b87-4a17bd904557")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TGDreamDaemonBridge/TGDreamDaemonBridge.csproj b/TGDreamDaemonBridge/TGDreamDaemonBridge.csproj new file mode 100644 index 0000000000..2a9a2d3abe --- /dev/null +++ b/TGDreamDaemonBridge/TGDreamDaemonBridge.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {9A01EF03-8EAE-45CB-8B87-4A17BD904557} + Library + Properties + TGDreamDaemonBridge + TGDreamDaemonBridge + v4.6.1 + 512 + TGDreamDaemonBridge + true + x86 + 1 + false + false + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + {ac4e7e8b-f83a-481c-a8b0-8fa4e8ae59ab} + TGServiceInterface + + + + + ..\packages\UnmanagedExports.1.2.7\lib\net\RGiesecke.DllExport.Metadata.dll + False + + + + + + + + + \ No newline at end of file diff --git a/TGServiceInterface/packages.config b/TGDreamDaemonBridge/packages.config similarity index 82% rename from TGServiceInterface/packages.config rename to TGDreamDaemonBridge/packages.config index bfd9f475da..2cc6157f53 100644 --- a/TGServiceInterface/packages.config +++ b/TGDreamDaemonBridge/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/TGInstallerWrapper/Main.Designer.cs b/TGInstallerWrapper/Main.Designer.cs index 88b82a06a3..885db27148 100644 --- a/TGInstallerWrapper/Main.Designer.cs +++ b/TGInstallerWrapper/Main.Designer.cs @@ -20,6 +20,7 @@ namespace TGInstallerWrapper if (disposing && (components != null)) { components.Dispose(); + CleanTempDir(); } base.Dispose(disposing); } diff --git a/TGInstallerWrapper/Main.cs b/TGInstallerWrapper/Main.cs index 79d8ac3081..436e6bdbf8 100644 --- a/TGInstallerWrapper/Main.cs +++ b/TGInstallerWrapper/Main.cs @@ -3,10 +3,11 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Reflection; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; +using TGServiceInterface; +using TGServiceInterface.Components; namespace TGInstallerWrapper { @@ -14,21 +15,6 @@ namespace TGInstallerWrapper { const string DefaultInstallDir = "TG Station Server"; //keep this in sync with the msi installer - //reflection shit, make sure it matches - const string InterfaceDLL = "TGServiceInterface.dll"; - const string InterfaceNamespace = "TGServiceInterface"; - const string InterfaceComponentsNamespace = InterfaceNamespace + ".Components"; - const string InterfaceClass = InterfaceNamespace + ".Server"; - const string InterfaceServiceInterface = InterfaceComponentsNamespace + ".ITGSService"; //fuck this typo - const string InterfaceClassVerifyConnection = "VerifyConnection"; - const string InterfaceClassGetComponent = "GetComponent"; - const string InterfaceServiceInterfaceVersion = "Version"; - const string InterfaceServiceInterfacePrepareForUpdate = "PrepareForUpdate"; - - Assembly InterfaceAssembly; - Type Server, ITGSService; - MethodInfo VerifyConnection, GetComponentITGSService, Version, PrepareForUpdate; - string tempDir; bool installing = false; bool cancelled = false; @@ -41,7 +27,6 @@ namespace TGInstallerWrapper { InitializeComponent(); SetupTempDir(); - LoadInterfaceFromReflection(); CheckForExistingVersion(); PathTextBox.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), DefaultInstallDir); } @@ -54,7 +39,7 @@ namespace TGInstallerWrapper if (File.Exists(tempDir)) File.Delete(tempDir); else if (Directory.Exists(tempDir)) - Directory.Delete(tempDir); + Directory.Delete(tempDir, true); } catch { } if (File.Exists(tempDir) || Directory.Exists(tempDir)) @@ -62,39 +47,30 @@ namespace TGInstallerWrapper tempDir = Path.GetTempFileName(); File.Delete(tempDir); //we want a dir not a file } - Directory.CreateDirectory(tempDir); - } - - void LoadInterfaceFromReflection() - { - //so this is where we expect to find the interface dll try { - var tmppath = Path.Combine(tempDir, InterfaceDLL); - File.WriteAllBytes(tmppath, Properties.Resources.TGServiceInterface); - InterfaceAssembly = Assembly.LoadFrom(tmppath); //we can't link to it, or load the bytes directly because the thing will complain about mixing the DLLExport code and IL code - Server = InterfaceAssembly.GetType(InterfaceClass); - ITGSService = InterfaceAssembly.GetType(InterfaceServiceInterface); - VerifyConnection = Server.GetMethod(InterfaceClassVerifyConnection); - GetComponentITGSService = Server.GetMethod(InterfaceClassGetComponent).MakeGenericMethod(ITGSService); - Version = ITGSService.GetMethod(InterfaceServiceInterfaceVersion); - PrepareForUpdate = ITGSService.GetMethod(InterfaceServiceInterfacePrepareForUpdate); + Directory.CreateDirectory(tempDir); } catch { - InterfaceAssembly = null; - VersionLabel.Text = "Error: (Could not load interface dll)"; - return; + tempDir = null; } } + void CleanTempDir() { + if(tempDir != null) + try + { + Directory.Delete(tempDir, true); + } + catch { } + } + void CheckForExistingVersion() { - if (InterfaceAssembly == null) - return; - var verifiedConnection = VerifyConnection.Invoke(null, null) == null; + var verifiedConnection = Interface.VerifyConnection() == null; try { - VersionLabel.Text = (string)Version.Invoke(GetComponentITGSService.Invoke(null, null), null); + VersionLabel.Text = Interface.GetComponent().Version(); } catch { @@ -110,12 +86,10 @@ namespace TGInstallerWrapper bool TellServiceWereComingForThem() { - if (InterfaceAssembly == null) - return ConfirmDangerousUpgrade(); - var connectionVerified = VerifyConnection.Invoke(null, null) == null; + var connectionVerified = Interface.VerifyConnection() == null; try { - PrepareForUpdate.Invoke(GetComponentITGSService.Invoke(null, null), null); + Interface.GetComponent().PrepareForUpdate(); Thread.Sleep(3000); //chat messages return true; } diff --git a/TGInstallerWrapper/Properties/Resources.Designer.cs b/TGInstallerWrapper/Properties/Resources.Designer.cs index e3858daec9..cd95f1bb4f 100644 --- a/TGInstallerWrapper/Properties/Resources.Designer.cs +++ b/TGInstallerWrapper/Properties/Resources.Designer.cs @@ -79,15 +79,5 @@ namespace TGInstallerWrapper.Properties { return ((byte[])(obj)); } } - - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] TGServiceInterface { - get { - object obj = ResourceManager.GetObject("TGServiceInterface", resourceCulture); - return ((byte[])(obj)); - } - } } } diff --git a/TGInstallerWrapper/Properties/Resources.resx b/TGInstallerWrapper/Properties/Resources.resx index daa2b3cb0c..223c76093a 100644 --- a/TGInstallerWrapper/Properties/Resources.resx +++ b/TGInstallerWrapper/Properties/Resources.resx @@ -124,7 +124,4 @@ ..\..\TGServiceInstaller\bin\Release\TGServiceInstaller.msi;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\..\TGServiceInterface\bin\x86\Release\TGServiceInterface.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - \ No newline at end of file diff --git a/TGInstallerWrapper/TGInstallerWrapper.csproj b/TGInstallerWrapper/TGInstallerWrapper.csproj index 7b9fa7692a..ffee3114b1 100644 --- a/TGInstallerWrapper/TGInstallerWrapper.csproj +++ b/TGInstallerWrapper/TGInstallerWrapper.csproj @@ -20,27 +20,27 @@ tgs.ico - + true - bin\x86\Debug\ + bin\Debug\ DEBUG;TRACE full - x86 + AnyCPU prompt MinimumRecommendedRules.ruleset true - - bin\x86\Release\ + + bin\Release\ TRACE + bin\x86\Release\TG Station Server Installer.xml true + true pdbonly - x86 + AnyCPU prompt MinimumRecommendedRules.ruleset true - true - bin\x86\Release\TG Station Server Installer.xml @@ -85,6 +85,12 @@ + + + {ac4e7e8b-f83a-481c-a8b0-8fa4e8ae59ab} + TGServiceInterface + + diff --git a/TGServerService/ServerInstance/Compiler.cs b/TGServerService/ServerInstance/Compiler.cs index ff5e781a4f..ad630f1b3b 100644 --- a/TGServerService/ServerInstance/Compiler.cs +++ b/TGServerService/ServerInstance/Compiler.cs @@ -37,8 +37,6 @@ namespace TGServerService const string BDirTest = GameDirB + LiveFile; const string LiveDirTest = GameDirLive + LiveFile; - const string InterfaceDLLName = "TGServiceInterface.dll"; - object CompilerLock = new object(); CompilerStatus compilerCurrentStatus; string lastCompilerError; @@ -142,9 +140,15 @@ namespace TGServerService if (Directory.Exists(Path.Combine(GameDirA, InterfaceDLLName))) Directory.Delete(Path.Combine(GameDirA, InterfaceDLLName)); + if (Directory.Exists(Path.Combine(GameDirA, BridgeDLLName))) + Directory.Delete(Path.Combine(GameDirA, BridgeDLLName)); + if (Directory.Exists(Path.Combine(GameDirB, InterfaceDLLName))) Directory.Delete(Path.Combine(GameDirB, InterfaceDLLName)); + if (Directory.Exists(Path.Combine(GameDirB, BridgeDLLName))) + Directory.Delete(Path.Combine(GameDirB, BridgeDLLName)); + if (Directory.Exists(GameDirLive)) Directory.Delete(GameDirLive); } @@ -204,6 +208,9 @@ namespace TGServerService CreateSymlink(Path.Combine(GameDirA, InterfaceDLLName), InterfaceDLLName); CreateSymlink(Path.Combine(GameDirB, InterfaceDLLName), InterfaceDLLName); + CreateSymlink(Path.Combine(GameDirA, BridgeDLLName), BridgeDLLName); + CreateSymlink(Path.Combine(GameDirB, BridgeDLLName), BridgeDLLName); + CreateSymlink(GameDirLive, GameDirA); lock (CompilerLock) @@ -355,7 +362,7 @@ namespace TGServerService resurrectee = GetStagingDir(); var Config = GetCachedRepoConfig(); - var deleteExcludeList = new List { InterfaceDLLName }; + var deleteExcludeList = new List { InterfaceDLLName, BridgeDLLName }; deleteExcludeList.AddRange(Config.StaticDirectoryPaths); deleteExcludeList.AddRange(Config.DLLPaths); Program.DeleteDirectory(resurrectee, true, deleteExcludeList); @@ -379,6 +386,9 @@ namespace TGServerService if (!File.Exists(Path.Combine(resurrectee, InterfaceDLLName))) CreateSymlink(Path.Combine(resurrectee, InterfaceDLLName), InterfaceDLLName); + if (!File.Exists(Path.Combine(resurrectee, BridgeDLLName))) + CreateSymlink(Path.Combine(resurrectee, BridgeDLLName), BridgeDLLName); + deleteExcludeList.Add(".git"); Program.CopyDirectory(RepoPath, resurrectee, deleteExcludeList); CurrentSha = GetHead(false, out string error); diff --git a/TGServerService/ServerInstance/DreamDaemon.cs b/TGServerService/ServerInstance/DreamDaemon.cs index 36a4e9c703..ae8e8362d9 100644 --- a/TGServerService/ServerInstance/DreamDaemon.cs +++ b/TGServerService/ServerInstance/DreamDaemon.cs @@ -38,6 +38,23 @@ namespace TGServerService /// const int DDBadStartTime = 10; + /// + /// The file name of the .dll that contains the + /// + static readonly string InterfaceDLLName = Path.GetFileName(Assembly.GetAssembly(typeof(Interface)).Location); + /// + /// The file name of the .dll that contains the bridge class + /// + const string BridgeDLLName = "TGDreamDaemonBridge.dll"; + /// + /// The namespace that contains the bridge class. Used for reflection + /// + const string DreamDaemonBridgeNamespace = "TGDreamDaemonBridge"; + /// + /// The bridge class. Used for reflection + /// + const string DreamDaemonBridgeType = DreamDaemonBridgeNamespace + ".DreamDaemonBridge"; + /// /// The DreamDaemon process /// @@ -512,27 +529,56 @@ namespace TGServerService } /// - /// Copies from the program directory to the the directory + /// Copies and from the program directory to the the directory /// - /// If , overwrites the 's current interface .dll if it exists - void UpdateInterfaceDll(bool overwrite) + /// If , overwrites the 's current interface .dll, if it exists + void UpdateInterfaceDlls(bool overwrite) { - var FileExists = File.Exists(InterfaceDLLName); + var InterfacePath = Assembly.GetAssembly(typeof(Interface)).Location; + UpdateInterfaceDLL(InterfacePath, InterfaceDLLName, overwrite); + + var BridgePath = Path.Combine(Path.GetDirectoryName(InterfacePath), BridgeDLLName); +#if DEBUG + //We could be debugging from the project directory + if(!File.Exists(BridgePath)) + //A little hackish debug mode doctoring never hurt anyone + BridgePath = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(InterfacePath)))), "TGDreamDaemonBridge/bin/Debug", BridgeDLLName); +#endif + try + { + //Use reflection to ensure these are the droids we're looking for + var bridge = Assembly.ReflectionOnlyLoadFrom(BridgePath); + bridge.GetType(DreamDaemonBridgeType); + UpdateInterfaceDLL(BridgePath, BridgeDLLName, overwrite); + } + catch (Exception e) { + Service.WriteError(String.Format("Unable to locate {0}! Error: {1}", BridgeDLLName, e.ToString()), EventID.InterfaceDLLUpdateFail); + } + } + + /// + /// Copies the .dll at to in the , optionally with an paremeter, retrying once if the file is locked + /// + /// The path of the source .dll + /// The path of the destination .dll + /// If , overwrites the 's current .dll, if it exists + void UpdateInterfaceDLL(string path, string targetPath, bool overwrite) + { + var FileExists = File.Exists(targetPath); if (FileExists && !overwrite) return; //Copy the interface dll to the static dir - var InterfacePath = Assembly.GetAssembly(typeof(DreamDaemonBridge)).Location; try { if (FileExists) { - var Old = File.ReadAllBytes(InterfaceDLLName); - var New = File.ReadAllBytes(InterfacePath); + var Old = File.ReadAllBytes(path); + var New = File.ReadAllBytes(targetPath); if (Old.SequenceEqual(New)) return; //no need } - File.Copy(InterfacePath, InterfaceDLLName, overwrite); - Service.WriteInfo("Updated interface DLL", TGServerService.EventID.InterfaceDLLUpdated); + File.Copy(path, targetPath, overwrite); + Service.WriteInfo("Updated interface DLL " + targetPath, TGServerService.EventID.InterfaceDLLUpdated); } catch { @@ -540,12 +586,12 @@ namespace TGServerService { //ok the things being stupid and hasn't released the dll yet, try ONCE more Thread.Sleep(1000); - File.Copy(InterfacePath, InterfaceDLLName, overwrite); + File.Copy(path, targetPath, overwrite); } catch (Exception e) { //intentionally using the fi - Service.WriteError("Failed to update interface DLL! Error: " + e.ToString(), TGServerService.EventID.InterfaceDLLUpdateFail); + Service.WriteError(String.Format("Failed to update interface DLL {0}! Error: {1}", targetPath, e.ToString()), TGServerService.EventID.InterfaceDLLUpdateFail); } } } @@ -571,7 +617,7 @@ namespace TGServerService GenCommsKey(); StartingSecurity = (DreamDaemonSecurity)Config.ServerSecurity; Proc.StartInfo.Arguments = String.Format("{0} -port {1} {5}-close -verbose -params \"server_service={3}&server_service_version={4}\" -{2} -public", DMB, Config.ServerPort, SecurityWord(), serviceCommsKey, Version(), Config.Webclient ? "-webclient " : ""); - UpdateInterfaceDll(true); + UpdateInterfaceDlls(true); lock (topicLock) { GameAPIVersion = null; //needs updating diff --git a/TGServerService/ServerInstance/Repository.cs b/TGServerService/ServerInstance/Repository.cs index b58f9c31b1..1cd2bc13f6 100644 --- a/TGServerService/ServerInstance/Repository.cs +++ b/TGServerService/ServerInstance/Repository.cs @@ -96,7 +96,7 @@ namespace TGServerService { Directory.CreateDirectory(RepoKeyDir); if(Exists()) - UpdateInterfaceDll(false); + UpdateInterfaceDlls(false); if(LoadRepo() == null) DisableGarbageCollectionNoLock(); //start the autoupdate timer @@ -336,7 +336,7 @@ namespace TGServerService void InitialConfigureRepository() { Directory.CreateDirectory(StaticDirs); - UpdateInterfaceDll(false); + UpdateInterfaceDlls(false); UpdateTGS3Json(); var Config = GetCachedRepoConfig(); //RepoBusy is set if we're here foreach(var I in Config.StaticDirectoryPaths) diff --git a/TGServerService/TGServerService.csproj b/TGServerService/TGServerService.csproj index 73d9428b8f..bc546d9423 100644 --- a/TGServerService/TGServerService.csproj +++ b/TGServerService/TGServerService.csproj @@ -19,27 +19,27 @@ tgs.ico - + true - bin\x86\Debug\ + bin\Debug\ DEBUG;TRACE full - x86 + AnyCPU prompt MinimumRecommendedRules.ruleset true - - bin\x86\Release\ + + bin\Release\ TRACE + bin\x86\Release\TGServerService.xml true + true pdbonly - x86 + AnyCPU prompt MinimumRecommendedRules.ruleset true - true - bin\x86\Release\TGServerService.xml diff --git a/TGServiceInstaller/Product.wxs b/TGServiceInstaller/Product.wxs index a43f25374b..0a917fac53 100644 --- a/TGServiceInstaller/Product.wxs +++ b/TGServiceInstaller/Product.wxs @@ -119,6 +119,9 @@ + + + diff --git a/TGServiceInstaller/TGServiceInstaller.wixproj b/TGServiceInstaller/TGServiceInstaller.wixproj index fd47e7c7f5..dbe628e0fd 100644 --- a/TGServiceInstaller/TGServiceInstaller.wixproj +++ b/TGServiceInstaller/TGServiceInstaller.wixproj @@ -40,6 +40,14 @@ Binaries;Content;Satellites INSTALLFOLDER + + TGDreamDaemonBridge + {9a01ef03-8eae-45cb-8b87-4a17bd904557} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + TGServerService {f32eda25-0855-411c-af5e-f0d042917e2d} diff --git a/TGServiceInterface/TGServiceInterface.csproj b/TGServiceInterface/TGServiceInterface.csproj index ea546a5b8a..016005f981 100644 --- a/TGServiceInterface/TGServiceInterface.csproj +++ b/TGServiceInterface/TGServiceInterface.csproj @@ -15,31 +15,28 @@ tgs.ico - + true - bin\x86\Debug\ + bin\Debug\ DEBUG;TRACE full - x86 + AnyCPU prompt MinimumRecommendedRules.ruleset - - bin\x86\Release\ + + bin\Release\ TRACE + bin\x86\Release\TGServiceInterface.xml true + true pdbonly - x86 + AnyCPU prompt MinimumRecommendedRules.ruleset - true - bin\x86\Release\TGServiceInterface.xml + false - - ..\packages\UnmanagedExports.1.2.7\lib\net\RGiesecke.DllExport.Metadata.dll - False - @@ -56,7 +53,6 @@ - @@ -71,9 +67,5 @@ - - - - \ No newline at end of file diff --git a/TGStationServer3.sln b/TGStationServer3.sln index 346a49d8d1..4127b6d655 100644 --- a/TGStationServer3.sln +++ b/TGStationServer3.sln @@ -86,34 +86,69 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{287B .github\CONTRIBUTING.md = .github\CONTRIBUTING.md EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TGDreamDaemonBridge", "TGDreamDaemonBridge\TGDreamDaemonBridge.csproj", "{9A01EF03-8EAE-45CB-8B87-4A17BD904557}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F32EDA25-0855-411C-AF5E-F0D042917E2D}.Debug|x86.ActiveCfg = Debug|x86 - {F32EDA25-0855-411C-AF5E-F0D042917E2D}.Debug|x86.Build.0 = Debug|x86 - {F32EDA25-0855-411C-AF5E-F0D042917E2D}.Release|x86.ActiveCfg = Release|x86 - {F32EDA25-0855-411C-AF5E-F0D042917E2D}.Release|x86.Build.0 = Release|x86 - {394E7643-6B8C-416F-AB18-95AC12648CDC}.Debug|x86.ActiveCfg = Debug|x86 - {394E7643-6B8C-416F-AB18-95AC12648CDC}.Debug|x86.Build.0 = Debug|x86 - {394E7643-6B8C-416F-AB18-95AC12648CDC}.Release|x86.ActiveCfg = Release|x86 - {394E7643-6B8C-416F-AB18-95AC12648CDC}.Release|x86.Build.0 = Release|x86 - {89191F69-B18E-4B59-B72E-E12F9B6811A0}.Debug|x86.ActiveCfg = Debug|x86 - {89191F69-B18E-4B59-B72E-E12F9B6811A0}.Debug|x86.Build.0 = Debug|x86 - {89191F69-B18E-4B59-B72E-E12F9B6811A0}.Release|x86.ActiveCfg = Release|x86 - {89191F69-B18E-4B59-B72E-E12F9B6811A0}.Release|x86.Build.0 = Release|x86 - {AC4E7E8B-F83A-481C-A8B0-8FA4E8AE59AB}.Debug|x86.ActiveCfg = Debug|x86 - {AC4E7E8B-F83A-481C-A8B0-8FA4E8AE59AB}.Debug|x86.Build.0 = Debug|x86 - {AC4E7E8B-F83A-481C-A8B0-8FA4E8AE59AB}.Release|x86.ActiveCfg = Release|x86 - {AC4E7E8B-F83A-481C-A8B0-8FA4E8AE59AB}.Release|x86.Build.0 = Release|x86 + {F32EDA25-0855-411C-AF5E-F0D042917E2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F32EDA25-0855-411C-AF5E-F0D042917E2D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F32EDA25-0855-411C-AF5E-F0D042917E2D}.Debug|x86.ActiveCfg = Debug|Any CPU + {F32EDA25-0855-411C-AF5E-F0D042917E2D}.Debug|x86.Build.0 = Debug|Any CPU + {F32EDA25-0855-411C-AF5E-F0D042917E2D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F32EDA25-0855-411C-AF5E-F0D042917E2D}.Release|Any CPU.Build.0 = Release|Any CPU + {F32EDA25-0855-411C-AF5E-F0D042917E2D}.Release|x86.ActiveCfg = Release|Any CPU + {F32EDA25-0855-411C-AF5E-F0D042917E2D}.Release|x86.Build.0 = Release|Any CPU + {394E7643-6B8C-416F-AB18-95AC12648CDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {394E7643-6B8C-416F-AB18-95AC12648CDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {394E7643-6B8C-416F-AB18-95AC12648CDC}.Debug|x86.ActiveCfg = Debug|Any CPU + {394E7643-6B8C-416F-AB18-95AC12648CDC}.Debug|x86.Build.0 = Debug|Any CPU + {394E7643-6B8C-416F-AB18-95AC12648CDC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {394E7643-6B8C-416F-AB18-95AC12648CDC}.Release|Any CPU.Build.0 = Release|Any CPU + {394E7643-6B8C-416F-AB18-95AC12648CDC}.Release|x86.ActiveCfg = Release|Any CPU + {394E7643-6B8C-416F-AB18-95AC12648CDC}.Release|x86.Build.0 = Release|Any CPU + {89191F69-B18E-4B59-B72E-E12F9B6811A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {89191F69-B18E-4B59-B72E-E12F9B6811A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {89191F69-B18E-4B59-B72E-E12F9B6811A0}.Debug|x86.ActiveCfg = Debug|Any CPU + {89191F69-B18E-4B59-B72E-E12F9B6811A0}.Debug|x86.Build.0 = Debug|Any CPU + {89191F69-B18E-4B59-B72E-E12F9B6811A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {89191F69-B18E-4B59-B72E-E12F9B6811A0}.Release|Any CPU.Build.0 = Release|Any CPU + {89191F69-B18E-4B59-B72E-E12F9B6811A0}.Release|x86.ActiveCfg = Release|Any CPU + {89191F69-B18E-4B59-B72E-E12F9B6811A0}.Release|x86.Build.0 = Release|Any CPU + {AC4E7E8B-F83A-481C-A8B0-8FA4E8AE59AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC4E7E8B-F83A-481C-A8B0-8FA4E8AE59AB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC4E7E8B-F83A-481C-A8B0-8FA4E8AE59AB}.Debug|x86.ActiveCfg = Debug|Any CPU + {AC4E7E8B-F83A-481C-A8B0-8FA4E8AE59AB}.Debug|x86.Build.0 = Debug|Any CPU + {AC4E7E8B-F83A-481C-A8B0-8FA4E8AE59AB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC4E7E8B-F83A-481C-A8B0-8FA4E8AE59AB}.Release|Any CPU.Build.0 = Release|Any CPU + {AC4E7E8B-F83A-481C-A8B0-8FA4E8AE59AB}.Release|x86.ActiveCfg = Release|Any CPU + {AC4E7E8B-F83A-481C-A8B0-8FA4E8AE59AB}.Release|x86.Build.0 = Release|Any CPU + {154435F6-0890-42D4-9AEC-B743D4FBC1CB}.Debug|Any CPU.ActiveCfg = Debug|x86 {154435F6-0890-42D4-9AEC-B743D4FBC1CB}.Debug|x86.ActiveCfg = Debug|x86 + {154435F6-0890-42D4-9AEC-B743D4FBC1CB}.Release|Any CPU.ActiveCfg = Release|x86 + {154435F6-0890-42D4-9AEC-B743D4FBC1CB}.Release|Any CPU.Build.0 = Release|x86 {154435F6-0890-42D4-9AEC-B743D4FBC1CB}.Release|x86.ActiveCfg = Release|x86 {154435F6-0890-42D4-9AEC-B743D4FBC1CB}.Release|x86.Build.0 = Release|x86 - {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Debug|x86.ActiveCfg = Debug|x86 - {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Release|x86.ActiveCfg = Release|x86 - {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Release|x86.Build.0 = Release|x86 + {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Debug|x86.ActiveCfg = Debug|Any CPU + {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Debug|x86.Build.0 = Debug|Any CPU + {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Release|Any CPU.Build.0 = Release|Any CPU + {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Release|x86.ActiveCfg = Release|Any CPU + {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Release|x86.Build.0 = Release|Any CPU + {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Debug|x86.ActiveCfg = Debug|Any CPU + {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Debug|x86.Build.0 = Debug|Any CPU + {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Release|Any CPU.Build.0 = Release|Any CPU + {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Release|x86.ActiveCfg = Release|Any CPU + {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Tools/TGS3Build.ps1 b/Tools/TGS3Build.ps1 index 9b845ad567..911789d56e 100644 --- a/Tools/TGS3Build.ps1 +++ b/Tools/TGS3Build.ps1 @@ -1,5 +1,5 @@ $bf = $Env:APPVEYOR_BUILD_FOLDER -$src = "$bf\TGInstallerWrapper\bin\x86\Release" +$src = "$bf\TGInstallerWrapper\bin\Release" $version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$src\TG Station Server Installer.exe").FileVersion $doxdir = "C:\tgsdox" @@ -43,9 +43,9 @@ $destination_md5sha = "$bf\MD5-SHA1-Server-v$version.txt" $src2 = "$bf\ClientApps" [system.io.directory]::CreateDirectory($src2) -Copy-Item "$bf\TGCommandLine\bin\x86\Release\TGCommandLine.exe" "$src2\TGCommandLine.exe" -Copy-Item "$bf\TGControlPanel\bin\x86\Release\TGControlPanel.exe" "$src2\TGControlPanel.exe" -Copy-Item "$bf\TGServiceInterface\bin\x86\Release\TGServiceInterface.dll" "$src2\TGServiceInterface.dll" +Copy-Item "$bf\TGCommandLine\bin\Release\TGCommandLine.exe" "$src2\TGCommandLine.exe" +Copy-Item "$bf\TGControlPanel\bin\Release\TGControlPanel.exe" "$src2\TGControlPanel.exe" +Copy-Item "$bf\TGServiceInterface\bin\Release\TGServiceInterface.dll" "$src2\TGServiceInterface.dll" $dest2 = "$bf\TGS3-Client-v$version.zip" From 4380457728761eda7b92f66c6633d83de0775481 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 2 Nov 2017 10:15:55 -0400 Subject: [PATCH 02/12] Add IsRemoteConnection --- TGServiceInterface/Interface.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/TGServiceInterface/Interface.cs b/TGServiceInterface/Interface.cs index 4c87303b6c..34d4460ff7 100644 --- a/TGServiceInterface/Interface.cs +++ b/TGServiceInterface/Interface.cs @@ -128,6 +128,11 @@ namespace TGServiceInterface HTTPSPassword = password; } + /// + /// Checks if the is setup for a remote connection + /// + public bool IsRemoteConnection { get { return HTTPSURL != null; } } + /// /// Closes all s stored in and clears it /// @@ -230,7 +235,7 @@ namespace TGServiceInterface if (!ValidInterfaces.Contains(ToT)) throw new Exception("Invalid type!"); var InterfaceName = typeof(T).Name; - if (HTTPSURL == null) + if (!IsRemoteConnection) { var res2 = new ChannelFactory( new NetNamedPipeBinding { SendTimeout = new TimeSpan(0, 0, 30), MaxReceivedMessageSize = TransferLimitLocal }, new EndpointAddress(String.Format("net.pipe://localhost/{0}/{1}", MasterInterfaceName, InterfaceName))); //10 megs From 1ac3f213f8ec6efb844d7a033c73c715512c2427 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 2 Nov 2017 10:27:10 -0400 Subject: [PATCH 03/12] Changes the CP title when connected to a remote server --- TGControlPanel/ControlPanel.cs | 6 ++++++ TGServiceInterface/Interface.cs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/TGControlPanel/ControlPanel.cs b/TGControlPanel/ControlPanel.cs index e4ce2968b6..a7a8b9fc4c 100644 --- a/TGControlPanel/ControlPanel.cs +++ b/TGControlPanel/ControlPanel.cs @@ -2,6 +2,7 @@ using System.Drawing; using System.Windows.Forms; using TGServiceInterface; +using TGServiceInterface.Components; namespace TGControlPanel { @@ -23,6 +24,11 @@ namespace TGControlPanel { Interface = I; InitializeComponent(); + if (Interface.IsRemoteConnection) + { + var splits = Interface.GetComponent().Version().Split(' '); + Text = String.Format("TGS {0}: {1}:{2}", splits[splits.Length - 1], Interface.HTTPSURL, Interface.HTTPSPort); + } if (Interface.VersionMismatch(out string error) && MessageBox.Show(error, "Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { Close(); diff --git a/TGServiceInterface/Interface.cs b/TGServiceInterface/Interface.cs index 34d4460ff7..b07c8e6e6e 100644 --- a/TGServiceInterface/Interface.cs +++ b/TGServiceInterface/Interface.cs @@ -40,12 +40,12 @@ namespace TGServiceInterface /// /// If this is set, we will try and connect to an HTTPS server running at this address /// - readonly string HTTPSURL; + public readonly string HTTPSURL; /// /// The port used by the service /// - readonly ushort HTTPSPort; + public readonly ushort HTTPSPort; /// /// Username for remote operations From 9cfd1541111c1ede8628f2a070ebc3eb97d54e7c Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 2 Nov 2017 10:56:54 -0400 Subject: [PATCH 04/12] Fix build script --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 11c3ad0381..d1352663fe 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -30,7 +30,7 @@ build: after_build: - ps: .\Tools\TGS3Build.ps1 - ps: if($env:APPVEYOR_REPO_COMMIT_MESSAGE -match "\[TGSDeploy\]"){$env:TGSDeploy = "Do it."} - - ps: $env:TGSVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$env:APPVEYOR_BUILD_FOLDER/TGServerService/bin/x86/Release/TGServerService.exe").FileVersion + - ps: $env:TGSVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$env:APPVEYOR_BUILD_FOLDER/TGServerService/bin/Release/TGServerService.exe").FileVersion deploy: - provider: GitHub release: "tgstation-server-v$(TGSVersion)" From 29b0ecaf94d1146b103ca6cbe58957c713bc101e Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 2 Nov 2017 11:11:41 -0400 Subject: [PATCH 05/12] Caches larges CI packages --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 11c3ad0381..692509bc82 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,6 +18,8 @@ artifacts: name: MD5SHA1Client cache: - packages -> **\packages.config + - C:\ProgramData\chocolatey\bin -> appveyor.yml + - C:\ProgramData\chocolatey\lib -> appveyor.yml install: - choco install fciv doxygen.portable graphviz.portable before_build: From 2a1aad531439fd8996a36d201684da46ae7acf18 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 2 Nov 2017 12:35:25 -0400 Subject: [PATCH 06/12] Just weave the dll and make everyones life easier --- TGDreamDaemonBridge/DreamDaemonBridge.cs | 3 +- .../TGDreamDaemonBridge.csproj | 30 +++++-- TGDreamDaemonBridge/packages.config | 2 + TGServerService/EventID.cs | 4 +- TGServerService/ServerInstance/Compiler.cs | 33 +++---- TGServerService/ServerInstance/DreamDaemon.cs | 88 +++++++------------ TGServerService/ServerInstance/Interop.cs | 13 +++ TGServerService/ServerInstance/Repository.cs | 4 +- 8 files changed, 87 insertions(+), 90 deletions(-) diff --git a/TGDreamDaemonBridge/DreamDaemonBridge.cs b/TGDreamDaemonBridge/DreamDaemonBridge.cs index f02aa1e3ef..c95f3e38d0 100644 --- a/TGDreamDaemonBridge/DreamDaemonBridge.cs +++ b/TGDreamDaemonBridge/DreamDaemonBridge.cs @@ -9,7 +9,7 @@ namespace TGDreamDaemonBridge /// /// Holds the proc that DD calls to access /// - public sealed class DreamDaemonBridge + public static class DreamDaemonBridge { /// /// The proc that DD calls to access @@ -20,6 +20,7 @@ namespace TGDreamDaemonBridge [DllExport("DDEntryPoint", CallingConvention = CallingConvention.Cdecl)] public static int DDEntryPoint(int argc, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr, SizeParamIndex = 0)]string[] args) { + System.Diagnostics.Debugger.Launch(); try { using (var I = new Interface()) diff --git a/TGDreamDaemonBridge/TGDreamDaemonBridge.csproj b/TGDreamDaemonBridge/TGDreamDaemonBridge.csproj index 2a9a2d3abe..1fb1121cfe 100644 --- a/TGDreamDaemonBridge/TGDreamDaemonBridge.csproj +++ b/TGDreamDaemonBridge/TGDreamDaemonBridge.csproj @@ -17,6 +17,8 @@ 1 false false + + true @@ -40,12 +42,10 @@ - - {ac4e7e8b-f83a-481c-a8b0-8fa4e8ae59ab} - TGServiceInterface - - - + + ..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll + False + ..\packages\UnmanagedExports.1.2.7\lib\net\RGiesecke.DllExport.Metadata.dll False @@ -55,6 +55,24 @@ + + + {ac4e7e8b-f83a-481c-a8b0-8fa4e8ae59ab} + TGServiceInterface + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/TGDreamDaemonBridge/packages.config b/TGDreamDaemonBridge/packages.config index 6250dba03c..8a9cbe435c 100644 --- a/TGDreamDaemonBridge/packages.config +++ b/TGDreamDaemonBridge/packages.config @@ -1,4 +1,6 @@  + + \ No newline at end of file diff --git a/TGServerService/EventID.cs b/TGServerService/EventID.cs index 02824101ab..93bdff846d 100644 --- a/TGServerService/EventID.cs +++ b/TGServerService/EventID.cs @@ -245,11 +245,11 @@ namespace TGServerService /// /// Info: When the dll is updated for the /// - InterfaceDLLUpdated = 5800, + BridgeDLLUpdated = 5800, /// /// Error: An error occurred while updating the dll for the /// - InterfaceDLLUpdateFail = 5900, + BridgeDLLUpdateFail = 5900, //YO THERE'S SPACE FOR 1 MORE ID HERE, USE IT!!! diff --git a/TGServerService/ServerInstance/Compiler.cs b/TGServerService/ServerInstance/Compiler.cs index 9fe9af2e22..cd67d9ff45 100644 --- a/TGServerService/ServerInstance/Compiler.cs +++ b/TGServerService/ServerInstance/Compiler.cs @@ -38,7 +38,7 @@ namespace TGServerService object CompilerLock = new object(); CompilerStatus compilerCurrentStatus; string lastCompilerError; - + Thread CompilerThread; bool compilationCancellationRequestation = false; bool canCancelCompilation = false; @@ -49,7 +49,7 @@ namespace TGServerService //deletes leftovers and checks current status void InitCompiler() { - if(File.Exists(LiveDirTest)) + if (File.Exists(LiveDirTest)) File.Delete(LiveDirTest); compilerCurrentStatus = IsInitialized(); } @@ -82,7 +82,7 @@ namespace TGServerService if (CompilerThread == null || !CompilerThread.IsAlive) return; CompilerThread.Abort(); //this will safely kill dm - InitCompiler(); //also cleanup + InitCompiler(); //also cleanup } } @@ -98,7 +98,7 @@ namespace TGServerService { return compilerCurrentStatus == CompilerStatus.Uninitialized || compilerCurrentStatus == CompilerStatus.Initialized; } - + /// public bool Initialize() { @@ -117,7 +117,7 @@ namespace TGServerService //what is says on the tin CompilerStatus IsInitialized() { - if (File.Exists(Path.Combine(GameDirLive, InterfaceDLLName))) //its a good tell, jim + if (File.Exists(Path.Combine(GameDirLive, BridgeDLLName))) //its a good tell, jim return CompilerStatus.Initialized; return CompilerStatus.Uninitialized; } @@ -135,15 +135,9 @@ namespace TGServerService //we need to remove symlinks before we can recursively delete void CleanGameFolder() { - if (Directory.Exists(Path.Combine(GameDirA, InterfaceDLLName))) - Directory.Delete(Path.Combine(GameDirA, InterfaceDLLName)); - if (Directory.Exists(Path.Combine(GameDirA, BridgeDLLName))) Directory.Delete(Path.Combine(GameDirA, BridgeDLLName)); - if (Directory.Exists(Path.Combine(GameDirB, InterfaceDLLName))) - Directory.Delete(Path.Combine(GameDirB, InterfaceDLLName)); - if (Directory.Exists(Path.Combine(GameDirB, BridgeDLLName))) Directory.Delete(Path.Combine(GameDirB, BridgeDLLName)); @@ -196,21 +190,19 @@ namespace TGServerService var Config = GetCachedRepoConfig(); - if (Config != null) { + if (Config != null) + { foreach (var I in Config.StaticDirectoryPaths) CreateSymlink(Path.Combine(GameDirA, I), Path.Combine(StaticDirs, I)); foreach (var I in Config.DLLPaths) CreateSymlink(Path.Combine(GameDirA, I), Path.Combine(StaticDirs, I)); } - CreateSymlink(Path.Combine(GameDirA, InterfaceDLLName), InterfaceDLLName); - CreateSymlink(Path.Combine(GameDirB, InterfaceDLLName), InterfaceDLLName); - CreateSymlink(Path.Combine(GameDirA, BridgeDLLName), BridgeDLLName); CreateSymlink(Path.Combine(GameDirB, BridgeDLLName), BridgeDLLName); CreateSymlink(GameDirLive, GameDirA); - + lock (CompilerLock) { compilerCurrentStatus = CompilerStatus.Compiling; @@ -238,7 +230,7 @@ namespace TGServerService return; } CompileImpl(); - } + } //Returns the A or B dir in which the game is NOT running string GetStagingDir() @@ -277,7 +269,7 @@ namespace TGServerService { File.Delete(rsclock); } - catch //held open by byond + catch //held open by byond { //This means there is a staged update waiting to be applied, we have to unstage it before we can work Directory.Delete(GameDirLive); @@ -360,7 +352,7 @@ namespace TGServerService resurrectee = GetStagingDir(); var Config = GetCachedRepoConfig(); - var deleteExcludeList = new List { InterfaceDLLName, BridgeDLLName }; + var deleteExcludeList = new List { BridgeDLLName }; deleteExcludeList.AddRange(Config.StaticDirectoryPaths); deleteExcludeList.AddRange(Config.DLLPaths); Program.DeleteDirectory(resurrectee, true, deleteExcludeList); @@ -381,9 +373,6 @@ namespace TGServerService CreateSymlink(the_path, Path.Combine(StaticDirs, I)); } - if (!File.Exists(Path.Combine(resurrectee, InterfaceDLLName))) - CreateSymlink(Path.Combine(resurrectee, InterfaceDLLName), InterfaceDLLName); - if (!File.Exists(Path.Combine(resurrectee, BridgeDLLName))) CreateSymlink(Path.Combine(resurrectee, BridgeDLLName), BridgeDLLName); diff --git a/TGServerService/ServerInstance/DreamDaemon.cs b/TGServerService/ServerInstance/DreamDaemon.cs index a8e7b845d5..72943470c1 100644 --- a/TGServerService/ServerInstance/DreamDaemon.cs +++ b/TGServerService/ServerInstance/DreamDaemon.cs @@ -38,23 +38,6 @@ namespace TGServerService /// const int DDBadStartTime = 10; - /// - /// The file name of the .dll that contains the - /// - static readonly string InterfaceDLLName = Path.GetFileName(Assembly.GetAssembly(typeof(Interface)).Location); - /// - /// The file name of the .dll that contains the bridge class - /// - const string BridgeDLLName = "TGDreamDaemonBridge.dll"; - /// - /// The namespace that contains the bridge class. Used for reflection - /// - const string DreamDaemonBridgeNamespace = "TGDreamDaemonBridge"; - /// - /// The bridge class. Used for reflection - /// - const string DreamDaemonBridgeType = DreamDaemonBridgeNamespace + ".DreamDaemonBridge"; - /// /// The DreamDaemon process /// @@ -168,7 +151,7 @@ namespace TGServerService //autostart the server if (Properties.Settings.Default.DDAutoStart) //break this off so we don't hold up starting the service - ThreadPool.QueueUserWorkItem( _ => { Start(); }); + ThreadPool.QueueUserWorkItem(_ => { Start(); }); } /// @@ -195,7 +178,7 @@ namespace TGServerService else if (Detach) Properties.Settings.Default.ReattachToDD = false; Stop(); - if(pcpu != null) + if (pcpu != null) pcpu.Dispose(); if (RenameLog) try @@ -283,7 +266,7 @@ namespace TGServerService { if (DaemonStatus() == DreamDaemonStatus.Offline) return Start(); - lock(restartLock) + lock (restartLock) { if (RestartInProgress) return "Restart already in progress"; @@ -292,8 +275,8 @@ namespace TGServerService SendMessage("DD: Hard restart triggered", MessageType.WatchdogInfo); Stop(); var res = Start(); - if(res != null) - lock(restartLock) + if (res != null) + lock (restartLock) { RestartInProgress = false; } @@ -512,7 +495,7 @@ namespace TGServerService } return StartImpl(false); } - + /// /// Translate the configured level into a byond command line param /// @@ -535,56 +518,46 @@ namespace TGServerService } /// - /// Copies and from the program directory to the the directory + /// Copies from the program directory to the the directory /// - /// If , overwrites the 's current interface .dll, if it exists - void UpdateInterfaceDlls(bool overwrite) + /// If , overwrites the 's current interface .dll if it exists + void UpdateInterfaceDll(bool overwrite) { - var InterfacePath = Assembly.GetAssembly(typeof(Interface)).Location; - UpdateInterfaceDLL(InterfacePath, InterfaceDLLName, overwrite); + var FileExists = File.Exists(BridgeDLLName); + if (FileExists && !overwrite) + return; + //Copy the interface dll to the static dir + var InterfacePath = Assembly.GetAssembly(typeof(Interface)).Location; var BridgePath = Path.Combine(Path.GetDirectoryName(InterfacePath), BridgeDLLName); #if DEBUG //We could be debugging from the project directory - if(!File.Exists(BridgePath)) + if (!File.Exists(BridgePath)) //A little hackish debug mode doctoring never hurt anyone BridgePath = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(InterfacePath)))), "TGDreamDaemonBridge/bin/Debug", BridgeDLLName); #endif try { //Use reflection to ensure these are the droids we're looking for - var bridge = Assembly.ReflectionOnlyLoadFrom(BridgePath); - bridge.GetType(DreamDaemonBridgeType); - UpdateInterfaceDLL(BridgePath, BridgeDLLName, overwrite); + Assembly.ReflectionOnlyLoadFrom(BridgePath).GetType(DreamDaemonBridgeType, true); } - catch (Exception e) { - Service.WriteError(String.Format("Unable to locate {0}! Error: {1}", BridgeDLLName, e.ToString()), EventID.InterfaceDLLUpdateFail); - } - } - - /// - /// Copies the .dll at to in the , optionally with an paremeter, retrying once if the file is locked - /// - /// The path of the source .dll - /// The path of the destination .dll - /// If , overwrites the 's current .dll, if it exists - void UpdateInterfaceDLL(string path, string targetPath, bool overwrite) - { - var FileExists = File.Exists(targetPath); - if (FileExists && !overwrite) + catch (Exception e) + { + Service.WriteError(String.Format("Unable to locate {0}! Error: {1}", BridgeDLLName, e.ToString()), EventID.BridgeDLLUpdateFail); return; - //Copy the interface dll to the static dir + } + try { if (FileExists) { - var Old = File.ReadAllBytes(path); - var New = File.ReadAllBytes(targetPath); + var Old = File.ReadAllBytes(BridgeDLLName); + var New = File.ReadAllBytes(BridgePath); if (Old.SequenceEqual(New)) return; //no need } - File.Copy(path, targetPath, overwrite); - Service.WriteInfo("Updated interface DLL", EventID.InterfaceDLLUpdated); + File.Copy(InterfacePath, BridgeDLLName, overwrite); + Service.WriteInfo("Updated interface DLL", EventID.BridgeDLLUpdated); } catch { @@ -592,18 +565,18 @@ namespace TGServerService { //ok the things being stupid and hasn't released the dll yet, try ONCE more Thread.Sleep(1000); - File.Copy(path, targetPath, overwrite); + File.Copy(InterfacePath, BridgeDLLName, overwrite); } catch (Exception e) { //intentionally using the fi - Service.WriteError(String.Format("Failed to update interface DLL {0}! Error: {1}", targetPath, e.ToString()), EventID.InterfaceDLLUpdateFail); + Service.WriteError("Failed to update interface DLL! Error: " + e.ToString(), EventID.BridgeDLLUpdateFail); } } } /// - /// Clears the current , calls with a parameter, and attempts to start the DreamDaemon + /// Clears the current , calls with a parameter, and attempts to start the DreamDaemon /// /// If , sets to a new pointing to and starts it /// on success, error message on failure @@ -623,7 +596,7 @@ namespace TGServerService GenCommsKey(); StartingSecurity = (DreamDaemonSecurity)Config.ServerSecurity; Proc.StartInfo.Arguments = String.Format("{0} -port {1} {5}-close -verbose -params \"server_service={3}&server_service_version={4}\" -{2} -public", DMB, Config.ServerPort, SecurityWord(), serviceCommsKey, Version(), Config.Webclient ? "-webclient " : ""); - UpdateInterfaceDlls(true); + UpdateInterfaceDll(true); lock (topicLock) { GameAPIVersion = null; //needs updating @@ -763,7 +736,8 @@ namespace TGServerService public void SetWebclient(bool on) { var Config = Properties.Settings.Default; - lock (watchdogLock) { + lock (watchdogLock) + { var diff = on != Config.Webclient; if (diff) { diff --git a/TGServerService/ServerInstance/Interop.cs b/TGServerService/ServerInstance/Interop.cs index 62bd60b49c..1cd07178be 100644 --- a/TGServerService/ServerInstance/Interop.cs +++ b/TGServerService/ServerInstance/Interop.cs @@ -42,6 +42,19 @@ namespace TGServerService const string CCPAdminOnly = "admin_only"; const string CCPRequiredParameters = "required_parameters"; + /// + /// The file name of the .dll that contains the bridge class + /// + const string BridgeDLLName = "TGDreamDaemonBridge.dll"; + /// + /// The namespace that contains the bridge class. Used for reflection + /// + const string DreamDaemonBridgeNamespace = "TGDreamDaemonBridge"; + /// + /// The bridge class. Used for reflection + /// + const string DreamDaemonBridgeType = DreamDaemonBridgeNamespace + ".DreamDaemonBridge"; + List ServerChatCommands; void LoadServerChatCommands() diff --git a/TGServerService/ServerInstance/Repository.cs b/TGServerService/ServerInstance/Repository.cs index 8f9629c8c0..0ebbddb121 100644 --- a/TGServerService/ServerInstance/Repository.cs +++ b/TGServerService/ServerInstance/Repository.cs @@ -96,7 +96,7 @@ namespace TGServerService { Directory.CreateDirectory(RepoKeyDir); if(Exists()) - UpdateInterfaceDlls(false); + UpdateInterfaceDll(false); if(LoadRepo() == null) DisableGarbageCollectionNoLock(); //start the autoupdate timer @@ -336,7 +336,7 @@ namespace TGServerService void InitialConfigureRepository() { Directory.CreateDirectory(StaticDirs); - UpdateInterfaceDlls(false); + UpdateInterfaceDll(false); UpdateTGS3Json(); var Config = GetCachedRepoConfig(); //RepoBusy is set if we're here foreach(var I in Config.StaticDirectoryPaths) From 747b1139f3af939e170b8730d55cf8d032404189 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 2 Nov 2017 15:29:41 -0400 Subject: [PATCH 07/12] Fixes bridge issues --- TGDreamDaemonBridge/DreamDaemonBridge.cs | 1 - TGDreamDaemonBridge/FodyWeavers.xml | 4 ++ .../Properties/AssemblyInfo.cs | 24 +----------- .../TGDreamDaemonBridge.csproj | 37 +++++++++---------- TGDreamDaemonBridge/packages.config | 4 +- TGServerService/ServerInstance/DreamDaemon.cs | 13 ++++--- TGServerService/ServerInstance/Interop.cs | 2 +- TGServerService/ServerInstance/Repository.cs | 4 +- TGServiceInterface/TGServiceInterface.csproj | 1 - TGStationServer3.sln | 8 ++-- 10 files changed, 39 insertions(+), 59 deletions(-) create mode 100644 TGDreamDaemonBridge/FodyWeavers.xml diff --git a/TGDreamDaemonBridge/DreamDaemonBridge.cs b/TGDreamDaemonBridge/DreamDaemonBridge.cs index c95f3e38d0..303143487a 100644 --- a/TGDreamDaemonBridge/DreamDaemonBridge.cs +++ b/TGDreamDaemonBridge/DreamDaemonBridge.cs @@ -20,7 +20,6 @@ namespace TGDreamDaemonBridge [DllExport("DDEntryPoint", CallingConvention = CallingConvention.Cdecl)] public static int DDEntryPoint(int argc, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr, SizeParamIndex = 0)]string[] args) { - System.Diagnostics.Debugger.Launch(); try { using (var I = new Interface()) diff --git a/TGDreamDaemonBridge/FodyWeavers.xml b/TGDreamDaemonBridge/FodyWeavers.xml new file mode 100644 index 0000000000..43fc6a6308 --- /dev/null +++ b/TGDreamDaemonBridge/FodyWeavers.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/TGDreamDaemonBridge/Properties/AssemblyInfo.cs b/TGDreamDaemonBridge/Properties/AssemblyInfo.cs index c011f4041f..7195e9f298 100644 --- a/TGDreamDaemonBridge/Properties/AssemblyInfo.cs +++ b/TGDreamDaemonBridge/Properties/AssemblyInfo.cs @@ -1,18 +1,11 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("TGDreamDaemonBridge")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TGDreamDaemonBridge")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyTitle("TGStation Server Service DreamDaemon Bridge")] +[assembly: AssemblyDescription("Used by DreamDaemon to call into the TGStation Server Service")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from @@ -21,16 +14,3 @@ using System.Runtime.InteropServices; // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("9a01ef03-8eae-45cb-8b87-4a17bd904557")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TGDreamDaemonBridge/TGDreamDaemonBridge.csproj b/TGDreamDaemonBridge/TGDreamDaemonBridge.csproj index 1fb1121cfe..99acc47c27 100644 --- a/TGDreamDaemonBridge/TGDreamDaemonBridge.csproj +++ b/TGDreamDaemonBridge/TGDreamDaemonBridge.csproj @@ -9,36 +9,34 @@ Properties TGDreamDaemonBridge TGDreamDaemonBridge - v4.6.1 + v4.5.2 512 - TGDreamDaemonBridge - true x86 - 1 - false - false + - + true - full - false - bin\Debug\ + bin\x86\Debug\ DEBUG;TRACE + full + x86 prompt - 4 + MinimumRecommendedRules.ruleset - - pdbonly - true - bin\Release\ + + bin\x86\Release\ TRACE + true + pdbonly + x86 prompt - 4 + MinimumRecommendedRules.ruleset + @@ -50,20 +48,19 @@ ..\packages\UnmanagedExports.1.2.7\lib\net\RGiesecke.DllExport.Metadata.dll False - + + + {ac4e7e8b-f83a-481c-a8b0-8fa4e8ae59ab} TGServiceInterface - - - diff --git a/TGDreamDaemonBridge/packages.config b/TGDreamDaemonBridge/packages.config index 8a9cbe435c..3d97405485 100644 --- a/TGDreamDaemonBridge/packages.config +++ b/TGDreamDaemonBridge/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/TGServerService/ServerInstance/DreamDaemon.cs b/TGServerService/ServerInstance/DreamDaemon.cs index 72943470c1..ab98cd4da7 100644 --- a/TGServerService/ServerInstance/DreamDaemon.cs +++ b/TGServerService/ServerInstance/DreamDaemon.cs @@ -518,10 +518,10 @@ namespace TGServerService } /// - /// Copies from the program directory to the the directory + /// Copies from the program directory to the the directory /// /// If , overwrites the 's current interface .dll if it exists - void UpdateInterfaceDll(bool overwrite) + void UpdateBridgeDll(bool overwrite) { var FileExists = File.Exists(BridgeDLLName); if (FileExists && !overwrite) @@ -529,12 +529,13 @@ namespace TGServerService //Copy the interface dll to the static dir var InterfacePath = Assembly.GetAssembly(typeof(Interface)).Location; + //bridge is installed next to the interface var BridgePath = Path.Combine(Path.GetDirectoryName(InterfacePath), BridgeDLLName); #if DEBUG //We could be debugging from the project directory if (!File.Exists(BridgePath)) //A little hackish debug mode doctoring never hurt anyone - BridgePath = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(InterfacePath)))), "TGDreamDaemonBridge/bin/Debug", BridgeDLLName); + BridgePath = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(InterfacePath)))), "TGDreamDaemonBridge/bin/x86/Debug", BridgeDLLName); #endif try { @@ -556,7 +557,7 @@ namespace TGServerService if (Old.SequenceEqual(New)) return; //no need } - File.Copy(InterfacePath, BridgeDLLName, overwrite); + File.Copy(BridgePath, BridgeDLLName, overwrite); Service.WriteInfo("Updated interface DLL", EventID.BridgeDLLUpdated); } catch @@ -576,7 +577,7 @@ namespace TGServerService } /// - /// Clears the current , calls with a parameter, and attempts to start the DreamDaemon + /// Clears the current , calls with a parameter, and attempts to start the DreamDaemon /// /// If , sets to a new pointing to and starts it /// on success, error message on failure @@ -596,7 +597,7 @@ namespace TGServerService GenCommsKey(); StartingSecurity = (DreamDaemonSecurity)Config.ServerSecurity; Proc.StartInfo.Arguments = String.Format("{0} -port {1} {5}-close -verbose -params \"server_service={3}&server_service_version={4}\" -{2} -public", DMB, Config.ServerPort, SecurityWord(), serviceCommsKey, Version(), Config.Webclient ? "-webclient " : ""); - UpdateInterfaceDll(true); + UpdateBridgeDll(true); lock (topicLock) { GameAPIVersion = null; //needs updating diff --git a/TGServerService/ServerInstance/Interop.cs b/TGServerService/ServerInstance/Interop.cs index 1cd07178be..6382e858bf 100644 --- a/TGServerService/ServerInstance/Interop.cs +++ b/TGServerService/ServerInstance/Interop.cs @@ -21,7 +21,7 @@ namespace TGServerService string serviceCommsKey; //regenerated every DD restart //range of supported api versions - const int AllowedMajorAPIVersion = 1; + const int AllowedMajorAPIVersion = 2; Version GameAPIVersion; //See code/modules/server_tools/server_tools.dm for command switch diff --git a/TGServerService/ServerInstance/Repository.cs b/TGServerService/ServerInstance/Repository.cs index 0ebbddb121..cac24f49eb 100644 --- a/TGServerService/ServerInstance/Repository.cs +++ b/TGServerService/ServerInstance/Repository.cs @@ -96,7 +96,7 @@ namespace TGServerService { Directory.CreateDirectory(RepoKeyDir); if(Exists()) - UpdateInterfaceDll(false); + UpdateBridgeDll(false); if(LoadRepo() == null) DisableGarbageCollectionNoLock(); //start the autoupdate timer @@ -336,7 +336,7 @@ namespace TGServerService void InitialConfigureRepository() { Directory.CreateDirectory(StaticDirs); - UpdateInterfaceDll(false); + UpdateBridgeDll(false); UpdateTGS3Json(); var Config = GetCachedRepoConfig(); //RepoBusy is set if we're here foreach(var I in Config.StaticDirectoryPaths) diff --git a/TGServiceInterface/TGServiceInterface.csproj b/TGServiceInterface/TGServiceInterface.csproj index e1832533a1..0b0a2f119a 100644 --- a/TGServiceInterface/TGServiceInterface.csproj +++ b/TGServiceInterface/TGServiceInterface.csproj @@ -69,7 +69,6 @@ - \ No newline at end of file diff --git a/TGStationServer3.sln b/TGStationServer3.sln index e5cf5403d5..00d427c311 100644 --- a/TGStationServer3.sln +++ b/TGStationServer3.sln @@ -116,10 +116,10 @@ Global {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Release|Any CPU.ActiveCfg = Release|Any CPU {8956D4C3-BFB9-448E-BF5F-EE7E6F9996F9}.Release|Any CPU.Build.0 = Release|Any CPU - {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Release|Any CPU.Build.0 = Release|Any CPU + {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Debug|Any CPU.ActiveCfg = Debug|x86 + {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Debug|Any CPU.Build.0 = Debug|x86 + {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Release|Any CPU.ActiveCfg = Release|x86 + {9A01EF03-8EAE-45CB-8B87-4A17BD904557}.Release|Any CPU.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From d550ed775ad933419e73842ac1a1486693a3aa0c Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 2 Nov 2017 15:49:17 -0400 Subject: [PATCH 08/12] Cleans up some class definitions --- TGServerService/ProcessExtension.cs | 2 +- TGServerService/ProjectInstaller.cs | 2 +- TGServerService/Service.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TGServerService/ProcessExtension.cs b/TGServerService/ProcessExtension.cs index 74758b40f3..ecf336a9a0 100644 --- a/TGServerService/ProcessExtension.cs +++ b/TGServerService/ProcessExtension.cs @@ -7,7 +7,7 @@ namespace TGServerService /// /// Helpers to ing and a . Lightly massaged code from https://stackoverflow.com/a/13109774. Documentation linked from MSDN on 20/10/2017 /// - public static class ProcessExtension + static class ProcessExtension { /// /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms686769(v=vs.85).aspx diff --git a/TGServerService/ProjectInstaller.cs b/TGServerService/ProjectInstaller.cs index 2f4d75524d..f5c0f1a911 100644 --- a/TGServerService/ProjectInstaller.cs +++ b/TGServerService/ProjectInstaller.cs @@ -8,7 +8,7 @@ namespace TGServerService /// This tells the .msi there is a Windows in this that needs installation /// [RunInstaller(true)] - public partial class ProjectInstaller : Installer + public sealed class ProjectInstaller : Installer { /// /// Construct a diff --git a/TGServerService/Service.cs b/TGServerService/Service.cs index b42b50dcdf..f181090b0b 100644 --- a/TGServerService/Service.cs +++ b/TGServerService/Service.cs @@ -12,7 +12,7 @@ namespace TGServerService /// /// The windows service the application runs as /// - sealed partial class Service : ServiceBase + sealed class Service : ServiceBase { /// /// The service version based on the From 58fd9c2151ac01c527f14546130e79ef846b9623 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 2 Nov 2017 16:06:58 -0400 Subject: [PATCH 09/12] Fix bad certificate error handling --- TGServiceInterface/Interface.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TGServiceInterface/Interface.cs b/TGServiceInterface/Interface.cs index b07c8e6e6e..9d648c205b 100644 --- a/TGServiceInterface/Interface.cs +++ b/TGServiceInterface/Interface.cs @@ -103,7 +103,7 @@ namespace TGServiceInterface ErrorMessage = "An unknown error occurred."; break; } - ErrorMessage = String.Format("The certificate failed to verify! Error: {2} Cert: {3}", ErrorMessage, cert.ToString()); + ErrorMessage = String.Format("The certificate failed to verify! Error: {0} Cert: {1}", ErrorMessage, cert.ToString()); return handler(ErrorMessage); }; } From 8486c5aa8d4c1d851d405dfbc9c1a50523d53515 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 2 Nov 2017 16:30:27 -0400 Subject: [PATCH 10/12] Version bump to 3.1.6.6 [TGSDeploy] --- Version.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Version.cs b/Version.cs index 8255119c01..fba77566f8 100644 --- a/Version.cs +++ b/Version.cs @@ -12,6 +12,6 @@ using System.Reflection; // [assembly: AssemblyVersion("1.0.*")] //It's impossible to make these a define, don't say I didn't warn you -[assembly: AssemblyVersion("3.1.6.5")] -[assembly: AssemblyFileVersion("3.1.6.5")] -[assembly: AssemblyInformationalVersion("3.1.6.5")] +[assembly: AssemblyVersion("3.1.6.6")] +[assembly: AssemblyFileVersion("3.1.6.6")] +[assembly: AssemblyInformationalVersion("3.1.6.6")] From a92f6f5fd6a1c45ab052b19d71f5b1505fff8b1b Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Fri, 3 Nov 2017 12:04:00 -0400 Subject: [PATCH 11/12] Adds a warning to upgrade to the latest API before upgrading the service --- TGInstallerWrapper/Main.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/TGInstallerWrapper/Main.cs b/TGInstallerWrapper/Main.cs index 2d941c519a..3b297cd5f1 100644 --- a/TGInstallerWrapper/Main.cs +++ b/TGInstallerWrapper/Main.cs @@ -97,8 +97,12 @@ namespace TGInstallerWrapper try { VersionLabel.Text = (string)Version.Invoke(GetComponentITGSService.Invoke(InterfaceObject, null), null); - if (VersionLabel.Text.Contains("v3.0")) //OH GOD!!!! - MessageBox.Show("Warning! Upgrading from version 3.0 may trigger a bug that can delete /config and /data. IT IS STRONGLY RECCOMMENDED THAT YOU BACKUP THESE FOLDERS BEFORE UPDATING!"); + var isV0 = VersionLabel.Text.Contains("v3.0"); + if (isV0) //OH GOD!!!! + MessageBox.Show("Upgrading from version 3.0 may trigger a bug that can delete /config and /data. IT IS STRONGLY RECCOMMENDED THAT YOU BACKUP THESE FOLDERS BEFORE UPDATING!", "Warning"); + if (isV0 || VersionLabel.Text.Contains("v3.1")) + //Friendly reminger + MessageBox.Show("Upgrading to service version 3.2 will break the 3.1 DMAPI. It is recommended you update your game to the 3.2 API before updating the servive to avoid having to trigger hard restarts.", "Note"); } catch { From dc8fb21376cdcb95f29dc27c7b1c53b3dc62172c Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sat, 4 Nov 2017 15:41:47 -0400 Subject: [PATCH 12/12] Moves topic formatting before socket is opened --- TGServerService/ServerInstance/Interop.cs | 44 +++++++++++------------ 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/TGServerService/ServerInstance/Interop.cs b/TGServerService/ServerInstance/Interop.cs index 62bd60b49c..2440cb1fec 100644 --- a/TGServerService/ServerInstance/Interop.cs +++ b/TGServerService/ServerInstance/Interop.cs @@ -165,34 +165,33 @@ namespace TGServerService lock (topicLock) { if (!CheckAPIVersionConstraints()) return "Incompatible API!"; + + StringBuilder stringPacket = new StringBuilder(); + stringPacket.Append((char)'\x00', 8); + stringPacket.Append('?' + topicdata); + stringPacket.Append((char)'\x00'); + string fullString = stringPacket.ToString(); + var packet = Encoding.ASCII.GetBytes(fullString); + packet[1] = 0x83; + var FinalLength = packet.Length - 4; + if (FinalLength > UInt16.MaxValue) + return "Error: Topic too long"; + + var lengthBytes = BitConverter.GetBytes((ushort)FinalLength); + + packet[2] = lengthBytes[1]; //fucking endianess + packet[3] = lengthBytes[0]; + + var returnedString = "NULL"; + var returnedData = new byte[UInt16.MaxValue]; using (var topicSender = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) { SendTimeout = 5000, ReceiveTimeout = 5000 }) - { try { topicSender.Connect(IPAddress.Loopback, port); - - StringBuilder stringPacket = new StringBuilder(); - stringPacket.Append((char)'\x00', 8); - stringPacket.Append('?' + topicdata); - stringPacket.Append((char)'\x00'); - string fullString = stringPacket.ToString(); - var packet = Encoding.ASCII.GetBytes(fullString); - packet[1] = 0x83; - var FinalLength = packet.Length - 4; - if (FinalLength > UInt16.MaxValue) - return "Error: Topic too long"; - - var lengthBytes = BitConverter.GetBytes((ushort)FinalLength); - - packet[2] = lengthBytes[1]; //fucking endianess - packet[3] = lengthBytes[0]; - topicSender.Send(packet); - string returnedString = "NULL"; try { - var returnedData = new byte[UInt16.MaxValue]; topicSender.Receive(returnedData); var raw_string = Encoding.ASCII.GetString(returnedData).TrimEnd(new char[] { (char)0 }).Trim(); if (raw_string.Length > 6) @@ -206,14 +205,13 @@ namespace TGServerService { topicSender.Shutdown(SocketShutdown.Both); } - - return returnedString; } catch { return "Topic delivery failed!"; } - } + + return returnedString; } }