Fix transfer limits. Add logging

This commit is contained in:
Cyberboss
2017-09-22 10:54:49 -04:00
parent 693952ae1b
commit fc3541a4ce
4 changed files with 29 additions and 11 deletions
+2 -6
View File
@@ -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";
+5 -1
View File
@@ -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;
}
+8 -2
View File
@@ -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;
+14 -2
View File
@@ -13,6 +13,16 @@ namespace TGServiceInterface
/// </summary>
public static readonly IList<Type> ValidInterfaces = new List<Type> { typeof(ITGByond), typeof(ITGChat), typeof(ITGCompiler), typeof(ITGConfig), typeof(ITGDreamDaemon), typeof(ITGRepository), typeof(ITGSService), typeof(ITGConnectivity), typeof(ITGAdministration), typeof(ITGInterop) };
/// <summary>
/// The maximum message size to and from a local server
/// </summary>
public static readonly long TransferLimitLocal = Int32.MaxValue; //2GB can't go higher
/// <summary>
/// The maximum message size to and from a remote server
/// </summary>
public static readonly long TransferLimitRemote = 10485760; //10 MB
/// <summary>
/// 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<T>(new NetNamedPipeBinding { SendTimeout = new TimeSpan(0, 10, 0) }, new EndpointAddress(String.Format("net.pipe://localhost/{0}/{1}", MasterInterfaceName, InterfaceName)));
outChannel = new ChannelFactory<T>(
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