diff --git a/TGControlPanel/StaticPage.cs b/TGControlPanel/StaticPage.cs index 8e3a158acf..916dc1357a 100644 --- a/TGControlPanel/StaticPage.cs +++ b/TGControlPanel/StaticPage.cs @@ -220,12 +220,8 @@ namespace TGControlPanel var newIndex = StaticFileListBox.SelectedIndex; var path = IndexesToPaths[newIndex]; var title = (string)StaticFileListBox.Items[newIndex]; - if (path == "TGServiceInterface.dll") - { - StaticFileEditTextbox.ReadOnly = true; - StaticFileEditTextbox.Text = "/tg/station Server Interface DLL"; - } - else if (title[title.Length - 1] == '/') + var authed_title = title.Replace(" (UNAUTHORIZED)", ""); + if (authed_title[authed_title.Length - 1] == '/') { StaticFileEditTextbox.ReadOnly = true; StaticFileEditTextbox.Text = "Directory"; diff --git a/TGServerService/Config.cs b/TGServerService/Config.cs index 8ff2a875a8..d811b6128a 100644 --- a/TGServerService/Config.cs +++ b/TGServerService/Config.cs @@ -77,9 +77,11 @@ namespace TGServerService return null; } + var output = File.ReadAllText(path); + TGServerService.WriteInfo("Read of " + path, TGServerService.EventID.StaticRead); error = null; unauthorized = false; - return File.ReadAllText(path); + return output; } } catch (UnauthorizedAccessException e) @@ -127,6 +129,7 @@ namespace TGServerService Directory.CreateDirectory(destdir); File.WriteAllText(path, data); + TGServerService.WriteInfo(String.Format("Rewrite {0}: {1}", path, data), TGServerService.EventID.StaticWrite); unauthorized = false; return null; } @@ -176,6 +179,7 @@ namespace TGServerService File.Delete(path); else if (Directory.Exists(path)) Program.DeleteDirectory(path); + TGServerService.WriteInfo("Delete of " + path, TGServerService.EventID.StaticDelete); unauthorized = false; return null; } diff --git a/TGServerService/ServerService.cs b/TGServerService/ServerService.cs index 061b922d9b..558573e747 100644 --- a/TGServerService/ServerService.cs +++ b/TGServerService/ServerService.cs @@ -81,6 +81,9 @@ namespace TGServerService InteropCallException = 7000, APIVersionMismatch = 7100, RepoConfigurationFail = 7200, + StaticRead = 7300, + StaticWrite = 7400, + StaticDelete = 7500, } static TGServerService ActiveService; //So everyone else can write to our eventlog @@ -196,8 +199,11 @@ namespace TGServerService void AddEndpoint(Type typetype) { var bindingName = Server.MasterInterfaceName + "/" + typetype.Name; - host.AddServiceEndpoint(typetype, new NetNamedPipeBinding(), bindingName); - var httpsBinding = new WSHttpBinding(); + host.AddServiceEndpoint(typetype, new NetNamedPipeBinding() { MaxReceivedMessageSize = Server.TransferLimitLocal }, bindingName); + var httpsBinding = new WSHttpBinding() + { + MaxReceivedMessageSize = Server.TransferLimitRemote + }; var requireAuth = typetype.Name != typeof(ITGConnectivity).Name; httpsBinding.Security.Mode = requireAuth ? SecurityMode.TransportWithMessageCredential : SecurityMode.Transport; //do not require auth for a connectivity check httpsBinding.Security.Message.ClientCredentialType = requireAuth ? MessageCredentialType.UserName : MessageCredentialType.None; diff --git a/TGServiceInterface/Server.cs b/TGServiceInterface/Server.cs index 31c01b92ec..9ceacf9fa0 100644 --- a/TGServiceInterface/Server.cs +++ b/TGServiceInterface/Server.cs @@ -13,6 +13,16 @@ namespace TGServiceInterface /// public static readonly IList ValidInterfaces = new List { typeof(ITGByond), typeof(ITGChat), typeof(ITGCompiler), typeof(ITGConfig), typeof(ITGDreamDaemon), typeof(ITGRepository), typeof(ITGSService), typeof(ITGConnectivity), typeof(ITGAdministration), typeof(ITGInterop) }; + /// + /// The maximum message size to and from a local server + /// + public static readonly long TransferLimitLocal = Int32.MaxValue; //2GB can't go higher + + /// + /// The maximum message size to and from a remote server + /// + public static readonly long TransferLimitRemote = 10485760; //10 MB + /// /// Base name of the communication pipe /// they are formatted as MasterPipeName/ComponentName @@ -107,7 +117,8 @@ namespace TGServiceInterface var InterfaceName = typeof(T).Name; if (HTTPSURL == null) { - outChannel = new ChannelFactory(new NetNamedPipeBinding { SendTimeout = new TimeSpan(0, 10, 0) }, new EndpointAddress(String.Format("net.pipe://localhost/{0}/{1}", MasterInterfaceName, InterfaceName))); + outChannel = new ChannelFactory( + new NetNamedPipeBinding { SendTimeout = new TimeSpan(0, 10, 0), MaxReceivedMessageSize = TransferLimitLocal }, new EndpointAddress(String.Format("net.pipe://localhost/{0}/{1}", MasterInterfaceName, InterfaceName))); //10 megs outChannel.Credentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation; return outChannel.CreateChannel(); } @@ -115,7 +126,8 @@ namespace TGServiceInterface //okay we're going over var binding = new WSHttpBinding() { - SendTimeout = new TimeSpan(0, 10, 0) + SendTimeout = new TimeSpan(0, 10, 0), + MaxReceivedMessageSize = TransferLimitRemote }; var requireAuth = InterfaceName != typeof(ITGConnectivity).Name; binding.Security.Mode = requireAuth ? SecurityMode.TransportWithMessageCredential : SecurityMode.Transport; //do not require auth for a connectivity check