add Novetus.Core namespace. Basic web proxy Extension support.
This commit is contained in:
parent
b0b2bad019
commit
f46b7d9a9c
|
|
@ -1,5 +1,6 @@
|
|||
#region Usings
|
||||
using NLog;
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using NLog;
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Text;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
* To change this template use Tools | Options | Coding | Edit Standard Headers.
|
||||
*/
|
||||
|
||||
using Novetus.Core;
|
||||
|
||||
partial class CharacterCustomizationCompact
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
*
|
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers.
|
||||
*/
|
||||
using Novetus.Core;
|
||||
|
||||
partial class CharacterCustomizationExtended
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ using System.Collections.Specialized;
|
|||
using System.Text.RegularExpressions;
|
||||
#endregion
|
||||
|
||||
#region CommandLineArguments
|
||||
namespace Novetus.Core
|
||||
{
|
||||
#region CommandLineArguments
|
||||
public class CommandLineArguments
|
||||
{
|
||||
//https://www.codeproject.com/Articles/3111/C-NET-Command-Line-Arguments-Parser
|
||||
|
|
@ -118,3 +120,4 @@ using System.Text.RegularExpressions;
|
|||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,49 +3,52 @@ using System;
|
|||
using System.Security.Cryptography;
|
||||
#endregion
|
||||
|
||||
#region CryptoRandom
|
||||
|
||||
public class CryptoRandom : RandomNumberGenerator
|
||||
namespace Novetus.Core
|
||||
{
|
||||
private static RandomNumberGenerator r;
|
||||
#region CryptoRandom
|
||||
|
||||
public CryptoRandom()
|
||||
public class CryptoRandom : RandomNumberGenerator
|
||||
{
|
||||
r = Create();
|
||||
}
|
||||
private static RandomNumberGenerator r;
|
||||
|
||||
///<param name=”buffer”>An array of bytes to contain random numbers.</param>
|
||||
public override void GetBytes(byte[] buffer)
|
||||
{
|
||||
r.GetBytes(buffer);
|
||||
}
|
||||
public CryptoRandom()
|
||||
{
|
||||
r = Create();
|
||||
}
|
||||
|
||||
public override void GetNonZeroBytes(byte[] data)
|
||||
{
|
||||
r.GetNonZeroBytes(data);
|
||||
}
|
||||
public double NextDouble()
|
||||
{
|
||||
byte[] b = new byte[4];
|
||||
r.GetBytes(b);
|
||||
return (double)BitConverter.ToUInt32(b, 0) / UInt32.MaxValue;
|
||||
}
|
||||
///<param name=”buffer”>An array of bytes to contain random numbers.</param>
|
||||
public override void GetBytes(byte[] buffer)
|
||||
{
|
||||
r.GetBytes(buffer);
|
||||
}
|
||||
|
||||
///<param name=”minValue”>The inclusive lower bound of the random number returned.</param>
|
||||
///<param name=”maxValue”>The exclusive upper bound of the random number returned. maxValue must be greater than or equal to minValue.</param>
|
||||
public int Next(int minValue, int maxValue)
|
||||
{
|
||||
return (int)Math.Round(NextDouble() * (maxValue - minValue - 1)) + minValue;
|
||||
}
|
||||
public int Next()
|
||||
{
|
||||
return Next(0, int.MaxValue);
|
||||
}
|
||||
public override void GetNonZeroBytes(byte[] data)
|
||||
{
|
||||
r.GetNonZeroBytes(data);
|
||||
}
|
||||
public double NextDouble()
|
||||
{
|
||||
byte[] b = new byte[4];
|
||||
r.GetBytes(b);
|
||||
return (double)BitConverter.ToUInt32(b, 0) / UInt32.MaxValue;
|
||||
}
|
||||
|
||||
///<param name=”maxValue”>The inclusive upper bound of the random number returned. maxValue must be greater than or equal 0</param>
|
||||
public int Next(int maxValue)
|
||||
{
|
||||
return Next(0, maxValue);
|
||||
///<param name=”minValue”>The inclusive lower bound of the random number returned.</param>
|
||||
///<param name=”maxValue”>The exclusive upper bound of the random number returned. maxValue must be greater than or equal to minValue.</param>
|
||||
public int Next(int minValue, int maxValue)
|
||||
{
|
||||
return (int)Math.Round(NextDouble() * (maxValue - minValue - 1)) + minValue;
|
||||
}
|
||||
public int Next()
|
||||
{
|
||||
return Next(0, int.MaxValue);
|
||||
}
|
||||
|
||||
///<param name=”maxValue”>The inclusive upper bound of the random number returned. maxValue must be greater than or equal 0</param>
|
||||
public int Next(int maxValue)
|
||||
{
|
||||
return Next(0, maxValue);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -6,245 +6,248 @@ using System.Threading;
|
|||
using System.Windows.Forms;
|
||||
#endregion
|
||||
|
||||
#region Downloader
|
||||
|
||||
class Downloader
|
||||
namespace Novetus.Core
|
||||
{
|
||||
public readonly string fileURL;
|
||||
public readonly string fileName;
|
||||
public readonly string fileFilter;
|
||||
public readonly string filePath;
|
||||
public static bool showErrorInfo = true;
|
||||
public static bool overwrite = true;
|
||||
public int downloadSize;
|
||||
private string downloadOutcome;
|
||||
private static string downloadOutcomeException;
|
||||
#region Downloader
|
||||
|
||||
public Downloader(string url, string name, string filter)
|
||||
class Downloader
|
||||
{
|
||||
fileName = name;
|
||||
fileURL = url;
|
||||
fileFilter = filter;
|
||||
}
|
||||
public readonly string fileURL;
|
||||
public readonly string fileName;
|
||||
public readonly string fileFilter;
|
||||
public readonly string filePath;
|
||||
public static bool showErrorInfo = true;
|
||||
public static bool overwrite = true;
|
||||
public int downloadSize;
|
||||
private string downloadOutcome;
|
||||
private static string downloadOutcomeException;
|
||||
|
||||
public Downloader(string url, string name, string filter, string path)
|
||||
{
|
||||
fileName = name;
|
||||
fileURL = url;
|
||||
fileFilter = filter;
|
||||
filePath = path;
|
||||
}
|
||||
|
||||
public Downloader(string url, string name)
|
||||
{
|
||||
fileName = name;
|
||||
fileURL = url;
|
||||
fileFilter = "";
|
||||
}
|
||||
|
||||
public void setDownloadOptions(bool ExtraErrorInfo, bool OverwriteFiles)
|
||||
{
|
||||
showErrorInfo = ExtraErrorInfo;
|
||||
overwrite = OverwriteFiles;
|
||||
}
|
||||
|
||||
public string getDownloadOutcome()
|
||||
{
|
||||
return downloadOutcome;
|
||||
}
|
||||
|
||||
public void InitDownloadDirect(string path, string fileext, string additionalText = "", bool removeSpaces = false)
|
||||
{
|
||||
string outputfilename = "";
|
||||
|
||||
if (removeSpaces == true)
|
||||
public Downloader(string url, string name, string filter)
|
||||
{
|
||||
outputfilename = (fileName + fileext).Replace(" ", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
outputfilename = fileName + fileext;
|
||||
}
|
||||
|
||||
string fullpath = path + "\\" + outputfilename;
|
||||
|
||||
InitDownloadNoDialog(fullpath, additionalText);
|
||||
}
|
||||
|
||||
public void InitDownload(string additionalText = "")
|
||||
{
|
||||
SaveFileDialog saveFileDialog1 = new SaveFileDialog
|
||||
{
|
||||
FileName = fileName,
|
||||
//"Compressed zip files (*.zip)|*.zip|All files (*.*)|*.*"
|
||||
Filter = fileFilter,
|
||||
Title = "Save " + fileName
|
||||
};
|
||||
|
||||
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
InitDownloadNoDialog(saveFileDialog1.FileName, additionalText);
|
||||
}
|
||||
}
|
||||
|
||||
public void InitDownloadNoDialog(string name, string additionalText = "")
|
||||
{
|
||||
if (!overwrite && File.Exists(name))
|
||||
{
|
||||
downloadOutcome = "Download skipped due to same file name.";
|
||||
return;
|
||||
fileName = name;
|
||||
fileURL = url;
|
||||
fileFilter = filter;
|
||||
}
|
||||
|
||||
int read = 0;
|
||||
|
||||
try
|
||||
public Downloader(string url, string name, string filter, string path)
|
||||
{
|
||||
read = DownloadFile(fileURL, name);
|
||||
fileName = name;
|
||||
fileURL = url;
|
||||
fileFilter = filter;
|
||||
filePath = path;
|
||||
}
|
||||
|
||||
public Downloader(string url, string name)
|
||||
{
|
||||
fileName = name;
|
||||
fileURL = url;
|
||||
fileFilter = "";
|
||||
}
|
||||
|
||||
public void setDownloadOptions(bool ExtraErrorInfo, bool OverwriteFiles)
|
||||
{
|
||||
showErrorInfo = ExtraErrorInfo;
|
||||
overwrite = OverwriteFiles;
|
||||
}
|
||||
|
||||
public string getDownloadOutcome()
|
||||
{
|
||||
return downloadOutcome;
|
||||
}
|
||||
|
||||
public void InitDownloadDirect(string path, string fileext, string additionalText = "", bool removeSpaces = false)
|
||||
{
|
||||
string outputfilename = "";
|
||||
|
||||
if (removeSpaces == true)
|
||||
{
|
||||
outputfilename = (fileName + fileext).Replace(" ", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
outputfilename = fileName + fileext;
|
||||
}
|
||||
|
||||
string fullpath = path + "\\" + outputfilename;
|
||||
|
||||
InitDownloadNoDialog(fullpath, additionalText);
|
||||
}
|
||||
|
||||
public void InitDownload(string additionalText = "")
|
||||
{
|
||||
SaveFileDialog saveFileDialog1 = new SaveFileDialog
|
||||
{
|
||||
FileName = fileName,
|
||||
//"Compressed zip files (*.zip)|*.zip|All files (*.*)|*.*"
|
||||
Filter = fileFilter,
|
||||
Title = "Save " + fileName
|
||||
};
|
||||
|
||||
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
InitDownloadNoDialog(saveFileDialog1.FileName, additionalText);
|
||||
}
|
||||
}
|
||||
|
||||
public void InitDownloadNoDialog(string name, string additionalText = "")
|
||||
{
|
||||
if (!overwrite && File.Exists(name))
|
||||
{
|
||||
downloadOutcome = "Download skipped due to same file name.";
|
||||
return;
|
||||
}
|
||||
|
||||
int read = 0;
|
||||
|
||||
try
|
||||
{
|
||||
read = DownloadFile(fileURL, name);
|
||||
}
|
||||
#if URI || LAUNCHER || BASICLAUNCHER
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.LogExceptions(ex);
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.LogExceptions(ex);
|
||||
#else
|
||||
catch (Exception)
|
||||
{
|
||||
#endif
|
||||
downloadOutcome = "Error when downloading file: " + ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
//wait a few seconds for the download to finish
|
||||
//Thread.Sleep(2000);
|
||||
if (File.Exists(name) && read > 0)
|
||||
{
|
||||
downloadSize = read;
|
||||
downloadOutcome = "File " + Path.GetFileName(name) + " downloaded! " + Util.SizeSuffix(Convert.ToInt64(downloadSize), 2) + " written (" + downloadSize + " bytes)! " + additionalText;
|
||||
downloadOutcome = "Error when downloading file: " + ex.Message;
|
||||
}
|
||||
else
|
||||
finally
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(downloadOutcomeException))
|
||||
//wait a few seconds for the download to finish
|
||||
//Thread.Sleep(2000);
|
||||
if (File.Exists(name) && read > 0)
|
||||
{
|
||||
downloadOutcome = "Error: Download of file " + Path.GetFileName(name) + " failed. " + downloadOutcomeException;
|
||||
downloadSize = read;
|
||||
downloadOutcome = "File " + Path.GetFileName(name) + " downloaded! " + Util.SizeSuffix(Convert.ToInt64(downloadSize), 2) + " written (" + downloadSize + " bytes)! " + additionalText;
|
||||
}
|
||||
else
|
||||
{
|
||||
downloadOutcome = "Error: Download of file " + Path.GetFileName(name) + " failed. The file wasn't downloaded to the assigned directory.";
|
||||
}
|
||||
|
||||
if (showErrorInfo)
|
||||
{
|
||||
downloadOutcome += "\n\nMore error info:\n\nFile URL: " + fileURL + "\n\nFile Path: " + name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetFullDLPath()
|
||||
{
|
||||
return filePath + Path.DirectorySeparatorChar + fileName;
|
||||
}
|
||||
|
||||
private static int DownloadFile(string remoteFilename, string localFilename)
|
||||
{
|
||||
//credit to Tom Archer (https://www.codeguru.com/columns/dotnettips/article.php/c7005/Downloading-Files-with-the-WebRequest-and-WebResponse-Classes.htm)
|
||||
//and Brokenglass (https://stackoverflow.com/questions/4567313/uncompressing-gzip-response-from-webclient/4567408#4567408)
|
||||
|
||||
// Function will return the number of bytes processed
|
||||
// to the caller. Initialize to 0 here.
|
||||
int bytesProcessed = 0;
|
||||
|
||||
// Assign values to these objects here so that they can
|
||||
// be referenced in the finally block
|
||||
Stream remoteStream = null;
|
||||
Stream localStream = null;
|
||||
WebResponse response = null;
|
||||
|
||||
// Use a try/catch/finally block as both the WebRequest and Stream
|
||||
// classes throw exceptions upon error
|
||||
//thanks to https://stackoverflow.com/questions/33761919/tls-1-2-in-net-framework-4-0 for the net 4.0 compatible TLS 1.1/1.2 code!
|
||||
try
|
||||
{
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
|
||||
| (SecurityProtocolType)3072
|
||||
| (SecurityProtocolType)768
|
||||
| SecurityProtocolType.Ssl3;
|
||||
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
|
||||
// Create a request for the specified remote file name
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(remoteFilename);
|
||||
//changing it to just "roblox" since roblox is breaking everything.
|
||||
//request.UserAgent = "Roblox/WinINet";
|
||||
request.UserAgent = "Roblox";
|
||||
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
|
||||
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||
if (request != null)
|
||||
{
|
||||
// Send the request to the server and retrieve the
|
||||
// WebResponse object
|
||||
response = request.GetResponse();
|
||||
if (response != null)
|
||||
{
|
||||
// Once the WebResponse object has been retrieved,
|
||||
// get the stream object associated with the response's data
|
||||
remoteStream = response.GetResponseStream();
|
||||
|
||||
// Create the local file
|
||||
localStream = File.Create(localFilename);
|
||||
|
||||
// Allocate a 1k buffer
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
|
||||
// Simple do/while loop to read from stream until
|
||||
// no bytes are returned
|
||||
do
|
||||
if (!string.IsNullOrWhiteSpace(downloadOutcomeException))
|
||||
{
|
||||
// Read data (up to 1k) from the stream
|
||||
bytesRead = remoteStream.Read(buffer, 0, buffer.Length);
|
||||
downloadOutcome = "Error: Download of file " + Path.GetFileName(name) + " failed. " + downloadOutcomeException;
|
||||
}
|
||||
else
|
||||
{
|
||||
downloadOutcome = "Error: Download of file " + Path.GetFileName(name) + " failed. The file wasn't downloaded to the assigned directory.";
|
||||
}
|
||||
|
||||
// Write the data to the local file
|
||||
localStream.Write(buffer, 0, bytesRead);
|
||||
|
||||
// Increment total bytes processed
|
||||
bytesProcessed += bytesRead;
|
||||
} while (bytesRead > 0);
|
||||
if (showErrorInfo)
|
||||
{
|
||||
downloadOutcome += "\n\nMore error info:\n\nFile URL: " + fileURL + "\n\nFile Path: " + name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
public string GetFullDLPath()
|
||||
{
|
||||
#if URI || LAUNCHER || BASICLAUNCHER
|
||||
Util.LogExceptions(e);
|
||||
#endif
|
||||
if (e is WebException && bytesProcessed == 0)
|
||||
return filePath + Path.DirectorySeparatorChar + fileName;
|
||||
}
|
||||
|
||||
private static int DownloadFile(string remoteFilename, string localFilename)
|
||||
{
|
||||
//credit to Tom Archer (https://www.codeguru.com/columns/dotnettips/article.php/c7005/Downloading-Files-with-the-WebRequest-and-WebResponse-Classes.htm)
|
||||
//and Brokenglass (https://stackoverflow.com/questions/4567313/uncompressing-gzip-response-from-webclient/4567408#4567408)
|
||||
|
||||
// Function will return the number of bytes processed
|
||||
// to the caller. Initialize to 0 here.
|
||||
int bytesProcessed = 0;
|
||||
|
||||
// Assign values to these objects here so that they can
|
||||
// be referenced in the finally block
|
||||
Stream remoteStream = null;
|
||||
Stream localStream = null;
|
||||
WebResponse response = null;
|
||||
|
||||
// Use a try/catch/finally block as both the WebRequest and Stream
|
||||
// classes throw exceptions upon error
|
||||
//thanks to https://stackoverflow.com/questions/33761919/tls-1-2-in-net-framework-4-0 for the net 4.0 compatible TLS 1.1/1.2 code!
|
||||
try
|
||||
{
|
||||
WebException ex = (WebException)e;
|
||||
HttpWebResponse errorResponse = ex.Response as HttpWebResponse;
|
||||
if (errorResponse.StatusCode == HttpStatusCode.Conflict || errorResponse.StatusCode == HttpStatusCode.Forbidden)
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
|
||||
| (SecurityProtocolType)3072
|
||||
| (SecurityProtocolType)768
|
||||
| SecurityProtocolType.Ssl3;
|
||||
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
|
||||
// Create a request for the specified remote file name
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(remoteFilename);
|
||||
//changing it to just "roblox" since roblox is breaking everything.
|
||||
//request.UserAgent = "Roblox/WinINet";
|
||||
request.UserAgent = "Roblox";
|
||||
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
|
||||
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||
if (request != null)
|
||||
{
|
||||
downloadOutcomeException = "Error: Unable to download item. The item may not be publically available.";
|
||||
// Send the request to the server and retrieve the
|
||||
// WebResponse object
|
||||
response = request.GetResponse();
|
||||
if (response != null)
|
||||
{
|
||||
// Once the WebResponse object has been retrieved,
|
||||
// get the stream object associated with the response's data
|
||||
remoteStream = response.GetResponseStream();
|
||||
|
||||
// Create the local file
|
||||
localStream = File.Create(localFilename);
|
||||
|
||||
// Allocate a 1k buffer
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
|
||||
// Simple do/while loop to read from stream until
|
||||
// no bytes are returned
|
||||
do
|
||||
{
|
||||
// Read data (up to 1k) from the stream
|
||||
bytesRead = remoteStream.Read(buffer, 0, buffer.Length);
|
||||
|
||||
// Write the data to the local file
|
||||
localStream.Write(buffer, 0, bytesRead);
|
||||
|
||||
// Increment total bytes processed
|
||||
bytesProcessed += bytesRead;
|
||||
} while (bytesRead > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if URI || LAUNCHER || BASICLAUNCHER
|
||||
Util.LogExceptions(e);
|
||||
#endif
|
||||
if (e is WebException && bytesProcessed == 0)
|
||||
{
|
||||
WebException ex = (WebException)e;
|
||||
HttpWebResponse errorResponse = ex.Response as HttpWebResponse;
|
||||
if (errorResponse.StatusCode == HttpStatusCode.Conflict || errorResponse.StatusCode == HttpStatusCode.Forbidden)
|
||||
{
|
||||
downloadOutcomeException = "Error: Unable to download item. The item may not be publically available.";
|
||||
}
|
||||
else
|
||||
{
|
||||
downloadOutcomeException = "Exception: " + ex.Message;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
downloadOutcomeException = "Exception: " + ex.Message;
|
||||
downloadOutcomeException = "Exception: " + e.Message;
|
||||
}
|
||||
}
|
||||
else
|
||||
finally
|
||||
{
|
||||
downloadOutcomeException = "Exception: " + e.Message;
|
||||
// Close the response and streams objects here
|
||||
// to make sure they're closed even if an exception
|
||||
// is thrown at some point
|
||||
if (response != null) response.Close();
|
||||
if (remoteStream != null) remoteStream.Close();
|
||||
if (localStream != null) localStream.Close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Close the response and streams objects here
|
||||
// to make sure they're closed even if an exception
|
||||
// is thrown at some point
|
||||
if (response != null) response.Close();
|
||||
if (remoteStream != null) remoteStream.Close();
|
||||
if (localStream != null) localStream.Close();
|
||||
}
|
||||
|
||||
// Return total bytes processed to caller.
|
||||
return bytesProcessed;
|
||||
// Return total bytes processed to caller.
|
||||
return bytesProcessed;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -2,95 +2,98 @@
|
|||
using System.Runtime.InteropServices;
|
||||
#endregion
|
||||
|
||||
#region Discord RPC
|
||||
//code by discord obv. just renamed it to fit better.
|
||||
public class DiscordRPC
|
||||
namespace Novetus.Core
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void ReadyCallback();
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void DisconnectedCallback(int errorCode, string message);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void ErrorCallback(int errorCode, string message);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void JoinCallback(string secret);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void SpectateCallback(string secret);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void RequestCallback(JoinRequest request);
|
||||
|
||||
public struct EventHandlers
|
||||
#region Discord RPC
|
||||
//code by discord obv. just renamed it to fit better.
|
||||
public class DiscordRPC
|
||||
{
|
||||
public ReadyCallback readyCallback;
|
||||
public DisconnectedCallback disconnectedCallback;
|
||||
public ErrorCallback errorCallback;
|
||||
public JoinCallback joinCallback;
|
||||
public SpectateCallback spectateCallback;
|
||||
public RequestCallback requestCallback;
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void ReadyCallback();
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void DisconnectedCallback(int errorCode, string message);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void ErrorCallback(int errorCode, string message);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void JoinCallback(string secret);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void SpectateCallback(string secret);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void RequestCallback(JoinRequest request);
|
||||
|
||||
public struct EventHandlers
|
||||
{
|
||||
public ReadyCallback readyCallback;
|
||||
public DisconnectedCallback disconnectedCallback;
|
||||
public ErrorCallback errorCallback;
|
||||
public JoinCallback joinCallback;
|
||||
public SpectateCallback spectateCallback;
|
||||
public RequestCallback requestCallback;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct RichPresence
|
||||
{
|
||||
public string state;
|
||||
/* max 128 bytes */
|
||||
public string details;
|
||||
/* max 128 bytes */
|
||||
public long startTimestamp;
|
||||
public long endTimestamp;
|
||||
public string largeImageKey;
|
||||
/* max 32 bytes */
|
||||
public string largeImageText;
|
||||
/* max 128 bytes */
|
||||
public string smallImageKey;
|
||||
/* max 32 bytes */
|
||||
public string smallImageText;
|
||||
/* max 128 bytes */
|
||||
public string partyId;
|
||||
/* max 128 bytes */
|
||||
public int partySize;
|
||||
public int partyMax;
|
||||
public string matchSecret;
|
||||
/* max 128 bytes */
|
||||
public string joinSecret;
|
||||
/* max 128 bytes */
|
||||
public string spectateSecret;
|
||||
/* max 128 bytes */
|
||||
public bool instance;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct JoinRequest
|
||||
{
|
||||
public string userId;
|
||||
public string username;
|
||||
public string avatar;
|
||||
}
|
||||
|
||||
public enum Reply
|
||||
{
|
||||
No = 0,
|
||||
Yes = 1,
|
||||
Ignore = 2
|
||||
}
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_Initialize", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId);
|
||||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_Shutdown", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Shutdown();
|
||||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_RunCallbacks", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void RunCallbacks();
|
||||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_UpdatePresence", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void UpdatePresence(ref RichPresence presence);
|
||||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_Respond", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Respond(string userId, Reply reply);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct RichPresence
|
||||
{
|
||||
public string state;
|
||||
/* max 128 bytes */
|
||||
public string details;
|
||||
/* max 128 bytes */
|
||||
public long startTimestamp;
|
||||
public long endTimestamp;
|
||||
public string largeImageKey;
|
||||
/* max 32 bytes */
|
||||
public string largeImageText;
|
||||
/* max 128 bytes */
|
||||
public string smallImageKey;
|
||||
/* max 32 bytes */
|
||||
public string smallImageText;
|
||||
/* max 128 bytes */
|
||||
public string partyId;
|
||||
/* max 128 bytes */
|
||||
public int partySize;
|
||||
public int partyMax;
|
||||
public string matchSecret;
|
||||
/* max 128 bytes */
|
||||
public string joinSecret;
|
||||
/* max 128 bytes */
|
||||
public string spectateSecret;
|
||||
/* max 128 bytes */
|
||||
public bool instance;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct JoinRequest
|
||||
{
|
||||
public string userId;
|
||||
public string username;
|
||||
public string avatar;
|
||||
}
|
||||
|
||||
public enum Reply
|
||||
{
|
||||
No = 0,
|
||||
Yes = 1,
|
||||
Ignore = 2
|
||||
}
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_Initialize", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId);
|
||||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_Shutdown", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Shutdown();
|
||||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_RunCallbacks", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void RunCallbacks();
|
||||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_UpdatePresence", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void UpdatePresence(ref RichPresence presence);
|
||||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_Respond", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Respond(string userId, Reply reply);
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -5,95 +5,98 @@ using System.Runtime.InteropServices;
|
|||
using System.Text;
|
||||
#endregion
|
||||
|
||||
#region INI File Parser
|
||||
//modified from https://www.codeproject.com/articles/1966/an-ini-file-handling-class-using-c?fid=425860&df=90&mpp=25&prof=True&sort=Position&view=Normal&spc=Relaxed&fr=51
|
||||
|
||||
public class INIFile
|
||||
namespace Novetus.Core
|
||||
{
|
||||
public string path;
|
||||
#region INI File Parser
|
||||
//modified from https://www.codeproject.com/articles/1966/an-ini-file-handling-class-using-c?fid=425860&df=90&mpp=25&prof=True&sort=Position&view=Normal&spc=Relaxed&fr=51
|
||||
|
||||
[DllImport("kernel32")]
|
||||
private static extern long WritePrivateProfileString(string section,
|
||||
string key, string val, string filePath);
|
||||
[DllImport("kernel32")]
|
||||
private static extern int GetPrivateProfileString(string section,
|
||||
string key, string def, StringBuilder retVal,
|
||||
int size, string filePath);
|
||||
public class INIFile
|
||||
{
|
||||
public string path;
|
||||
|
||||
/// <summary>
|
||||
/// INIFile Constructor.
|
||||
/// </summary>
|
||||
/// <PARAM name="INIPath"></PARAM>
|
||||
public INIFile(string INIPath)
|
||||
{
|
||||
path = INIPath;
|
||||
}
|
||||
/// <summary>
|
||||
/// Write Data to the INI File
|
||||
/// </summary>
|
||||
/// <PARAM name="Section"></PARAM>
|
||||
/// Section name
|
||||
/// <PARAM name="Key"></PARAM>
|
||||
/// Key Name
|
||||
/// <PARAM name="Value"></PARAM>
|
||||
/// Value Name
|
||||
public void IniWriteValue(string Section, string Key, string Value)
|
||||
{
|
||||
WritePrivateProfileString(Section, Key, Value, path);
|
||||
}
|
||||
[DllImport("kernel32")]
|
||||
private static extern long WritePrivateProfileString(string section,
|
||||
string key, string val, string filePath);
|
||||
[DllImport("kernel32")]
|
||||
private static extern int GetPrivateProfileString(string section,
|
||||
string key, string def, StringBuilder retVal,
|
||||
int size, string filePath);
|
||||
|
||||
/// <summary>
|
||||
/// Read Data Value From the Ini File
|
||||
/// </summary>
|
||||
/// <PARAM name="Section"></PARAM>
|
||||
/// <PARAM name="Key"></PARAM>
|
||||
/// <PARAM name="Default Value. Optional for creating values in case they are invalid."></PARAM>
|
||||
/// <returns></returns>
|
||||
public string IniReadValue(string Section, string Key, string DefaultValue = "")
|
||||
{
|
||||
if (IniValueExists(Key))
|
||||
/// <summary>
|
||||
/// INIFile Constructor.
|
||||
/// </summary>
|
||||
/// <PARAM name="INIPath"></PARAM>
|
||||
public INIFile(string INIPath)
|
||||
{
|
||||
StringBuilder temp = new StringBuilder(255);
|
||||
int i = GetPrivateProfileString(Section, Key, "", temp,
|
||||
255, path);
|
||||
return temp.ToString();
|
||||
path = INIPath;
|
||||
}
|
||||
else
|
||||
/// <summary>
|
||||
/// Write Data to the INI File
|
||||
/// </summary>
|
||||
/// <PARAM name="Section"></PARAM>
|
||||
/// Section name
|
||||
/// <PARAM name="Key"></PARAM>
|
||||
/// Key Name
|
||||
/// <PARAM name="Value"></PARAM>
|
||||
/// Value Name
|
||||
public void IniWriteValue(string Section, string Key, string Value)
|
||||
{
|
||||
IniWriteValue(Section, Key, DefaultValue);
|
||||
return DefaultValue;
|
||||
WritePrivateProfileString(Section, Key, Value, path);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IniValueExists(string SearchString)
|
||||
{
|
||||
try
|
||||
/// <summary>
|
||||
/// Read Data Value From the Ini File
|
||||
/// </summary>
|
||||
/// <PARAM name="Section"></PARAM>
|
||||
/// <PARAM name="Key"></PARAM>
|
||||
/// <PARAM name="Default Value. Optional for creating values in case they are invalid."></PARAM>
|
||||
/// <returns></returns>
|
||||
public string IniReadValue(string Section, string Key, string DefaultValue = "")
|
||||
{
|
||||
if (File.Exists(path))
|
||||
if (IniValueExists(Key))
|
||||
{
|
||||
string[] lines = File.ReadAllLines(path);
|
||||
StringBuilder temp = new StringBuilder(255);
|
||||
int i = GetPrivateProfileString(Section, Key, "", temp,
|
||||
255, path);
|
||||
return temp.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
IniWriteValue(Section, Key, DefaultValue);
|
||||
return DefaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string line in lines)
|
||||
public bool IniValueExists(string SearchString)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
if (line.Contains(SearchString))
|
||||
string[] lines = File.ReadAllLines(path);
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
return true;
|
||||
if (line.Contains(SearchString))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#if URI || LAUNCHER || BASICLAUNCHER
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.LogExceptions(ex);
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.LogExceptions(ex);
|
||||
#else
|
||||
catch (Exception)
|
||||
{
|
||||
#endif
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -0,0 +1,111 @@
|
|||
#region Usings
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Microsoft.CSharp;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
// based on https://stackoverflow.com/questions/137933/what-is-the-best-scripting-language-to-embed-in-a-c-sharp-desktop-application
|
||||
namespace Novetus.Core
|
||||
{
|
||||
#region Script
|
||||
public class Script
|
||||
{
|
||||
public static object LoadScriptFromContent(string scriptPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var stream = File.OpenRead(scriptPath))
|
||||
{
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
string script = reader.ReadToEnd();
|
||||
Assembly compiled = CompileScript(script, scriptPath);
|
||||
object code = ExecuteScript(compiled, scriptPath);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrorHandler(scriptPath + ": " + ex.ToString(), true);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static object ExecuteScript(Assembly assemblyScript, string filePath)
|
||||
{
|
||||
if (assemblyScript == null)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
foreach (Type type in assemblyScript.GetExportedTypes())
|
||||
{
|
||||
if (type.IsInterface || type.IsAbstract)
|
||||
continue;
|
||||
|
||||
ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes);
|
||||
|
||||
if (constructor != null && constructor.IsPublic)
|
||||
{
|
||||
return constructor.Invoke(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorHandler(filePath + ": Constructor does not exist or it is not public.", true);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
error:
|
||||
ErrorHandler(filePath + ": Failed to load script.", true);
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Assembly CompileScript(string code, string filePath)
|
||||
{
|
||||
CSharpCodeProvider provider = new CSharpCodeProvider();
|
||||
|
||||
CompilerParameters perams = new CompilerParameters();
|
||||
perams.GenerateExecutable = false;
|
||||
perams.GenerateInMemory = true;
|
||||
|
||||
var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => !a.IsDynamic).Select(a => a.Location);
|
||||
perams.ReferencedAssemblies.AddRange(assemblies.ToArray());
|
||||
|
||||
CompilerResults result = provider.CompileAssemblyFromSource(perams, code);
|
||||
|
||||
foreach (CompilerError error in result.Errors)
|
||||
{
|
||||
ErrorHandler(error, filePath, error.IsWarning, false);
|
||||
}
|
||||
|
||||
if (result.Errors.HasErrors)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return result.CompiledAssembly;
|
||||
}
|
||||
|
||||
public static void ErrorHandler(string error, bool finalError = false)
|
||||
{
|
||||
ErrorHandler(error, false, finalError);
|
||||
}
|
||||
|
||||
private static void ErrorHandler(string error, bool warning, bool finalError)
|
||||
{
|
||||
Util.ConsolePrint(warning ? "[SCRIPT WARNING] - " : "[SCRIPT ERROR] - " + error, warning ? 5 : 2);
|
||||
}
|
||||
|
||||
private static void ErrorHandler(CompilerError error, string fileName, bool warning, bool finalError)
|
||||
{
|
||||
Util.ConsolePrint(warning ? "[SCRIPT WARNING] - " : "[SCRIPT ERROR] - " + fileName + " (" + error.Line + "," + error.Column + "): " + error.ErrorText, warning ? 5 : 2);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
@ -4,100 +4,103 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
#endregion
|
||||
|
||||
#region Text Line Remover and Friends
|
||||
// modified from https://stackoverflow.com/questions/668907/how-to-delete-a-line-from-a-text-file-in-c/668914#668914
|
||||
|
||||
public static class TextLineRemover
|
||||
namespace Novetus.Core
|
||||
{
|
||||
public static void RemoveTextLines(IList<string> linesToRemove, string filename, string tempFilename)
|
||||
{
|
||||
// Initial values
|
||||
int lineNumber = 0;
|
||||
int linesRemoved = 0;
|
||||
DateTime startTime = DateTime.Now;
|
||||
#region Text Line Remover and Friends
|
||||
// modified from https://stackoverflow.com/questions/668907/how-to-delete-a-line-from-a-text-file-in-c/668914#668914
|
||||
|
||||
// Read file
|
||||
using (var sr = new StreamReader(filename))
|
||||
public static class TextLineRemover
|
||||
{
|
||||
public static void RemoveTextLines(IList<string> linesToRemove, string filename, string tempFilename)
|
||||
{
|
||||
// Write new file
|
||||
using (var sw = new StreamWriter(tempFilename))
|
||||
// Initial values
|
||||
int lineNumber = 0;
|
||||
int linesRemoved = 0;
|
||||
DateTime startTime = DateTime.Now;
|
||||
|
||||
// Read file
|
||||
using (var sr = new StreamReader(filename))
|
||||
{
|
||||
// Read lines
|
||||
string line;
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
// Write new file
|
||||
using (var sw = new StreamWriter(tempFilename))
|
||||
{
|
||||
lineNumber++;
|
||||
// Look for text to remove
|
||||
if (!ContainsString(line, linesToRemove))
|
||||
// Read lines
|
||||
string line;
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
{
|
||||
// Keep lines that does not match
|
||||
sw.WriteLine(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore lines that DO match
|
||||
linesRemoved++;
|
||||
InvokeOnRemovedLine(new RemovedLineArgs
|
||||
lineNumber++;
|
||||
// Look for text to remove
|
||||
if (!ContainsString(line, linesToRemove))
|
||||
{
|
||||
RemovedLine = line,
|
||||
RemovedLineNumber = lineNumber
|
||||
});
|
||||
// Keep lines that does not match
|
||||
sw.WriteLine(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore lines that DO match
|
||||
linesRemoved++;
|
||||
InvokeOnRemovedLine(new RemovedLineArgs
|
||||
{
|
||||
RemovedLine = line,
|
||||
RemovedLineNumber = lineNumber
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//FixedFileMove deletes the original file and moves the temp file in.
|
||||
Util.FixedFileMove(tempFilename, filename, true);
|
||||
|
||||
// Final calculations
|
||||
DateTime endTime = DateTime.Now;
|
||||
InvokeOnFinished(new FinishedArgs
|
||||
{
|
||||
LinesRemoved = linesRemoved,
|
||||
TotalLines = lineNumber,
|
||||
TotalTime = endTime.Subtract(startTime)
|
||||
});
|
||||
}
|
||||
|
||||
//FixedFileMove deletes the original file and moves the temp file in.
|
||||
Util.FixedFileMove(tempFilename, filename, true);
|
||||
|
||||
// Final calculations
|
||||
DateTime endTime = DateTime.Now;
|
||||
InvokeOnFinished(new FinishedArgs
|
||||
private static bool ContainsString(string line, IEnumerable<string> linesToRemove)
|
||||
{
|
||||
LinesRemoved = linesRemoved,
|
||||
TotalLines = lineNumber,
|
||||
TotalTime = endTime.Subtract(startTime)
|
||||
});
|
||||
}
|
||||
|
||||
private static bool ContainsString(string line, IEnumerable<string> linesToRemove)
|
||||
{
|
||||
foreach (var lineToRemove in linesToRemove)
|
||||
{
|
||||
if (line.Contains(lineToRemove))
|
||||
return true;
|
||||
foreach (var lineToRemove in linesToRemove)
|
||||
{
|
||||
if (line.Contains(lineToRemove))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static event RemovedLine OnRemovedLine;
|
||||
public static event Finished OnFinished;
|
||||
|
||||
public static void InvokeOnFinished(FinishedArgs args)
|
||||
{
|
||||
OnFinished?.Invoke(null, args);
|
||||
}
|
||||
|
||||
public static void InvokeOnRemovedLine(RemovedLineArgs args)
|
||||
{
|
||||
OnRemovedLine?.Invoke(null, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static event RemovedLine OnRemovedLine;
|
||||
public static event Finished OnFinished;
|
||||
public delegate void Finished(object sender, FinishedArgs args);
|
||||
|
||||
public static void InvokeOnFinished(FinishedArgs args)
|
||||
public struct FinishedArgs
|
||||
{
|
||||
OnFinished?.Invoke(null, args);
|
||||
public int TotalLines { get; set; }
|
||||
public int LinesRemoved { get; set; }
|
||||
public TimeSpan TotalTime { get; set; }
|
||||
}
|
||||
|
||||
public static void InvokeOnRemovedLine(RemovedLineArgs args)
|
||||
public delegate void RemovedLine(object sender, RemovedLineArgs args);
|
||||
|
||||
public struct RemovedLineArgs
|
||||
{
|
||||
OnRemovedLine?.Invoke(null, args);
|
||||
public string RemovedLine { get; set; }
|
||||
public int RemovedLineNumber { get; set; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public delegate void Finished(object sender, FinishedArgs args);
|
||||
|
||||
public struct FinishedArgs
|
||||
{
|
||||
public int TotalLines { get; set; }
|
||||
public int LinesRemoved { get; set; }
|
||||
public TimeSpan TotalTime { get; set; }
|
||||
}
|
||||
|
||||
public delegate void RemovedLine(object sender, RemovedLineArgs args);
|
||||
|
||||
public struct RemovedLineArgs
|
||||
{
|
||||
public string RemovedLine { get; set; }
|
||||
public int RemovedLineNumber { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@ using System.IO;
|
|||
using System.Runtime.InteropServices;
|
||||
#endregion
|
||||
|
||||
|
||||
//https://github.com/davcs86/csharp-uhwid
|
||||
//merged into one class
|
||||
namespace UHWID
|
||||
namespace Novetus.Core
|
||||
{
|
||||
#region UHWIDEngine
|
||||
public static class UHWIDEngine
|
||||
|
|
|
|||
|
|
@ -12,162 +12,268 @@ using Titanium.Web.Proxy.EventArguments;
|
|||
using Titanium.Web.Proxy.Http;
|
||||
using Titanium.Web.Proxy.Models;
|
||||
|
||||
public class WebProxy
|
||||
namespace Novetus.Core
|
||||
{
|
||||
private static ProxyServer Server = new ProxyServer();
|
||||
private static ExplicitProxyEndPoint end;
|
||||
|
||||
public bool HasStarted()
|
||||
public class IWebProxyExtension
|
||||
{
|
||||
return Server.ProxyRunning;
|
||||
public virtual string Name { get; set; } = "Unnamed Web Proxy Extension";
|
||||
public virtual void OnExtensionLoad() { }
|
||||
public virtual void OnProxyStart() { }
|
||||
public virtual void OnProxyStopped() { }
|
||||
|
||||
public virtual bool IsValidURL(string absolutePath, string host) { return false; }
|
||||
|
||||
public virtual Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e) { return Task.CompletedTask; }
|
||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||
public virtual async Task OnRequest(object sender, SessionEventArgs e) { }
|
||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||
}
|
||||
|
||||
public void DoSetup()
|
||||
public class WebProxy
|
||||
{
|
||||
if (GlobalVars.UserConfiguration.WebProxyInitialSetupRequired)
|
||||
private static List<IWebProxyExtension> ExtensionList = new List<IWebProxyExtension>();
|
||||
private static ProxyServer Server = new ProxyServer();
|
||||
private static ExplicitProxyEndPoint end;
|
||||
|
||||
public void LoadExtensions()
|
||||
{
|
||||
string text = "Would you like to enable the Novetus web proxy?\n\n" +
|
||||
"A web proxy redirects web traffic to a different location and in some cases can act as a gateway to different sites. Novetus uses the web proxy for additional client features and asset redirection.\n\n" +
|
||||
"When enabling the web proxy, Novetus will locally create a certificate upon startup that ensures the proxy's functionality. Novetus will not send any user data to anyone, as everything involving the web proxy is entirely local to this computer.\n" +
|
||||
"If you have any issue connecting to other web sites, including Roblox, closing Novetus or typing 'proxy off' into Novetus' console will fix it in most instances.\n\n" +
|
||||
"Upon pressing 'Yes', Windows will ask you for permission to install the certificate.\n\n" +
|
||||
"You can change this option at any time by typing 'proxy disable' or 'proxy on' in the Novetus console. This message will appear only once.\n";
|
||||
string nothingFoundError = "No extensions found. The Web Proxy will run with limited functionality.";
|
||||
|
||||
DialogResult result = MessageBox.Show(text, "Novetus - Web Proxy Opt-In", MessageBoxButtons.YesNo);
|
||||
|
||||
switch (result)
|
||||
if (!Directory.Exists(GlobalPaths.NovetusExtsWebProxy))
|
||||
{
|
||||
case DialogResult.Yes:
|
||||
GlobalVars.UserConfiguration.WebProxyEnabled = true;
|
||||
Util.ConsolePrint(nothingFoundError, 5);
|
||||
return;
|
||||
}
|
||||
|
||||
// load up all .cs files.
|
||||
string[] filePaths = Directory.GetFiles(GlobalPaths.NovetusExtsWebProxy, "*.cs", SearchOption.TopDirectoryOnly);
|
||||
|
||||
if (filePaths.Count() == 0)
|
||||
{
|
||||
Util.ConsolePrint(nothingFoundError, 5);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string file in filePaths)
|
||||
{
|
||||
try
|
||||
{
|
||||
IWebProxyExtension newExt = (IWebProxyExtension)Script.LoadScriptFromContent(file);
|
||||
ExtensionList.Add(newExt);
|
||||
Util.ConsolePrint("Web Proxy: Loaded extension " + newExt.Name + " from " + Path.GetFileName(file), 3);
|
||||
newExt.OnExtensionLoad();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Util.LogExceptions(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasStarted()
|
||||
{
|
||||
return Server.ProxyRunning;
|
||||
}
|
||||
|
||||
public void DoSetup()
|
||||
{
|
||||
if (GlobalVars.UserConfiguration.WebProxyInitialSetupRequired)
|
||||
{
|
||||
string text = "Would you like to enable the Novetus web proxy?\n\n" +
|
||||
"A web proxy redirects web traffic to a different location and in some cases can act as a gateway to different sites. Novetus uses the web proxy for additional client features and asset redirection.\n\n" +
|
||||
"When enabling the web proxy, Novetus will locally create a certificate upon startup that ensures the proxy's functionality. Novetus will not send any user data to anyone, as everything involving the web proxy is entirely local to this computer.\n" +
|
||||
"If you have any issue connecting to other web sites, including Roblox, closing Novetus or typing 'proxy off' into Novetus' console will fix it in most instances.\n\n" +
|
||||
"Upon pressing 'Yes', Windows will ask you for permission to install the certificate.\n\n" +
|
||||
"You can change this option at any time by typing 'proxy disable' or 'proxy on' in the Novetus console. This message will appear only once.\n";
|
||||
|
||||
DialogResult result = MessageBox.Show(text, "Novetus - Web Proxy Opt-In", MessageBoxButtons.YesNo);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case DialogResult.Yes:
|
||||
GlobalVars.UserConfiguration.WebProxyEnabled = true;
|
||||
Start();
|
||||
break;
|
||||
case DialogResult.No:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
GlobalVars.UserConfiguration.WebProxyInitialSetupRequired = false;
|
||||
FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GlobalVars.UserConfiguration.WebProxyEnabled)
|
||||
{
|
||||
Start();
|
||||
break;
|
||||
case DialogResult.No:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GlobalVars.UserConfiguration.WebProxyInitialSetupRequired = false;
|
||||
FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, true);
|
||||
}
|
||||
else
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (GlobalVars.UserConfiguration.WebProxyEnabled)
|
||||
try
|
||||
{
|
||||
Start();
|
||||
LoadExtensions();
|
||||
Server.CertificateManager.RootCertificateIssuerName = "Novetus";
|
||||
Server.CertificateManager.RootCertificateName = "Novetus Web Proxy";
|
||||
Server.BeforeRequest += new AsyncEventHandler<SessionEventArgs>(OnRequest);
|
||||
UpdateEndPoint(true);
|
||||
Util.ConsolePrint("Web Proxy started on port " + GlobalVars.WebProxyPort, 3);
|
||||
foreach (IWebProxyExtension extension in ExtensionList.ToArray())
|
||||
{
|
||||
extension.OnProxyStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
try
|
||||
{
|
||||
//load ext
|
||||
Server.CertificateManager.RootCertificateIssuerName = "Novetus";
|
||||
Server.CertificateManager.RootCertificateName = "Novetus Web Proxy";
|
||||
Server.BeforeRequest += new AsyncEventHandler<SessionEventArgs>(OnRequest);
|
||||
UpdateEndPoint(true);
|
||||
Util.ConsolePrint("Web Proxy started on port " + GlobalVars.WebProxyPort, 3);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Util.LogExceptions(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateEndPoint(bool shouldRunServer = false, bool decrypt = true)
|
||||
{
|
||||
if (Server.ProxyEndPoints.Count > 0)
|
||||
{
|
||||
Server.RemoveEndPoint(end);
|
||||
}
|
||||
|
||||
GlobalVars.WebProxyPort = GlobalVars.UserConfiguration.RobloxPort + 1;
|
||||
end = new ExplicitProxyEndPoint(IPAddress.Any, GlobalVars.WebProxyPort, decrypt);
|
||||
end.BeforeTunnelConnectRequest += new AsyncEventHandler<TunnelConnectSessionEventArgs>(OnBeforeTunnelConnectRequest);
|
||||
Server.AddEndPoint(end);
|
||||
|
||||
if (!Server.ProxyRunning && shouldRunServer)
|
||||
{
|
||||
Server.Start();
|
||||
}
|
||||
|
||||
if (Server.ProxyRunning)
|
||||
{
|
||||
foreach (ProxyEndPoint endPoint in Server.ProxyEndPoints)
|
||||
catch (Exception e)
|
||||
{
|
||||
Server.SetAsSystemHttpProxy(end);
|
||||
Server.SetAsSystemHttpsProxy(end);
|
||||
Util.LogExceptions(e);
|
||||
}
|
||||
}
|
||||
|
||||
Util.ConsolePrint("Web Proxy Endpoint updated with port " + GlobalVars.WebProxyPort, 3);
|
||||
}
|
||||
|
||||
private bool IsURIAllowed(HttpWebClient client)
|
||||
{
|
||||
string uri = client.Request.RequestUri.Host;
|
||||
|
||||
if ((!uri.StartsWith("www.") &&
|
||||
!uri.StartsWith("web.") &&
|
||||
!uri.StartsWith("assetgame.") &&
|
||||
!uri.StartsWith("wiki.") &&
|
||||
!uri.EndsWith("api.roblox.com") &&
|
||||
!uri.StartsWith("roblox.com") || !uri.EndsWith("roblox.com")) &&
|
||||
!uri.EndsWith("robloxlabs.com"))
|
||||
public void UpdateEndPoint(bool shouldRunServer = false, bool decrypt = true)
|
||||
{
|
||||
return false;
|
||||
if (Server.ProxyEndPoints.Count > 0)
|
||||
{
|
||||
Server.RemoveEndPoint(end);
|
||||
}
|
||||
|
||||
GlobalVars.WebProxyPort = GlobalVars.UserConfiguration.RobloxPort + 1;
|
||||
end = new ExplicitProxyEndPoint(IPAddress.Any, GlobalVars.WebProxyPort, decrypt);
|
||||
end.BeforeTunnelConnectRequest += new AsyncEventHandler<TunnelConnectSessionEventArgs>(OnBeforeTunnelConnectRequest);
|
||||
Server.AddEndPoint(end);
|
||||
|
||||
if (!Server.ProxyRunning && shouldRunServer)
|
||||
{
|
||||
Server.Start();
|
||||
}
|
||||
|
||||
if (Server.ProxyRunning)
|
||||
{
|
||||
foreach (ProxyEndPoint endPoint in Server.ProxyEndPoints)
|
||||
{
|
||||
Server.SetAsSystemHttpProxy(end);
|
||||
Server.SetAsSystemHttpsProxy(end);
|
||||
}
|
||||
}
|
||||
|
||||
Util.ConsolePrint("Web Proxy Endpoint updated with port " + GlobalVars.WebProxyPort, 3);
|
||||
}
|
||||
|
||||
//we check the header
|
||||
HeaderCollection headers = client.Request.Headers;
|
||||
List<HttpHeader> userAgents = headers.GetHeaders("User-Agent");
|
||||
|
||||
if (userAgents == null)
|
||||
return false;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(userAgents.FirstOrDefault().Value))
|
||||
return false;
|
||||
|
||||
string ua = userAgents.FirstOrDefault().Value.ToLowerInvariant();
|
||||
|
||||
//for some reason, this doesn't go through for the browser unless we look for mozilla/4.0.
|
||||
//this shouldn't break modern mozilla browsers though.
|
||||
return (ua.Contains("mozilla/4.0") || ua.Contains("roblox"));
|
||||
}
|
||||
|
||||
private Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
|
||||
{
|
||||
if (!IsURIAllowed(e.HttpClient))
|
||||
private bool IsValidURL(HttpWebClient client)
|
||||
{
|
||||
e.DecryptSsl = false;
|
||||
string uri = client.Request.RequestUri.Host;
|
||||
|
||||
if ((!uri.StartsWith("www.") &&
|
||||
!uri.StartsWith("web.") &&
|
||||
!uri.StartsWith("assetgame.") &&
|
||||
!uri.StartsWith("wiki.") &&
|
||||
!uri.EndsWith("api.roblox.com") &&
|
||||
!uri.StartsWith("roblox.com") || !uri.EndsWith("roblox.com")) &&
|
||||
!uri.EndsWith("robloxlabs.com"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//we check the header
|
||||
HeaderCollection headers = client.Request.Headers;
|
||||
List<HttpHeader> userAgents = headers.GetHeaders("User-Agent");
|
||||
|
||||
if (userAgents == null)
|
||||
return false;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(userAgents.FirstOrDefault().Value))
|
||||
return false;
|
||||
|
||||
string ua = userAgents.FirstOrDefault().Value.ToLowerInvariant();
|
||||
|
||||
//for some reason, this doesn't go through for the browser unless we look for mozilla/4.0.
|
||||
//this shouldn't break modern mozilla browsers though.
|
||||
return (ua.Contains("mozilla/4.0") || ua.Contains("roblox"));
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
|
||||
{
|
||||
if (!IsValidURL(e.HttpClient))
|
||||
{
|
||||
e.DecryptSsl = false;
|
||||
}
|
||||
|
||||
Uri uri = e.HttpClient.Request.RequestUri;
|
||||
|
||||
foreach (IWebProxyExtension extension in ExtensionList.ToArray())
|
||||
{
|
||||
if (extension.IsValidURL(uri.AbsolutePath.ToLowerInvariant(), uri.Host))
|
||||
{
|
||||
try
|
||||
{
|
||||
extension.OnBeforeTunnelConnectRequest(sender, e);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.LogExceptions(ex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
e.DecryptSsl = false;
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||
private async Task OnRequest(object sender, SessionEventArgs e)
|
||||
private async Task OnRequest(object sender, SessionEventArgs e)
|
||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||
{
|
||||
if (!IsURIAllowed(e.HttpClient))
|
||||
{
|
||||
return;
|
||||
if (!IsValidURL(e.HttpClient))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Uri uri = e.HttpClient.Request.RequestUri;
|
||||
|
||||
foreach (IWebProxyExtension extension in ExtensionList.ToArray())
|
||||
{
|
||||
if (extension.IsValidURL(uri.AbsolutePath.ToLowerInvariant(), uri.Host))
|
||||
{
|
||||
try
|
||||
{
|
||||
await extension.OnRequest(sender, e);
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.LogExceptions(ex);
|
||||
e.GenericResponse("", HttpStatusCode.InternalServerError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e.GenericResponse("", HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
e.GenericResponse("", HttpStatusCode.NotFound);
|
||||
public void Stop()
|
||||
{
|
||||
Util.ConsolePrint("Web Proxy stopping on port " + GlobalVars.WebProxyPort, 3);
|
||||
Server.BeforeRequest -= new AsyncEventHandler<SessionEventArgs>(OnRequest);
|
||||
Server.Stop();
|
||||
|
||||
foreach (IWebProxyExtension extension in ExtensionList.ToArray())
|
||||
{
|
||||
try
|
||||
{
|
||||
extension.OnProxyStopped();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Util.LogExceptions(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
Util.ConsolePrint("Web Proxy stopping on port " + GlobalVars.WebProxyPort, 3);
|
||||
Server.BeforeRequest -= new AsyncEventHandler<SessionEventArgs>(OnRequest);
|
||||
Server.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
public interface IWebProxyExtention
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
<Import_RootNamespace>NovetusCore</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\Script.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\WebProxy.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\ClientManagement.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\Downloader.cs" />
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -3,116 +3,121 @@ using System.IO;
|
|||
using System.Reflection;
|
||||
#endregion
|
||||
|
||||
#region Global Paths
|
||||
|
||||
public class GlobalPaths
|
||||
namespace Novetus.Core
|
||||
{
|
||||
#region Base Game Paths
|
||||
public static readonly string RootPathLauncher = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
public static readonly string BasePathLauncher = RootPathLauncher.Replace(@"\", @"\\");
|
||||
public static readonly string RootPath = Directory.GetParent(RootPathLauncher).ToString();
|
||||
public static readonly string BasePath = RootPath.Replace(@"\", @"\\");
|
||||
public static readonly string DataPath = BasePath + @"\\shareddata";
|
||||
public static readonly string BinDir = BasePath + @"\\bin";
|
||||
public static readonly string ConfigDir = BasePath + @"\\config";
|
||||
public static readonly string LogDir = BasePath + @"\\logs";
|
||||
public static readonly string ConfigDirClients = ConfigDir + @"\\clients";
|
||||
public static readonly string ConfigDirTemplates = ConfigDir + @"\\itemtemplates";
|
||||
public static readonly string DataDir = BinDir + @"\\data";
|
||||
public static readonly string ClientDir = BasePath + @"\\clients";
|
||||
public static readonly string MapsDir = BasePath + @"\\maps";
|
||||
public static readonly string AddonDir = BasePath + @"\\addons";
|
||||
public static readonly string AddonCoreDir = AddonDir + @"\\core";
|
||||
public static readonly string MapsDirCustom = MapsDir + @"\\Custom";
|
||||
public static readonly string MapsDirBase = "maps";
|
||||
public static readonly string BaseGameDir = "rbxasset://../../../";
|
||||
public static readonly string AltBaseGameDir = "rbxasset://";
|
||||
public static readonly string SharedDataGameDir = BaseGameDir + "shareddata/";
|
||||
#endregion
|
||||
#region Global Paths
|
||||
|
||||
#region Customization Paths
|
||||
public static readonly string CustomPlayerDir = DataPath + "\\charcustom";
|
||||
public static readonly string hatdir = CustomPlayerDir + "\\hats";
|
||||
public static readonly string facedir = CustomPlayerDir + "\\faces";
|
||||
public static readonly string headdir = CustomPlayerDir + "\\heads";
|
||||
public static readonly string tshirtdir = CustomPlayerDir + "\\tshirts";
|
||||
public static readonly string shirtdir = CustomPlayerDir + "\\shirts";
|
||||
public static readonly string pantsdir = CustomPlayerDir + "\\pants";
|
||||
public static readonly string extradir = CustomPlayerDir + "\\custom";
|
||||
public static readonly string extradirIcons = extradir + "\\icons";
|
||||
public class GlobalPaths
|
||||
{
|
||||
#region Base Game Paths
|
||||
public static readonly string RootPathLauncher = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
public static readonly string BasePathLauncher = RootPathLauncher.Replace(@"\", @"\\");
|
||||
public static readonly string RootPath = Directory.GetParent(RootPathLauncher).ToString();
|
||||
public static readonly string BasePath = RootPath.Replace(@"\", @"\\");
|
||||
public static readonly string DataPath = BasePath + @"\\shareddata";
|
||||
public static readonly string BinDir = BasePath + @"\\bin";
|
||||
public static readonly string ConfigDir = BasePath + @"\\config";
|
||||
public static readonly string LogDir = BasePath + @"\\logs";
|
||||
public static readonly string ConfigDirClients = ConfigDir + @"\\clients";
|
||||
public static readonly string ConfigDirTemplates = ConfigDir + @"\\itemtemplates";
|
||||
public static readonly string DataDir = BinDir + @"\\data";
|
||||
public static readonly string ClientDir = BasePath + @"\\clients";
|
||||
public static readonly string MapsDir = BasePath + @"\\maps";
|
||||
public static readonly string AddonDir = BasePath + @"\\addons";
|
||||
public static readonly string AddonCoreDir = AddonDir + @"\\core";
|
||||
public static readonly string AddonNovetusExts = AddonDir + @"\\novetusexts";
|
||||
public static readonly string NovetusExtsWebProxy = AddonNovetusExts + @"\\webproxy";
|
||||
public static readonly string MapsDirCustom = MapsDir + @"\\Custom";
|
||||
public static readonly string MapsDirBase = "maps";
|
||||
public static readonly string BaseGameDir = "rbxasset://../../../";
|
||||
public static readonly string AltBaseGameDir = "rbxasset://";
|
||||
public static readonly string SharedDataGameDir = BaseGameDir + "shareddata/";
|
||||
#endregion
|
||||
|
||||
public static readonly string CharCustomGameDir = SharedDataGameDir + "charcustom/";
|
||||
public static readonly string hatGameDir = CharCustomGameDir + "hats/";
|
||||
public static readonly string faceGameDir = CharCustomGameDir + "faces/";
|
||||
public static readonly string headGameDir = CharCustomGameDir + "heads/";
|
||||
public static readonly string tshirtGameDir = CharCustomGameDir + "tshirts/";
|
||||
public static readonly string shirtGameDir = CharCustomGameDir + "shirts/";
|
||||
public static readonly string pantsGameDir = CharCustomGameDir + "pants/";
|
||||
public static readonly string extraGameDir = CharCustomGameDir + "custom/";
|
||||
#endregion
|
||||
#region Customization Paths
|
||||
public static readonly string CustomPlayerDir = DataPath + "\\charcustom";
|
||||
public static readonly string hatdir = CustomPlayerDir + "\\hats";
|
||||
public static readonly string facedir = CustomPlayerDir + "\\faces";
|
||||
public static readonly string headdir = CustomPlayerDir + "\\heads";
|
||||
public static readonly string tshirtdir = CustomPlayerDir + "\\tshirts";
|
||||
public static readonly string shirtdir = CustomPlayerDir + "\\shirts";
|
||||
public static readonly string pantsdir = CustomPlayerDir + "\\pants";
|
||||
public static readonly string extradir = CustomPlayerDir + "\\custom";
|
||||
public static readonly string extradirIcons = extradir + "\\icons";
|
||||
|
||||
#region Asset Cache Paths
|
||||
public static readonly string CharCustomGameDir = SharedDataGameDir + "charcustom/";
|
||||
public static readonly string hatGameDir = CharCustomGameDir + "hats/";
|
||||
public static readonly string faceGameDir = CharCustomGameDir + "faces/";
|
||||
public static readonly string headGameDir = CharCustomGameDir + "heads/";
|
||||
public static readonly string tshirtGameDir = CharCustomGameDir + "tshirts/";
|
||||
public static readonly string shirtGameDir = CharCustomGameDir + "shirts/";
|
||||
public static readonly string pantsGameDir = CharCustomGameDir + "pants/";
|
||||
public static readonly string extraGameDir = CharCustomGameDir + "custom/";
|
||||
#endregion
|
||||
|
||||
#region Base Paths
|
||||
public static readonly string DirFonts = "\\fonts";
|
||||
public static readonly string DirSounds = "\\sounds";
|
||||
public static readonly string DirTextures = "\\textures";
|
||||
public static readonly string DirScripts = "\\scripts";
|
||||
public static readonly string FontsGameDir = "fonts/";
|
||||
public static readonly string SoundsGameDir = "sounds/";
|
||||
public static readonly string TexturesGameDir = "textures/";
|
||||
public static readonly string ScriptsGameDir = "scripts/";
|
||||
#endregion
|
||||
#region Asset Cache Paths
|
||||
|
||||
#region Asset Dirs
|
||||
public static string AssetCacheDir = DataPath + "\\assetcache";
|
||||
public static string AssetCacheDirAssets = AssetCacheDir + "\\assets";
|
||||
#region Base Paths
|
||||
public static readonly string DirFonts = "\\fonts";
|
||||
public static readonly string DirSounds = "\\sounds";
|
||||
public static readonly string DirTextures = "\\textures";
|
||||
public static readonly string DirScripts = "\\scripts";
|
||||
public static readonly string FontsGameDir = "fonts/";
|
||||
public static readonly string SoundsGameDir = "sounds/";
|
||||
public static readonly string TexturesGameDir = "textures/";
|
||||
public static readonly string ScriptsGameDir = "scripts/";
|
||||
#endregion
|
||||
|
||||
public static string AssetCacheGameDir = SharedDataGameDir + "assetcache/";
|
||||
public static string AssetCacheAssetsGameDir = AssetCacheGameDir + "assets/";
|
||||
#endregion
|
||||
#region Asset Dirs
|
||||
public static string AssetCacheDir = DataPath + "\\assetcache";
|
||||
public static string AssetCacheDirAssets = AssetCacheDir + "\\assets";
|
||||
|
||||
#region Item Dirs
|
||||
public static readonly string hatdirFonts = hatdir + DirFonts;
|
||||
public static readonly string hatdirTextures = hatdir + DirTextures;
|
||||
public static readonly string hatdirSounds = hatdir + DirSounds;
|
||||
public static readonly string hatdirScripts = hatdir + DirScripts;
|
||||
public static readonly string facedirTextures = facedir; //+ DirTextures;
|
||||
public static readonly string headdirFonts = headdir + DirFonts;
|
||||
public static readonly string headdirTextures = headdir + DirTextures;
|
||||
public static readonly string tshirtdirTextures = tshirtdir; //+ DirTextures;
|
||||
public static readonly string shirtdirTextures = shirtdir + DirTextures;
|
||||
public static readonly string pantsdirTextures = pantsdir + DirTextures;
|
||||
public static string AssetCacheGameDir = SharedDataGameDir + "assetcache/";
|
||||
public static string AssetCacheAssetsGameDir = AssetCacheGameDir + "assets/";
|
||||
#endregion
|
||||
|
||||
public static readonly string hatGameDirFonts = hatGameDir + FontsGameDir;
|
||||
public static readonly string hatGameDirTextures = hatGameDir + TexturesGameDir;
|
||||
public static readonly string hatGameDirSounds = hatGameDir + SoundsGameDir;
|
||||
public static readonly string hatGameDirScripts = hatGameDir + ScriptsGameDir;
|
||||
public static readonly string faceGameDirTextures = faceGameDir; //+ TexturesGameDir;
|
||||
public static readonly string headGameDirFonts = headGameDir + FontsGameDir;
|
||||
public static readonly string headGameDirTextures = headGameDir + TexturesGameDir;
|
||||
public static readonly string tshirtGameDirTextures = tshirtGameDir; //+ TexturesGameDir;
|
||||
public static readonly string shirtGameDirTextures = shirtGameDir + TexturesGameDir;
|
||||
public static readonly string pantsGameDirTextures = pantsGameDir + TexturesGameDir;
|
||||
#endregion
|
||||
#region Item Dirs
|
||||
public static readonly string hatdirFonts = hatdir + DirFonts;
|
||||
public static readonly string hatdirTextures = hatdir + DirTextures;
|
||||
public static readonly string hatdirSounds = hatdir + DirSounds;
|
||||
public static readonly string hatdirScripts = hatdir + DirScripts;
|
||||
public static readonly string facedirTextures = facedir; //+ DirTextures;
|
||||
public static readonly string headdirFonts = headdir + DirFonts;
|
||||
public static readonly string headdirTextures = headdir + DirTextures;
|
||||
public static readonly string tshirtdirTextures = tshirtdir; //+ DirTextures;
|
||||
public static readonly string shirtdirTextures = shirtdir + DirTextures;
|
||||
public static readonly string pantsdirTextures = pantsdir + DirTextures;
|
||||
|
||||
#endregion
|
||||
public static readonly string hatGameDirFonts = hatGameDir + FontsGameDir;
|
||||
public static readonly string hatGameDirTextures = hatGameDir + TexturesGameDir;
|
||||
public static readonly string hatGameDirSounds = hatGameDir + SoundsGameDir;
|
||||
public static readonly string hatGameDirScripts = hatGameDir + ScriptsGameDir;
|
||||
public static readonly string faceGameDirTextures = faceGameDir; //+ TexturesGameDir;
|
||||
public static readonly string headGameDirFonts = headGameDir + FontsGameDir;
|
||||
public static readonly string headGameDirTextures = headGameDir + TexturesGameDir;
|
||||
public static readonly string tshirtGameDirTextures = tshirtGameDir; //+ TexturesGameDir;
|
||||
public static readonly string shirtGameDirTextures = shirtGameDir + TexturesGameDir;
|
||||
public static readonly string pantsGameDirTextures = pantsGameDir + TexturesGameDir;
|
||||
#endregion
|
||||
|
||||
#region File Names
|
||||
public static readonly string ConfigName = "config.ini";
|
||||
public static string ConfigNameCustomization = "config_customization.ini";
|
||||
public static readonly string InfoName = "info.ini";
|
||||
public static readonly string ScriptName = "CSMPFunctions";
|
||||
public static readonly string ScriptGenName = "CSMPBoot";
|
||||
public static readonly string ContentProviderXMLName = "ContentProviders.xml";
|
||||
public static readonly string PartColorXMLName = "PartColors.xml";
|
||||
public static readonly string FileDeleteFilterName = "FileDeleteFilter.txt";
|
||||
public static readonly string InitialFileListIgnoreFilterName = "InitialFileListIgnoreFilter.txt";
|
||||
public static readonly string ServerInfoFileName = "serverinfo.txt";
|
||||
public static readonly string ConsoleHelpFileName = "consolehelp.txt";
|
||||
public static readonly string ClientScriptDocumentationFileName = "documentation.txt";
|
||||
public static readonly string AddonLoaderFileName = "AddonLoader.lua";
|
||||
public static readonly string AssetFixerPatternFileName = "assetfixer_pattern.txt";
|
||||
#endregion
|
||||
|
||||
#region File Names
|
||||
public static readonly string ConfigName = "config.ini";
|
||||
public static string ConfigNameCustomization = "config_customization.ini";
|
||||
public static readonly string InfoName = "info.ini";
|
||||
public static readonly string ScriptName = "CSMPFunctions";
|
||||
public static readonly string ScriptGenName = "CSMPBoot";
|
||||
public static readonly string ContentProviderXMLName = "ContentProviders.xml";
|
||||
public static readonly string PartColorXMLName = "PartColors.xml";
|
||||
public static readonly string FileDeleteFilterName = "FileDeleteFilter.txt";
|
||||
public static readonly string InitialFileListIgnoreFilterName = "InitialFileListIgnoreFilter.txt";
|
||||
public static readonly string ServerInfoFileName = "serverinfo.txt";
|
||||
public static readonly string ConsoleHelpFileName = "consolehelp.txt";
|
||||
public static readonly string ClientScriptDocumentationFileName = "documentation.txt";
|
||||
public static readonly string AddonLoaderFileName = "AddonLoader.lua";
|
||||
public static readonly string AssetFixerPatternFileName = "assetfixer_pattern.txt";
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -14,140 +14,143 @@ using System.Diagnostics;
|
|||
using System.Windows.Forms;
|
||||
#endregion
|
||||
|
||||
#region Script Type
|
||||
public enum ScriptType
|
||||
namespace Novetus.Core
|
||||
{
|
||||
Client = 0,
|
||||
Server = 1,
|
||||
Solo = 2,
|
||||
Studio = 3,
|
||||
EasterEgg = 4,
|
||||
None = 5
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Game Server Definition
|
||||
public class GameServer
|
||||
{
|
||||
public GameServer(string ip, int port)
|
||||
#region Script Type
|
||||
public enum ScriptType
|
||||
{
|
||||
ServerIP = ip;
|
||||
ServerPort = port;
|
||||
Client = 0,
|
||||
Server = 1,
|
||||
Solo = 2,
|
||||
Studio = 3,
|
||||
EasterEgg = 4,
|
||||
None = 5
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ServerIP + ":" + ServerPort.ToString();
|
||||
}
|
||||
|
||||
public void SetValues(string input)
|
||||
#region Game Server Definition
|
||||
public class GameServer
|
||||
{
|
||||
try
|
||||
public GameServer(string ip, int port)
|
||||
{
|
||||
string[] vals = input.Split(':');
|
||||
string ip = vals[0];
|
||||
int port = Convert.ToInt32(vals[1]);
|
||||
|
||||
ServerIP = ip;
|
||||
ServerPort = port;
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
ServerIP = input;
|
||||
ServerPort = GlobalVars.DefaultRobloxPort;
|
||||
return ServerIP + ":" + ServerPort.ToString();
|
||||
}
|
||||
|
||||
public void SetValues(string input)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] vals = input.Split(':');
|
||||
string ip = vals[0];
|
||||
int port = Convert.ToInt32(vals[1]);
|
||||
|
||||
ServerIP = ip;
|
||||
ServerPort = port;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ServerIP = input;
|
||||
ServerPort = GlobalVars.DefaultRobloxPort;
|
||||
}
|
||||
}
|
||||
|
||||
public string ServerIP { get; set; }
|
||||
public int ServerPort { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
public string ServerIP { get; set; }
|
||||
public int ServerPort { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Global Variables
|
||||
public static class GlobalVars
|
||||
{
|
||||
#region Discord
|
||||
public enum LauncherState
|
||||
#region Global Variables
|
||||
public static class GlobalVars
|
||||
{
|
||||
InLauncher = 0,
|
||||
InMPGame = 1,
|
||||
InSoloGame = 2,
|
||||
InStudio = 3,
|
||||
InCustomization = 4,
|
||||
InEasterEggGame = 5,
|
||||
LoadingURI = 6
|
||||
}
|
||||
#region Discord
|
||||
public enum LauncherState
|
||||
{
|
||||
InLauncher = 0,
|
||||
InMPGame = 1,
|
||||
InSoloGame = 2,
|
||||
InStudio = 3,
|
||||
InCustomization = 4,
|
||||
InEasterEggGame = 5,
|
||||
LoadingURI = 6
|
||||
}
|
||||
|
||||
public static DiscordRPC.EventHandlers handlers;
|
||||
#endregion
|
||||
public static DiscordRPC.EventHandlers handlers;
|
||||
#endregion
|
||||
|
||||
#region Class definitions
|
||||
public static FileFormat.ProgramInfo ProgramInformation = new FileFormat.ProgramInfo();
|
||||
public static FileFormat.Config UserConfiguration = new FileFormat.Config();
|
||||
public static FileFormat.ClientInfo SelectedClientInfo = new FileFormat.ClientInfo();
|
||||
public static FileFormat.CustomizationConfig UserCustomization = new FileFormat.CustomizationConfig();
|
||||
public static PartColor[] PartColorList;
|
||||
public static List<PartColor> PartColorListConv;
|
||||
#endregion
|
||||
#region Class definitions
|
||||
public static FileFormat.ProgramInfo ProgramInformation = new FileFormat.ProgramInfo();
|
||||
public static FileFormat.Config UserConfiguration = new FileFormat.Config();
|
||||
public static FileFormat.ClientInfo SelectedClientInfo = new FileFormat.ClientInfo();
|
||||
public static FileFormat.CustomizationConfig UserCustomization = new FileFormat.CustomizationConfig();
|
||||
public static PartColor[] PartColorList;
|
||||
public static List<PartColor> PartColorListConv;
|
||||
#endregion
|
||||
|
||||
#region Joining/Hosting
|
||||
public static string DefaultIP = "localhost";
|
||||
public static int DefaultRobloxPort = 53640;
|
||||
public static GameServer CurrentServer = new GameServer(DefaultIP, DefaultRobloxPort);
|
||||
public static string ExternalIP = SecurityFuncs.GetExternalIPAddress();
|
||||
public static ScriptType GameOpened = ScriptType.None;
|
||||
public static string PlayerTripcode = "";
|
||||
#region Joining/Hosting
|
||||
public static string DefaultIP = "localhost";
|
||||
public static int DefaultRobloxPort = 53640;
|
||||
public static GameServer CurrentServer = new GameServer(DefaultIP, DefaultRobloxPort);
|
||||
public static string ExternalIP = SecurityFuncs.GetExternalIPAddress();
|
||||
public static ScriptType GameOpened = ScriptType.None;
|
||||
public static string PlayerTripcode = "";
|
||||
#if LAUNCHER || URI
|
||||
public static int WebProxyPort = 0;
|
||||
public static WebProxy Proxy = new WebProxy();
|
||||
public static int WebProxyPort = 0;
|
||||
public static WebProxy Proxy = new WebProxy();
|
||||
#endif
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#if LAUNCHER
|
||||
#region Novetus Launcher
|
||||
#region Novetus Launcher
|
||||
public static NovetusLauncher.NovetusConsole consoleForm = null;
|
||||
#endregion
|
||||
#endregion
|
||||
#endif
|
||||
|
||||
#region Customization
|
||||
public static string Loadout = "";
|
||||
public static string soloLoadout = "";
|
||||
public static string TShirtTextureID = "";
|
||||
public static string ShirtTextureID = "";
|
||||
public static string PantsTextureID = "";
|
||||
public static string FaceTextureID = "";
|
||||
public static string TShirtTextureLocal = "";
|
||||
public static string ShirtTextureLocal = "";
|
||||
public static string PantsTextureLocal = "";
|
||||
public static string FaceTextureLocal = "";
|
||||
#endregion
|
||||
#region Customization
|
||||
public static string Loadout = "";
|
||||
public static string soloLoadout = "";
|
||||
public static string TShirtTextureID = "";
|
||||
public static string ShirtTextureID = "";
|
||||
public static string PantsTextureID = "";
|
||||
public static string FaceTextureID = "";
|
||||
public static string TShirtTextureLocal = "";
|
||||
public static string ShirtTextureLocal = "";
|
||||
public static string PantsTextureLocal = "";
|
||||
public static string FaceTextureLocal = "";
|
||||
#endregion
|
||||
|
||||
#region Discord Variables
|
||||
//discord
|
||||
public static DiscordRPC.RichPresence presence;
|
||||
public static string appid = "505955125727330324";
|
||||
public static string imagekey_large = "novetus_large";
|
||||
public static string image_ingame = "ingame_small";
|
||||
public static string image_inlauncher = "inlauncher_small";
|
||||
public static string image_instudio = "instudio_small";
|
||||
public static string image_incustomization = "incustomization_small";
|
||||
#endregion
|
||||
#region Discord Variables
|
||||
//discord
|
||||
public static DiscordRPC.RichPresence presence;
|
||||
public static string appid = "505955125727330324";
|
||||
public static string imagekey_large = "novetus_large";
|
||||
public static string image_ingame = "ingame_small";
|
||||
public static string image_inlauncher = "inlauncher_small";
|
||||
public static string image_instudio = "instudio_small";
|
||||
public static string image_incustomization = "incustomization_small";
|
||||
#endregion
|
||||
|
||||
#region Other
|
||||
public static bool ExtendedVersionNumber = false;
|
||||
public static bool LocalPlayMode = false;
|
||||
public static bool AdminMode = false;
|
||||
public static bool ColorsLoaded = false;
|
||||
public static int ValidatedExtraFiles = 0;
|
||||
public static bool NoFileList = false;
|
||||
public static string ServerID = "N/A";
|
||||
public static string PingURL = "";
|
||||
public static string Important = "";
|
||||
public static string Important2 = "";
|
||||
public static string NextCommand = "";
|
||||
public static bool AppClosed = false;
|
||||
public static bool isConsoleOnly = false;
|
||||
public static bool isMapCompressed = false;
|
||||
#region Other
|
||||
public static bool ExtendedVersionNumber = false;
|
||||
public static bool LocalPlayMode = false;
|
||||
public static bool AdminMode = false;
|
||||
public static bool ColorsLoaded = false;
|
||||
public static int ValidatedExtraFiles = 0;
|
||||
public static bool NoFileList = false;
|
||||
public static string ServerID = "N/A";
|
||||
public static string PingURL = "";
|
||||
public static string Important = "";
|
||||
public static string Important2 = "";
|
||||
public static string NextCommand = "";
|
||||
public static bool AppClosed = false;
|
||||
public static bool isConsoleOnly = false;
|
||||
public static bool isMapCompressed = false;
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -4,50 +4,53 @@ using Mono.Nat;
|
|||
using System;
|
||||
#endregion
|
||||
|
||||
#region NetFuncs
|
||||
|
||||
public static class NetFuncs
|
||||
namespace Novetus.Core
|
||||
{
|
||||
public static void InitUPnP(EventHandler<DeviceEventArgs> DeviceFound, EventHandler<DeviceEventArgs> DeviceLost)
|
||||
{
|
||||
if (GlobalVars.UserConfiguration.UPnP)
|
||||
{
|
||||
NatUtility.DeviceFound += DeviceFound;
|
||||
NatUtility.StartDiscovery();
|
||||
}
|
||||
}
|
||||
#region NetFuncs
|
||||
|
||||
public static void StartUPnP(INatDevice device, Protocol protocol, int port)
|
||||
public static class NetFuncs
|
||||
{
|
||||
if (GlobalVars.UserConfiguration.UPnP)
|
||||
public static void InitUPnP(EventHandler<DeviceEventArgs> DeviceFound, EventHandler<DeviceEventArgs> DeviceLost)
|
||||
{
|
||||
Mapping checker = device.GetSpecificMapping(protocol, port);
|
||||
int mapPublic = checker.PublicPort;
|
||||
int mapPrivate = checker.PrivatePort;
|
||||
|
||||
if (mapPublic == -1 && mapPrivate == -1)
|
||||
if (GlobalVars.UserConfiguration.UPnP)
|
||||
{
|
||||
Mapping portmap = new Mapping(protocol, port, port);
|
||||
device.CreatePortMap(portmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopUPnP(INatDevice device, Protocol protocol, int port)
|
||||
{
|
||||
if (GlobalVars.UserConfiguration.UPnP)
|
||||
{
|
||||
Mapping checker = device.GetSpecificMapping(protocol, port);
|
||||
int mapPublic = checker.PublicPort;
|
||||
int mapPrivate = checker.PrivatePort;
|
||||
|
||||
if (mapPublic != -1 && mapPrivate != -1)
|
||||
{
|
||||
Mapping portmap = new Mapping(protocol, port, port);
|
||||
device.DeletePortMap(portmap);
|
||||
NatUtility.DeviceFound += DeviceFound;
|
||||
NatUtility.StartDiscovery();
|
||||
}
|
||||
}
|
||||
|
||||
public static void StartUPnP(INatDevice device, Protocol protocol, int port)
|
||||
{
|
||||
if (GlobalVars.UserConfiguration.UPnP)
|
||||
{
|
||||
Mapping checker = device.GetSpecificMapping(protocol, port);
|
||||
int mapPublic = checker.PublicPort;
|
||||
int mapPrivate = checker.PrivatePort;
|
||||
|
||||
if (mapPublic == -1 && mapPrivate == -1)
|
||||
{
|
||||
Mapping portmap = new Mapping(protocol, port, port);
|
||||
device.CreatePortMap(portmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopUPnP(INatDevice device, Protocol protocol, int port)
|
||||
{
|
||||
if (GlobalVars.UserConfiguration.UPnP)
|
||||
{
|
||||
Mapping checker = device.GetSpecificMapping(protocol, port);
|
||||
int mapPublic = checker.PublicPort;
|
||||
int mapPrivate = checker.PrivatePort;
|
||||
|
||||
if (mapPublic != -1 && mapPrivate != -1)
|
||||
{
|
||||
Mapping portmap = new Mapping(protocol, port, port);
|
||||
device.DeletePortMap(portmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -14,369 +14,376 @@ using System.Net;
|
|||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
#region Security Functions
|
||||
public class SecurityFuncs
|
||||
namespace Novetus.Core
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
static extern int SetWindowText(IntPtr hWnd, string text);
|
||||
|
||||
public static string RandomString(int length)
|
||||
#region Security Functions
|
||||
public class SecurityFuncs
|
||||
{
|
||||
CryptoRandom random = new CryptoRandom();
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
return new string(Enumerable.Repeat(chars, length)
|
||||
.Select(s => s[random.Next(s.Length)]).ToArray());
|
||||
}
|
||||
[DllImport("user32.dll")]
|
||||
static extern int SetWindowText(IntPtr hWnd, string text);
|
||||
|
||||
public static int GenerateRandomNumber()
|
||||
{
|
||||
CryptoRandom random = new CryptoRandom();
|
||||
int randomID = 0;
|
||||
int randIDmode = random.Next(0, 8);
|
||||
int idlimit = 0;
|
||||
|
||||
switch (randIDmode)
|
||||
public static string RandomString(int length)
|
||||
{
|
||||
case 0:
|
||||
idlimit = 9;
|
||||
break;
|
||||
case 1:
|
||||
idlimit = 99;
|
||||
break;
|
||||
case 2:
|
||||
idlimit = 999;
|
||||
break;
|
||||
case 3:
|
||||
idlimit = 9999;
|
||||
break;
|
||||
case 4:
|
||||
idlimit = 99999;
|
||||
break;
|
||||
case 5:
|
||||
idlimit = 999999;
|
||||
break;
|
||||
case 6:
|
||||
idlimit = 9999999;
|
||||
break;
|
||||
case 7:
|
||||
idlimit = 99999999;
|
||||
break;
|
||||
case 8:
|
||||
default:
|
||||
break;
|
||||
CryptoRandom random = new CryptoRandom();
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
return new string(Enumerable.Repeat(chars, length)
|
||||
.Select(s => s[random.Next(s.Length)]).ToArray());
|
||||
}
|
||||
|
||||
if (idlimit > 0)
|
||||
public static int GenerateRandomNumber()
|
||||
{
|
||||
randomID = random.Next(0, idlimit);
|
||||
}
|
||||
else
|
||||
{
|
||||
randomID = random.Next();
|
||||
}
|
||||
CryptoRandom random = new CryptoRandom();
|
||||
int randomID = 0;
|
||||
int randIDmode = random.Next(0, 8);
|
||||
int idlimit = 0;
|
||||
|
||||
//2147483647 is max id.
|
||||
return randomID;
|
||||
}
|
||||
|
||||
//these 2 methods are for the clientinfo creator.
|
||||
public static string Base64DecodeNew(string base64EncodedData)
|
||||
{
|
||||
return base64EncodedData.Decrypt();
|
||||
}
|
||||
|
||||
public static string Base64DecodeOld(string base64EncodedData)
|
||||
{
|
||||
var base64EncodedBytes = Convert.FromBase64String(base64EncodedData);
|
||||
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
|
||||
}
|
||||
|
||||
//this is for everything else
|
||||
public static string Base64Decode(string base64EncodedData)
|
||||
{
|
||||
try
|
||||
{
|
||||
string decode = base64EncodedData.Decrypt();
|
||||
return decode;
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
var base64EncodedBytes = Convert.FromBase64String(base64EncodedData);
|
||||
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Base64Encode(string plainText, bool oldVer = false)
|
||||
{
|
||||
if (oldVer)
|
||||
{
|
||||
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
|
||||
return System.Convert.ToBase64String(plainTextBytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return plainText.Crypt();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsBase64String(string s)
|
||||
{
|
||||
s = s.Trim();
|
||||
return (s.Length % 4 == 0) && Regex.IsMatch(s, @"^[a-zA-Z0-9\+/]*={0,3}$", RegexOptions.None);
|
||||
}
|
||||
|
||||
public static long UnixTimeNow()
|
||||
{
|
||||
var timeSpan = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
|
||||
return (long)timeSpan.TotalSeconds;
|
||||
}
|
||||
|
||||
public static bool checkClientMD5(string client)
|
||||
{
|
||||
if (!GlobalVars.AdminMode)
|
||||
{
|
||||
if (!GlobalVars.SelectedClientInfo.AlreadyHasSecurity)
|
||||
switch (randIDmode)
|
||||
{
|
||||
string rbxexe = "";
|
||||
string BasePath = GlobalPaths.BasePath + "\\clients\\" + client;
|
||||
if (GlobalVars.SelectedClientInfo.LegacyMode)
|
||||
{
|
||||
rbxexe = BasePath + "\\RobloxApp.exe";
|
||||
}
|
||||
else if (GlobalVars.SelectedClientInfo.SeperateFolders)
|
||||
{
|
||||
rbxexe = BasePath + "\\client\\RobloxApp_client.exe";
|
||||
}
|
||||
else if (GlobalVars.SelectedClientInfo.UsesCustomClientEXEName)
|
||||
{
|
||||
rbxexe = BasePath + @"\\" + GlobalVars.SelectedClientInfo.CustomClientEXEName;
|
||||
}
|
||||
else
|
||||
{
|
||||
rbxexe = BasePath + "\\RobloxApp_client.exe";
|
||||
}
|
||||
return CheckMD5(GlobalVars.SelectedClientInfo.ClientMD5, rbxexe);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
case 0:
|
||||
idlimit = 9;
|
||||
break;
|
||||
case 1:
|
||||
idlimit = 99;
|
||||
break;
|
||||
case 2:
|
||||
idlimit = 999;
|
||||
break;
|
||||
case 3:
|
||||
idlimit = 9999;
|
||||
break;
|
||||
case 4:
|
||||
idlimit = 99999;
|
||||
break;
|
||||
case 5:
|
||||
idlimit = 999999;
|
||||
break;
|
||||
case 6:
|
||||
idlimit = 9999999;
|
||||
break;
|
||||
case 7:
|
||||
idlimit = 99999999;
|
||||
break;
|
||||
case 8:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool checkScriptMD5(string client)
|
||||
{
|
||||
if (!GlobalVars.AdminMode)
|
||||
{
|
||||
if (!GlobalVars.SelectedClientInfo.AlreadyHasSecurity)
|
||||
|
||||
if (idlimit > 0)
|
||||
{
|
||||
string rbxscript = GlobalPaths.BasePath + "\\clients\\" + client + "\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua";
|
||||
return CheckMD5(GlobalVars.SelectedClientInfo.ScriptMD5, rbxscript);
|
||||
} else {
|
||||
return true;
|
||||
randomID = random.Next(0, idlimit);
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckMD5(string MD5Hash, string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
return false;
|
||||
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
using (var stream = File.OpenRead(path))
|
||||
else
|
||||
{
|
||||
byte[] hash = md5.ComputeHash(stream);
|
||||
string clientMD5 = BitConverter.ToString(hash).Replace("-", "");
|
||||
if (clientMD5.Equals(MD5Hash))
|
||||
randomID = random.Next();
|
||||
}
|
||||
|
||||
//2147483647 is max id.
|
||||
return randomID;
|
||||
}
|
||||
|
||||
//these 2 methods are for the clientinfo creator.
|
||||
public static string Base64DecodeNew(string base64EncodedData)
|
||||
{
|
||||
return base64EncodedData.Decrypt();
|
||||
}
|
||||
|
||||
public static string Base64DecodeOld(string base64EncodedData)
|
||||
{
|
||||
var base64EncodedBytes = Convert.FromBase64String(base64EncodedData);
|
||||
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
|
||||
}
|
||||
|
||||
//this is for everything else
|
||||
public static string Base64Decode(string base64EncodedData)
|
||||
{
|
||||
try
|
||||
{
|
||||
string decode = base64EncodedData.Decrypt();
|
||||
return decode;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
var base64EncodedBytes = Convert.FromBase64String(base64EncodedData);
|
||||
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Base64Encode(string plainText, bool oldVer = false)
|
||||
{
|
||||
if (oldVer)
|
||||
{
|
||||
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
|
||||
return System.Convert.ToBase64String(plainTextBytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return plainText.Crypt();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsBase64String(string s)
|
||||
{
|
||||
s = s.Trim();
|
||||
return (s.Length % 4 == 0) && Regex.IsMatch(s, @"^[a-zA-Z0-9\+/]*={0,3}$", RegexOptions.None);
|
||||
}
|
||||
|
||||
public static long UnixTimeNow()
|
||||
{
|
||||
var timeSpan = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
|
||||
return (long)timeSpan.TotalSeconds;
|
||||
}
|
||||
|
||||
public static bool checkClientMD5(string client)
|
||||
{
|
||||
if (!GlobalVars.AdminMode)
|
||||
{
|
||||
if (!GlobalVars.SelectedClientInfo.AlreadyHasSecurity)
|
||||
{
|
||||
return true;
|
||||
string rbxexe = "";
|
||||
string BasePath = GlobalPaths.BasePath + "\\clients\\" + client;
|
||||
if (GlobalVars.SelectedClientInfo.LegacyMode)
|
||||
{
|
||||
rbxexe = BasePath + "\\RobloxApp.exe";
|
||||
}
|
||||
else if (GlobalVars.SelectedClientInfo.SeperateFolders)
|
||||
{
|
||||
rbxexe = BasePath + "\\client\\RobloxApp_client.exe";
|
||||
}
|
||||
else if (GlobalVars.SelectedClientInfo.UsesCustomClientEXEName)
|
||||
{
|
||||
rbxexe = BasePath + @"\\" + GlobalVars.SelectedClientInfo.CustomClientEXEName;
|
||||
}
|
||||
else
|
||||
{
|
||||
rbxexe = BasePath + "\\RobloxApp_client.exe";
|
||||
}
|
||||
return CheckMD5(GlobalVars.SelectedClientInfo.ClientMD5, rbxexe);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GenerateMD5(string filename)
|
||||
{
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
using (var stream = new BufferedStream(File.OpenRead(filename), 1200000))
|
||||
else
|
||||
{
|
||||
return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsElevated
|
||||
{
|
||||
get
|
||||
{
|
||||
return WindowsIdentity.GetCurrent().Owner.IsWellKnown(WellKnownSidType.BuiltinAdministratorsSid);
|
||||
}
|
||||
}
|
||||
|
||||
public static string RandomStringTitle()
|
||||
{
|
||||
CryptoRandom random = new CryptoRandom();
|
||||
return new String(' ', random.Next(20));
|
||||
}
|
||||
|
||||
public static void RenameWindow(Process exe, ScriptType type, string clientname, string mapname)
|
||||
{
|
||||
if (!GlobalVars.SelectedClientInfo.AlreadyHasSecurity)
|
||||
public static bool checkScriptMD5(string client)
|
||||
{
|
||||
int time = 500;
|
||||
BackgroundWorker worker = new BackgroundWorker();
|
||||
worker.WorkerSupportsCancellation = true;
|
||||
worker.DoWork += (obj, e) => WorkerDoWork(exe, type, time, worker, clientname, mapname);
|
||||
worker.RunWorkerAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private static void WorkerKill(Process exe, ScriptType type, int time, BackgroundWorker worker, string clientname, string mapname)
|
||||
{
|
||||
worker.DoWork -= (obj, e) => WorkerDoWork(exe, type, time, worker, clientname, mapname);
|
||||
worker.CancelAsync();
|
||||
worker.Dispose();
|
||||
}
|
||||
|
||||
private static void WorkerDoWork(Process exe, ScriptType type, int time, BackgroundWorker worker, string clientname, string mapname)
|
||||
{
|
||||
DateTime StartTimeAfterMinute = exe.StartTime.AddMinutes(1);
|
||||
|
||||
if (exe.IsRunning())
|
||||
{
|
||||
while (exe.IsRunning())
|
||||
if (!GlobalVars.AdminMode)
|
||||
{
|
||||
if (exe.MainWindowHandle == null && DateTime.Now > StartTimeAfterMinute)
|
||||
{
|
||||
exe.Kill();
|
||||
WorkerKill(exe, type, time, worker, clientname, mapname);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
if (!GlobalVars.SelectedClientInfo.AlreadyHasSecurity)
|
||||
{
|
||||
case ScriptType.Client:
|
||||
SetWindowText(exe.MainWindowHandle, "Novetus "
|
||||
+ GlobalVars.ProgramInformation.Version + " - "
|
||||
+ clientname + " "
|
||||
+ ScriptFuncs.Generator.GetNameForType(type)
|
||||
+ " [" + GlobalVars.CurrentServer.ToString() + "]"
|
||||
+ RandomStringTitle());
|
||||
break;
|
||||
case ScriptType.Server:
|
||||
case ScriptType.Solo:
|
||||
SetWindowText(exe.MainWindowHandle, "Novetus "
|
||||
+ GlobalVars.ProgramInformation.Version + " - "
|
||||
+ clientname + " "
|
||||
+ ScriptFuncs.Generator.GetNameForType(type)
|
||||
+ (string.IsNullOrWhiteSpace(mapname) ? " [Place1]" : " [" + mapname + "]")
|
||||
+ RandomStringTitle());
|
||||
break;
|
||||
case ScriptType.Studio:
|
||||
SetWindowText(exe.MainWindowHandle, "Novetus Studio "
|
||||
+ GlobalVars.ProgramInformation.Version + " - "
|
||||
+ clientname
|
||||
+ (string.IsNullOrWhiteSpace(mapname) ? " [Place1]" : " [" + mapname + "]")
|
||||
+ RandomStringTitle());
|
||||
break;
|
||||
case ScriptType.EasterEgg:
|
||||
default:
|
||||
SetWindowText(exe.MainWindowHandle, ScriptFuncs.Generator.GetNameForType(type)
|
||||
+ RandomStringTitle());
|
||||
break;
|
||||
string rbxscript = GlobalPaths.BasePath + "\\clients\\" + client + "\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua";
|
||||
return CheckMD5(GlobalVars.SelectedClientInfo.ScriptMD5, rbxscript);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Thread.Sleep(time);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckMD5(string MD5Hash, string path)
|
||||
{
|
||||
Thread.Sleep(time);
|
||||
RenameWindow(exe, type, clientname, mapname);
|
||||
}
|
||||
}
|
||||
if (!File.Exists(path))
|
||||
return false;
|
||||
|
||||
public static string GetExternalIPAddress()
|
||||
{
|
||||
string ipAddress;
|
||||
|
||||
try
|
||||
{
|
||||
ipAddress = new WebClient().DownloadString("https://ipv4.icanhazip.com/").TrimEnd();
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
using (var stream = File.OpenRead(path))
|
||||
{
|
||||
byte[] hash = md5.ComputeHash(stream);
|
||||
string clientMD5 = BitConverter.ToString(hash).Replace("-", "");
|
||||
if (clientMD5.Equals(MD5Hash))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GenerateMD5(string filename)
|
||||
{
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
using (var stream = new BufferedStream(File.OpenRead(filename), 1200000))
|
||||
{
|
||||
return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsElevated
|
||||
{
|
||||
get
|
||||
{
|
||||
return WindowsIdentity.GetCurrent().Owner.IsWellKnown(WellKnownSidType.BuiltinAdministratorsSid);
|
||||
}
|
||||
}
|
||||
|
||||
public static string RandomStringTitle()
|
||||
{
|
||||
CryptoRandom random = new CryptoRandom();
|
||||
return new String(' ', random.Next(20));
|
||||
}
|
||||
|
||||
public static void RenameWindow(Process exe, ScriptType type, string clientname, string mapname)
|
||||
{
|
||||
if (!GlobalVars.SelectedClientInfo.AlreadyHasSecurity)
|
||||
{
|
||||
int time = 500;
|
||||
BackgroundWorker worker = new BackgroundWorker();
|
||||
worker.WorkerSupportsCancellation = true;
|
||||
worker.DoWork += (obj, e) => WorkerDoWork(exe, type, time, worker, clientname, mapname);
|
||||
worker.RunWorkerAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private static void WorkerKill(Process exe, ScriptType type, int time, BackgroundWorker worker, string clientname, string mapname)
|
||||
{
|
||||
worker.DoWork -= (obj, e) => WorkerDoWork(exe, type, time, worker, clientname, mapname);
|
||||
worker.CancelAsync();
|
||||
worker.Dispose();
|
||||
}
|
||||
|
||||
private static void WorkerDoWork(Process exe, ScriptType type, int time, BackgroundWorker worker, string clientname, string mapname)
|
||||
{
|
||||
DateTime StartTimeAfterMinute = exe.StartTime.AddMinutes(1);
|
||||
|
||||
if (exe.IsRunning())
|
||||
{
|
||||
while (exe.IsRunning())
|
||||
{
|
||||
if (exe.MainWindowHandle == null && DateTime.Now > StartTimeAfterMinute)
|
||||
{
|
||||
exe.Kill();
|
||||
WorkerKill(exe, type, time, worker, clientname, mapname);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ScriptType.Client:
|
||||
SetWindowText(exe.MainWindowHandle, "Novetus "
|
||||
+ GlobalVars.ProgramInformation.Version + " - "
|
||||
+ clientname + " "
|
||||
+ ScriptFuncs.Generator.GetNameForType(type)
|
||||
+ " [" + GlobalVars.CurrentServer.ToString() + "]"
|
||||
+ RandomStringTitle());
|
||||
break;
|
||||
case ScriptType.Server:
|
||||
case ScriptType.Solo:
|
||||
SetWindowText(exe.MainWindowHandle, "Novetus "
|
||||
+ GlobalVars.ProgramInformation.Version + " - "
|
||||
+ clientname + " "
|
||||
+ ScriptFuncs.Generator.GetNameForType(type)
|
||||
+ (string.IsNullOrWhiteSpace(mapname) ? " [Place1]" : " [" + mapname + "]")
|
||||
+ RandomStringTitle());
|
||||
break;
|
||||
case ScriptType.Studio:
|
||||
SetWindowText(exe.MainWindowHandle, "Novetus Studio "
|
||||
+ GlobalVars.ProgramInformation.Version + " - "
|
||||
+ clientname
|
||||
+ (string.IsNullOrWhiteSpace(mapname) ? " [Place1]" : " [" + mapname + "]")
|
||||
+ RandomStringTitle());
|
||||
break;
|
||||
case ScriptType.EasterEgg:
|
||||
default:
|
||||
SetWindowText(exe.MainWindowHandle, ScriptFuncs.Generator.GetNameForType(type)
|
||||
+ RandomStringTitle());
|
||||
break;
|
||||
}
|
||||
|
||||
Thread.Sleep(time);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(time);
|
||||
RenameWindow(exe, type, clientname, mapname);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetExternalIPAddress()
|
||||
{
|
||||
string ipAddress;
|
||||
|
||||
try
|
||||
{
|
||||
ipAddress = new WebClient().DownloadString("https://ipv4.icanhazip.com/").TrimEnd();
|
||||
}
|
||||
#if URI || LAUNCHER || BASICLAUNCHER
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.LogExceptions(ex);
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.LogExceptions(ex);
|
||||
#else
|
||||
catch (Exception)
|
||||
{
|
||||
#endif
|
||||
ipAddress = "localhost";
|
||||
}
|
||||
ipAddress = "localhost";
|
||||
}
|
||||
|
||||
return ipAddress;
|
||||
}
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
//modified from https://stackoverflow.com/questions/14687658/random-name-generator-in-c-sharp
|
||||
public static string GenerateName(int len)
|
||||
{
|
||||
CryptoRandom r = new CryptoRandom();
|
||||
string[] consonants = { "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "l", "n", "p", "q", "r", "s", "sh", "zh", "t", "v", "w", "x" };
|
||||
string[] vowels = { "a", "e", "i", "o", "u", "ae", "y" };
|
||||
string Name = "";
|
||||
Name += consonants[r.Next(consonants.Length)].ToUpper();
|
||||
Name += vowels[r.Next(vowels.Length)];
|
||||
int b = 2; //b tells how many times a new letter has been added. It's 2 right now because the first two letters are already in the name.
|
||||
while (b < len)
|
||||
//modified from https://stackoverflow.com/questions/14687658/random-name-generator-in-c-sharp
|
||||
public static string GenerateName(int len)
|
||||
{
|
||||
Name += consonants[r.Next(consonants.Length)];
|
||||
b++;
|
||||
CryptoRandom r = new CryptoRandom();
|
||||
string[] consonants = { "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "l", "n", "p", "q", "r", "s", "sh", "zh", "t", "v", "w", "x" };
|
||||
string[] vowels = { "a", "e", "i", "o", "u", "ae", "y" };
|
||||
string Name = "";
|
||||
Name += consonants[r.Next(consonants.Length)].ToUpper();
|
||||
Name += vowels[r.Next(vowels.Length)];
|
||||
b++;
|
||||
int b = 2; //b tells how many times a new letter has been added. It's 2 right now because the first two letters are already in the name.
|
||||
while (b < len)
|
||||
{
|
||||
Name += consonants[r.Next(consonants.Length)];
|
||||
b++;
|
||||
Name += vowels[r.Next(vowels.Length)];
|
||||
b++;
|
||||
}
|
||||
|
||||
return Name;
|
||||
}
|
||||
|
||||
return Name;
|
||||
}
|
||||
|
||||
//https://www.c-sharpcorner.com/article/caesar-cipher-in-c-sharp/
|
||||
public static char cipher(char ch, int key)
|
||||
{
|
||||
if (!char.IsLetter(ch))
|
||||
//https://www.c-sharpcorner.com/article/caesar-cipher-in-c-sharp/
|
||||
public static char cipher(char ch, int key)
|
||||
{
|
||||
return ch;
|
||||
if (!char.IsLetter(ch))
|
||||
{
|
||||
return ch;
|
||||
}
|
||||
|
||||
char d = char.IsUpper(ch) ? 'A' : 'a';
|
||||
return (char)((((ch + key) - d) % 26) + d);
|
||||
}
|
||||
|
||||
char d = char.IsUpper(ch) ? 'A' : 'a';
|
||||
return (char)((((ch + key) - d) % 26) + d);
|
||||
public static string Encipher(string input, int key)
|
||||
{
|
||||
string output = string.Empty;
|
||||
|
||||
foreach (char ch in input)
|
||||
output += cipher(ch, key);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public static string Decipher(string input, int key)
|
||||
{
|
||||
return Encipher(input, 26 - key);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Encipher(string input, int key)
|
||||
{
|
||||
string output = string.Empty;
|
||||
|
||||
foreach (char ch in input)
|
||||
output += cipher(ch, key);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public static string Decipher(string input, int key)
|
||||
{
|
||||
return Encipher(input, 26 - key);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,5 +1,6 @@
|
|||
#region Usings
|
||||
using Ionic.Zip;
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Windows.Forms;
|
||||
using Novetus.Core;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace NovetusLauncher
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
*
|
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers.
|
||||
*/
|
||||
using Novetus.Core;
|
||||
|
||||
namespace NovetusLauncher
|
||||
{
|
||||
partial class LauncherFormCompact
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#region Usings
|
||||
using Mono.Nat;
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
*
|
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers.
|
||||
*/
|
||||
using Novetus.Core;
|
||||
|
||||
namespace NovetusLauncher
|
||||
{
|
||||
partial class LauncherFormExtended
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using System.Reflection;
|
|||
using Mono.Nat;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Novetus.Core;
|
||||
#endregion
|
||||
|
||||
namespace NovetusLauncher
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#region Usings
|
||||
using Mono.Nat;
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using NLog;
|
||||
using Novetus.Core;
|
||||
|
||||
namespace NovetusLauncher
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using Novetus.Core;
|
||||
#endregion
|
||||
|
||||
#region ClientScriptDocumentation
|
||||
public partial class ClientScriptDocumentation : Form
|
||||
public partial class ClientScriptDocumentation : Form
|
||||
{
|
||||
#region Constructor
|
||||
public ClientScriptDocumentation()
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Windows.Forms;
|
|||
using System.IO;
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
using Novetus.Core;
|
||||
#endregion
|
||||
|
||||
#region Client SDK
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#region Usings
|
||||
using NLog;
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#region Usings
|
||||
using Microsoft.Win32;
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Diagnostics;
|
|||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using NLog;
|
||||
using Novetus.Core;
|
||||
#endregion
|
||||
|
||||
namespace NovetusURI
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using System.Windows.Forms;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using Novetus.Core;
|
||||
#endregion
|
||||
|
||||
namespace NovetusURI
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#region Usings
|
||||
using NLog;
|
||||
using Novetus.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
|
|
|||
Loading…
Reference in New Issue