SetZooConsoleEnabled - Random Url

This commit is contained in:
sergey 2013-06-14 13:36:29 +03:00
parent 14febde12b
commit eb1bf2213e

View file

@ -727,17 +727,10 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
public void SetZooConsoleEnabled(ServerManager srvman, string siteId, string appName)
{
UInt32 hwidlow = (UInt32)GetVolumeSerial();
UInt64 hwidhi = ((UInt64) hwidlow) << 32;
UInt64 secret = (ulong) DateTime.Now.ToFileTime();
UInt64 hw = hwidhi | hwidlow;
secret ^= hw;
string consoleUrl = "console_" + secret.ToString();
Random random = new Random((int) DateTime.Now.Ticks);
byte[] bytes = new byte[8];
random.NextBytes(bytes);
string consoleUrl = "console_" + Convert.ToBase64String(bytes);
SetZooEnvironmentVariable(srvman, siteId, appName, "CONSOLE_URL", consoleUrl);
}
@ -801,25 +794,7 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
}
[DllImport("kernel32.dll")]
private static extern long GetVolumeInformation(string PathName, StringBuilder VolumeNameBuffer, UInt32 VolumeNameSize, ref UInt32 VolumeSerialNumber, ref UInt32 MaximumComponentLength, ref UInt32 FileSystemFlags, StringBuilder FileSystemNameBuffer, UInt32 FileSystemNameSize);
private static int GetVolumeSerial()
{
new FileIOPermission(PermissionState.Unrestricted).Assert();
string strDriveLetter = new string(Environment.SystemDirectory[0], 1);
uint serNum = 0;
uint maxCompLen = 0;
StringBuilder VolLabel = new StringBuilder(256); // Label
UInt32 VolFlags = new UInt32();
StringBuilder FSName = new StringBuilder(256); // File System Name
strDriveLetter += ":\\";
long Ret = GetVolumeInformation(strDriveLetter, VolLabel, (UInt32)VolLabel.Capacity, ref serNum, ref maxCompLen, ref VolFlags, FSName, (UInt32)FSName.Capacity);
return (int)serNum;
}
public WebVirtualDirectory GetVirtualDirectory(string siteId, string directoryName)
{