add Novetus.Core namespace. Basic web proxy Extension support.

This commit is contained in:
Bitl 2023-01-05 10:07:51 -07:00
parent b0b2bad019
commit f46b7d9a9c
59 changed files with 5598 additions and 5286 deletions

View File

@ -1,5 +1,6 @@
#region Usings #region Usings
using NLog; using NLog;
using Novetus.Core;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
#endregion #endregion

View File

@ -1,4 +1,5 @@
using NLog; using NLog;
using Novetus.Core;
using System; using System;
using System.Drawing; using System.Drawing;
using System.Drawing.Text; using System.Drawing.Text;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;

View File

@ -7,6 +7,8 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using Novetus.Core;
partial class CharacterCustomizationCompact partial class CharacterCustomizationCompact
{ {
/// <summary> /// <summary>

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@ -6,6 +6,8 @@
* *
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using Novetus.Core;
partial class CharacterCustomizationExtended partial class CharacterCustomizationExtended
{ {
/// <summary> /// <summary>

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@ -3,7 +3,9 @@ using System.Collections.Specialized;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
#endregion #endregion
#region CommandLineArguments namespace Novetus.Core
{
#region CommandLineArguments
public class CommandLineArguments public class CommandLineArguments
{ {
//https://www.codeproject.com/Articles/3111/C-NET-Command-Line-Arguments-Parser //https://www.codeproject.com/Articles/3111/C-NET-Command-Line-Arguments-Parser
@ -118,3 +120,4 @@ using System.Text.RegularExpressions;
} }
} }
#endregion #endregion
}

View File

@ -3,10 +3,12 @@ using System;
using System.Security.Cryptography; using System.Security.Cryptography;
#endregion #endregion
#region CryptoRandom namespace Novetus.Core
public class CryptoRandom : RandomNumberGenerator
{ {
#region CryptoRandom
public class CryptoRandom : RandomNumberGenerator
{
private static RandomNumberGenerator r; private static RandomNumberGenerator r;
public CryptoRandom() public CryptoRandom()
@ -47,5 +49,6 @@ public class CryptoRandom : RandomNumberGenerator
{ {
return Next(0, maxValue); return Next(0, maxValue);
} }
}
#endregion
} }
#endregion

View File

@ -6,10 +6,12 @@ using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
#endregion #endregion
#region Downloader namespace Novetus.Core
class Downloader
{ {
#region Downloader
class Downloader
{
public readonly string fileURL; public readonly string fileURL;
public readonly string fileName; public readonly string fileName;
public readonly string fileFilter; public readonly string fileFilter;
@ -246,5 +248,6 @@ class Downloader
// Return total bytes processed to caller. // Return total bytes processed to caller.
return bytesProcessed; return bytesProcessed;
} }
}
#endregion
} }
#endregion

View File

@ -2,10 +2,12 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
#endregion #endregion
#region Discord RPC namespace Novetus.Core
//code by discord obv. just renamed it to fit better.
public class DiscordRPC
{ {
#region Discord RPC
//code by discord obv. just renamed it to fit better.
public class DiscordRPC
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void ReadyCallback(); public delegate void ReadyCallback();
@ -92,5 +94,6 @@ public class DiscordRPC
[DllImport("discord-rpc", EntryPoint = "Discord_Respond", CallingConvention = CallingConvention.Cdecl)] [DllImport("discord-rpc", EntryPoint = "Discord_Respond", CallingConvention = CallingConvention.Cdecl)]
public static extern void Respond(string userId, Reply reply); public static extern void Respond(string userId, Reply reply);
}
#endregion
} }
#endregion

View File

@ -5,11 +5,13 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
#endregion #endregion
#region INI File Parser namespace Novetus.Core
//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
{ {
#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
{
public string path; public string path;
[DllImport("kernel32")] [DllImport("kernel32")]
@ -95,5 +97,6 @@ public class INIFile
return false; return false;
} }
} }
}
#endregion
} }
#endregion

View File

@ -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
}

View File

@ -4,11 +4,13 @@ using System.Collections.Generic;
using System.IO; using System.IO;
#endregion #endregion
#region Text Line Remover and Friends namespace Novetus.Core
// modified from https://stackoverflow.com/questions/668907/how-to-delete-a-line-from-a-text-file-in-c/668914#668914
public static class TextLineRemover
{ {
#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
{
public static void RemoveTextLines(IList<string> linesToRemove, string filename, string tempFilename) public static void RemoveTextLines(IList<string> linesToRemove, string filename, string tempFilename)
{ {
// Initial values // Initial values
@ -82,22 +84,23 @@ public static class TextLineRemover
{ {
OnRemovedLine?.Invoke(null, args); OnRemovedLine?.Invoke(null, args);
} }
} }
public delegate void Finished(object sender, FinishedArgs args); public delegate void Finished(object sender, FinishedArgs args);
public struct FinishedArgs public struct FinishedArgs
{ {
public int TotalLines { get; set; } public int TotalLines { get; set; }
public int LinesRemoved { get; set; } public int LinesRemoved { get; set; }
public TimeSpan TotalTime { get; set; } public TimeSpan TotalTime { get; set; }
} }
public delegate void RemovedLine(object sender, RemovedLineArgs args); public delegate void RemovedLine(object sender, RemovedLineArgs args);
public struct RemovedLineArgs public struct RemovedLineArgs
{ {
public string RemovedLine { get; set; } public string RemovedLine { get; set; }
public int RemovedLineNumber { get; set; } public int RemovedLineNumber { get; set; }
}
#endregion
} }
#endregion

View File

@ -7,9 +7,10 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
#endregion #endregion
//https://github.com/davcs86/csharp-uhwid //https://github.com/davcs86/csharp-uhwid
//merged into one class //merged into one class
namespace UHWID namespace Novetus.Core
{ {
#region UHWIDEngine #region UHWIDEngine
public static class UHWIDEngine public static class UHWIDEngine

View File

@ -12,11 +12,64 @@ using Titanium.Web.Proxy.EventArguments;
using Titanium.Web.Proxy.Http; using Titanium.Web.Proxy.Http;
using Titanium.Web.Proxy.Models; using Titanium.Web.Proxy.Models;
public class WebProxy namespace Novetus.Core
{ {
public class IWebProxyExtension
{
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 class WebProxy
{
private static List<IWebProxyExtension> ExtensionList = new List<IWebProxyExtension>();
private static ProxyServer Server = new ProxyServer(); private static ProxyServer Server = new ProxyServer();
private static ExplicitProxyEndPoint end; private static ExplicitProxyEndPoint end;
public void LoadExtensions()
{
string nothingFoundError = "No extensions found. The Web Proxy will run with limited functionality.";
if (!Directory.Exists(GlobalPaths.NovetusExtsWebProxy))
{
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() public bool HasStarted()
{ {
return Server.ProxyRunning; return Server.ProxyRunning;
@ -62,12 +115,16 @@ public class WebProxy
{ {
try try
{ {
//load ext LoadExtensions();
Server.CertificateManager.RootCertificateIssuerName = "Novetus"; Server.CertificateManager.RootCertificateIssuerName = "Novetus";
Server.CertificateManager.RootCertificateName = "Novetus Web Proxy"; Server.CertificateManager.RootCertificateName = "Novetus Web Proxy";
Server.BeforeRequest += new AsyncEventHandler<SessionEventArgs>(OnRequest); Server.BeforeRequest += new AsyncEventHandler<SessionEventArgs>(OnRequest);
UpdateEndPoint(true); UpdateEndPoint(true);
Util.ConsolePrint("Web Proxy started on port " + GlobalVars.WebProxyPort, 3); Util.ConsolePrint("Web Proxy started on port " + GlobalVars.WebProxyPort, 3);
foreach (IWebProxyExtension extension in ExtensionList.ToArray())
{
extension.OnProxyStart();
}
} }
catch (Exception e) catch (Exception e)
{ {
@ -104,7 +161,7 @@ public class WebProxy
Util.ConsolePrint("Web Proxy Endpoint updated with port " + GlobalVars.WebProxyPort, 3); Util.ConsolePrint("Web Proxy Endpoint updated with port " + GlobalVars.WebProxyPort, 3);
} }
private bool IsURIAllowed(HttpWebClient client) private bool IsValidURL(HttpWebClient client)
{ {
string uri = client.Request.RequestUri.Host; string uri = client.Request.RequestUri.Host;
@ -138,11 +195,32 @@ public class WebProxy
private Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e) private Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
{ {
if (!IsURIAllowed(e.HttpClient)) if (!IsValidURL(e.HttpClient))
{ {
e.DecryptSsl = false; 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; return Task.CompletedTask;
} }
@ -150,11 +228,31 @@ public class WebProxy
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 #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{ {
if (!IsURIAllowed(e.HttpClient)) if (!IsValidURL(e.HttpClient))
{ {
return; 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);
} }
@ -163,11 +261,19 @@ public class WebProxy
Util.ConsolePrint("Web Proxy stopping on port " + GlobalVars.WebProxyPort, 3); Util.ConsolePrint("Web Proxy stopping on port " + GlobalVars.WebProxyPort, 3);
Server.BeforeRequest -= new AsyncEventHandler<SessionEventArgs>(OnRequest); Server.BeforeRequest -= new AsyncEventHandler<SessionEventArgs>(OnRequest);
Server.Stop(); Server.Stop();
foreach (IWebProxyExtension extension in ExtensionList.ToArray())
{
try
{
extension.OnProxyStopped();
}
catch (Exception e)
{
Util.LogExceptions(e);
}
}
}
} }
} }
public interface IWebProxyExtention
{
}
#endif #endif

View File

@ -9,6 +9,7 @@
<Import_RootNamespace>NovetusCore</Import_RootNamespace> <Import_RootNamespace>NovetusCore</Import_RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Classes\Script.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Classes\WebProxy.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Classes\WebProxy.cs" />
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\ClientManagement.cs" /> <Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\ClientManagement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Classes\Downloader.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Classes\Downloader.cs" />

View File

@ -12,9 +12,11 @@ using System.Security.Cryptography;
using System.Reflection; using System.Reflection;
#endregion #endregion
#region Client Management namespace Novetus.Core
public class ClientManagement
{ {
#region Client Management
public class ClientManagement
{
public static void ReadClientValues(bool initial = false) public static void ReadClientValues(bool initial = false)
{ {
ReadClientValues(GlobalVars.UserConfiguration.SelectedClient, initial); ReadClientValues(GlobalVars.UserConfiguration.SelectedClient, initial);
@ -1072,9 +1074,9 @@ public class ClientManagement
public static void LaunchRBXClient(string ClientName, ScriptType type, bool no3d, bool nomap, EventHandler e) public static void LaunchRBXClient(string ClientName, ScriptType type, bool no3d, bool nomap, EventHandler e)
#endif #endif
{ {
#if LAUNCHER #if LAUNCHER
DecompressMap(type, nomap); DecompressMap(type, nomap);
#endif #endif
switch (type) switch (type)
{ {
@ -1396,13 +1398,13 @@ public class ClientManagement
return false; return false;
} }
} }
#endregion #endregion
#region Script Functions #region Script Functions
public class ScriptFuncs public class ScriptFuncs
{ {
#region Script Generator/Signer #region Script Generator/Signer
public class Generator public class Generator
{ {
public static void SignGeneratedScript(string scriptFileName, bool newSigFormat = false, bool encodeInBase64 = true) public static void SignGeneratedScript(string scriptFileName, bool newSigFormat = false, bool encodeInBase64 = true)
@ -1587,9 +1589,9 @@ public class ScriptFuncs
return ClientManagement.GetGenLuaFileName(ClientName, type); return ClientManagement.GetGenLuaFileName(ClientName, type);
} }
} }
#endregion #endregion
#region ClientScript Parser #region ClientScript Parser
public class ClientScript public class ClientScript
{ {
public static string GetArgsFromTag(string code, string tag, string endtag) public static string GetArgsFromTag(string code, string tag, string endtag)
@ -1887,6 +1889,7 @@ public class ScriptFuncs
return compiled; return compiled;
} }
} }
#endregion #endregion
}
#endregion
} }
#endregion

View File

@ -14,9 +14,11 @@ using System.Xml.Serialization;
using System.Runtime.Versioning; using System.Runtime.Versioning;
#endregion #endregion
#region File Formats namespace Novetus.Core
public class FileFormat
{ {
#region File Formats
public class FileFormat
{
#region Client Information #region Client Information
public class ClientInfo public class ClientInfo
{ {
@ -217,12 +219,12 @@ public class FileFormat
public bool InitialBootup { get; set; } public bool InitialBootup { get; set; }
} }
#endregion #endregion
} }
#endregion #endregion
#region Part Color Options #region Part Color Options
public class PartColor public class PartColor
{ {
public string ColorName; public string ColorName;
public int ColorID; public int ColorID;
public string ColorRGB; public string ColorRGB;
@ -234,17 +236,17 @@ public class PartColor
public string ColorRawName; public string ColorRawName;
[XmlIgnore] [XmlIgnore]
public Bitmap ColorImage; public Bitmap ColorImage;
} }
[XmlRoot("PartColors")] [XmlRoot("PartColors")]
public class PartColors public class PartColors
{ {
[XmlArray("ColorList")] [XmlArray("ColorList")]
public PartColor[] ColorList; public PartColor[] ColorList;
} }
public class PartColorLoader public class PartColorLoader
{ {
public static PartColor[] GetPartColors() public static PartColor[] GetPartColors()
{ {
if (File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.PartColorXMLName)) if (File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.PartColorXMLName))
@ -392,26 +394,26 @@ public class PartColorLoader
return null; return null;
} }
} }
} }
#endregion #endregion
#region Content Provider Options #region Content Provider Options
public class Provider public class Provider
{ {
public string Name; public string Name;
public string URL; public string URL;
public string Icon; public string Icon;
} }
[XmlRoot("ContentProviders")] [XmlRoot("ContentProviders")]
public class ContentProviders public class ContentProviders
{ {
[XmlArray("Providers")] [XmlArray("Providers")]
public Provider[] Providers; public Provider[] Providers;
} }
public class OnlineClothing public class OnlineClothing
{ {
public static Provider[] GetContentProviders() public static Provider[] GetContentProviders()
{ {
if (File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ContentProviderXMLName)) if (File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ContentProviderXMLName))
@ -455,12 +457,12 @@ public class OnlineClothing
return null; return null;
} }
} }
} }
#endregion #endregion
#region Settings #region Settings
public class Settings public class Settings
{ {
public enum Mode public enum Mode
{ {
Automatic = 0, Automatic = 0,
@ -541,14 +543,14 @@ public class Settings
return appdataRobloxPath; return appdataRobloxPath;
} }
} }
} }
#endregion #endregion
#region Icon Loader #region Icon Loader
public class IconLoader public class IconLoader
{ {
private OpenFileDialog openFileDialog1; private OpenFileDialog openFileDialog1;
private string installOutcome = ""; private string installOutcome = "";
public bool CopyToItemDir = false; public bool CopyToItemDir = false;
@ -603,12 +605,12 @@ public class IconLoader
} }
} }
} }
} }
#endregion #endregion
#region File Management #region File Management
public class FileManagement public class FileManagement
{ {
public static void ReadInfoFile(string infopath, bool other = false, string exepath = "") public static void ReadInfoFile(string infopath, bool other = false, string exepath = "")
{ {
//READ //READ
@ -1501,5 +1503,6 @@ public class FileManagement
Util.ConsolePrint("File list generation finished.", 4); Util.ConsolePrint("File list generation finished.", 4);
} }
}
#endregion
} }
#endregion

View File

@ -3,10 +3,12 @@ using System.IO;
using System.Reflection; using System.Reflection;
#endregion #endregion
#region Global Paths namespace Novetus.Core
public class GlobalPaths
{ {
#region Global Paths
public class GlobalPaths
{
#region Base Game Paths #region Base Game Paths
public static readonly string RootPathLauncher = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); public static readonly string RootPathLauncher = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public static readonly string BasePathLauncher = RootPathLauncher.Replace(@"\", @"\\"); public static readonly string BasePathLauncher = RootPathLauncher.Replace(@"\", @"\\");
@ -23,6 +25,8 @@ public class GlobalPaths
public static readonly string MapsDir = BasePath + @"\\maps"; public static readonly string MapsDir = BasePath + @"\\maps";
public static readonly string AddonDir = BasePath + @"\\addons"; public static readonly string AddonDir = BasePath + @"\\addons";
public static readonly string AddonCoreDir = AddonDir + @"\\core"; 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 MapsDirCustom = MapsDir + @"\\Custom";
public static readonly string MapsDirBase = "maps"; public static readonly string MapsDirBase = "maps";
public static readonly string BaseGameDir = "rbxasset://../../../"; public static readonly string BaseGameDir = "rbxasset://../../../";
@ -114,5 +118,6 @@ public class GlobalPaths
public static readonly string AddonLoaderFileName = "AddonLoader.lua"; public static readonly string AddonLoaderFileName = "AddonLoader.lua";
public static readonly string AssetFixerPatternFileName = "assetfixer_pattern.txt"; public static readonly string AssetFixerPatternFileName = "assetfixer_pattern.txt";
#endregion #endregion
}
#endregion
} }
#endregion

View File

@ -14,21 +14,23 @@ using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;
#endregion #endregion
#region Script Type namespace Novetus.Core
public enum ScriptType
{ {
#region Script Type
public enum ScriptType
{
Client = 0, Client = 0,
Server = 1, Server = 1,
Solo = 2, Solo = 2,
Studio = 3, Studio = 3,
EasterEgg = 4, EasterEgg = 4,
None = 5 None = 5
} }
#endregion #endregion
#region Game Server Definition #region Game Server Definition
public class GameServer public class GameServer
{ {
public GameServer(string ip, int port) public GameServer(string ip, int port)
{ {
ServerIP = ip; ServerIP = ip;
@ -60,12 +62,12 @@ public class GameServer
public string ServerIP { get; set; } public string ServerIP { get; set; }
public int ServerPort { get; set; } public int ServerPort { get; set; }
} }
#endregion #endregion
#region Global Variables #region Global Variables
public static class GlobalVars public static class GlobalVars
{ {
#region Discord #region Discord
public enum LauncherState public enum LauncherState
{ {
@ -101,7 +103,7 @@ public static class GlobalVars
public static int WebProxyPort = 0; public static int WebProxyPort = 0;
public static WebProxy Proxy = new WebProxy(); public static WebProxy Proxy = new WebProxy();
#endif #endif
#endregion #endregion
#if LAUNCHER #if LAUNCHER
#region Novetus Launcher #region Novetus Launcher
@ -149,5 +151,6 @@ public static class GlobalVars
public static bool isConsoleOnly = false; public static bool isConsoleOnly = false;
public static bool isMapCompressed = false; public static bool isMapCompressed = false;
#endregion #endregion
}
#endregion
} }
#endregion

View File

@ -4,10 +4,12 @@ using Mono.Nat;
using System; using System;
#endregion #endregion
#region NetFuncs namespace Novetus.Core
public static class NetFuncs
{ {
#region NetFuncs
public static class NetFuncs
{
public static void InitUPnP(EventHandler<DeviceEventArgs> DeviceFound, EventHandler<DeviceEventArgs> DeviceLost) public static void InitUPnP(EventHandler<DeviceEventArgs> DeviceFound, EventHandler<DeviceEventArgs> DeviceLost)
{ {
if (GlobalVars.UserConfiguration.UPnP) if (GlobalVars.UserConfiguration.UPnP)
@ -48,6 +50,7 @@ public static class NetFuncs
} }
} }
} }
}
#endregion
} }
#endregion
#endif #endif

View File

@ -10,9 +10,11 @@ using System.Windows.Forms;
using System.Collections.Generic; using System.Collections.Generic;
#endregion #endregion
#region Novetus Functions namespace Novetus.Core
public class NovetusFuncs
{ {
#region Novetus Functions
public class NovetusFuncs
{
public static string CopyMapToRBXAsset() public static string CopyMapToRBXAsset()
{ {
string clientcontentpath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\temp.rbxl"; string clientcontentpath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\temp.rbxl";
@ -126,7 +128,7 @@ public class NovetusFuncs
public static string GenerateAndReturnTripcode() public static string GenerateAndReturnTripcode()
{ {
//Powered by https://github.com/davcs86/csharp-uhwid //Powered by https://github.com/davcs86/csharp-uhwid
return UHWID.UHWIDEngine.AdvancedUid; return UHWIDEngine.AdvancedUid;
} }
public static void PingMasterServer(bool online, string reason) public static void PingMasterServer(bool online, string reason)
@ -299,13 +301,13 @@ public class NovetusFuncs
GlobalVars.Important = Name1 + Name2; GlobalVars.Important = Name1 + Name2;
GlobalVars.Important2 = SecurityFuncs.Encipher(GlobalVars.Important, random.Next(2, 13)); GlobalVars.Important2 = SecurityFuncs.Encipher(GlobalVars.Important, random.Next(2, 13));
} }
} }
#endregion #endregion
#region Roblox Helpers #region Roblox Helpers
#region Vector3 #region Vector3
public class Vector3 public class Vector3
{ {
public double X; public double X;
public double Y; public double Y;
public double Z; public double Z;
@ -316,12 +318,12 @@ public class Vector3
Y = aY; Y = aY;
Z = aZ; Z = aZ;
} }
} }
#endregion #endregion
#region Roblox File Types #region Roblox File Types
public enum RobloxFileType public enum RobloxFileType
{ {
//RBXL and RBXM //RBXL and RBXM
RBXL, RBXL,
RBXM, RBXM,
@ -334,12 +336,12 @@ public enum RobloxFileType
Pants, Pants,
Script, Script,
HeadNoCustomMesh HeadNoCustomMesh
} }
#endregion #endregion
#region Asset Cache Definition #region Asset Cache Definition
public class AssetCacheDefBasic public class AssetCacheDefBasic
{ {
public AssetCacheDefBasic(string clas, string[] id) public AssetCacheDefBasic(string clas, string[] id)
{ {
Class = clas; Class = clas;
@ -348,10 +350,10 @@ public class AssetCacheDefBasic
public string Class { get; set; } public string Class { get; set; }
public string[] Id { get; set; } public string[] Id { get; set; }
} }
public class AssetCacheDef : AssetCacheDefBasic public class AssetCacheDef : AssetCacheDefBasic
{ {
public AssetCacheDef(string clas, string[] id, string[] ext, public AssetCacheDef(string clas, string[] id, string[] ext,
string[] dir, string[] gamedir) : base(clas, id) string[] dir, string[] gamedir) : base(clas, id)
{ {
@ -363,12 +365,12 @@ public class AssetCacheDef : AssetCacheDefBasic
public string[] Ext { get; set; } public string[] Ext { get; set; }
public string[] Dir { get; set; } public string[] Dir { get; set; }
public string[] GameDir { get; set; } public string[] GameDir { get; set; }
} }
#endregion #endregion
#region Roblox Type Definitions #region Roblox Type Definitions
public struct RobloxDefs public struct RobloxDefs
{ {
//item defs below //item defs below
public static AssetCacheDef ItemHatFonts public static AssetCacheDef ItemHatFonts
{ {
@ -477,24 +479,24 @@ public struct RobloxDefs
new string[] { GlobalPaths.pantsGameDirTextures }); new string[] { GlobalPaths.pantsGameDirTextures });
} }
} }
} }
#endregion #endregion
#region XML Types #region XML Types
public enum XMLTypes public enum XMLTypes
{ {
Token, Token,
Bool, Bool,
Float, Float,
String, String,
Vector2Int16, Vector2Int16,
Int Int
} }
#endregion #endregion
#region Roblox XML Parser #region Roblox XML Parser
public static class RobloxXML public static class RobloxXML
{ {
public static void EditRenderSettings(XDocument doc, string setting, string value, XMLTypes type) public static void EditRenderSettings(XDocument doc, string setting, string value, XMLTypes type)
{ {
var v = from nodes in doc.Descendants("Item") var v = from nodes in doc.Descendants("Item")
@ -670,6 +672,7 @@ public static class RobloxXML
string r = "[\x00-\x08\x0B\x0C\x0E-\x1F]"; string r = "[\x00-\x08\x0B\x0C\x0E-\x1F]";
return Regex.Replace(txt, r, "", RegexOptions.Compiled); return Regex.Replace(txt, r, "", RegexOptions.Compiled);
} }
}
#endregion
#endregion
} }
#endregion
#endregion

View File

@ -14,9 +14,11 @@ using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
#endregion #endregion
#region Security Functions namespace Novetus.Core
public class SecurityFuncs
{ {
#region Security Functions
public class SecurityFuncs
{
[DllImport("user32.dll")] [DllImport("user32.dll")]
static extern int SetWindowText(IntPtr hWnd, string text); static extern int SetWindowText(IntPtr hWnd, string text);
@ -99,7 +101,7 @@ public class SecurityFuncs
string decode = base64EncodedData.Decrypt(); string decode = base64EncodedData.Decrypt();
return decode; return decode;
} }
catch(Exception) catch (Exception)
{ {
var base64EncodedBytes = Convert.FromBase64String(base64EncodedData); var base64EncodedBytes = Convert.FromBase64String(base64EncodedData);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes); return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
@ -176,10 +178,14 @@ public class SecurityFuncs
{ {
string rbxscript = GlobalPaths.BasePath + "\\clients\\" + client + "\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua"; string rbxscript = GlobalPaths.BasePath + "\\clients\\" + client + "\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua";
return CheckMD5(GlobalVars.SelectedClientInfo.ScriptMD5, rbxscript); return CheckMD5(GlobalVars.SelectedClientInfo.ScriptMD5, rbxscript);
} else { }
else
{
return true; return true;
} }
} else { }
else
{
return true; return true;
} }
} }
@ -378,5 +384,6 @@ public class SecurityFuncs
{ {
return Encipher(input, 26 - key); return Encipher(input, 26 - key);
} }
}
#endregion
} }
#endregion

View File

@ -20,10 +20,12 @@ using Mono.Nat;
#endif #endif
#endregion #endregion
#region Utils namespace Novetus.Core
public static class Util
{ {
#region Utils
public static class Util
{
#region Extensions #region Extensions
//This code was brought to you by: //This code was brought to you by:
//https://stackoverflow.com/questions/1926264/color-different-parts-of-a-richtextbox-string //https://stackoverflow.com/questions/1926264/color-different-parts-of-a-richtextbox-string
@ -730,7 +732,7 @@ public static class Util
{ {
try try
{ {
string[] NewlineChars = {Environment.NewLine, "\n"}; string[] NewlineChars = { Environment.NewLine, "\n" };
string[] lines = text.Split(NewlineChars, StringSplitOptions.None); string[] lines = text.Split(NewlineChars, StringSplitOptions.None);
ConsolePrintMultiLine(lines, type, notime, noLog); ConsolePrintMultiLine(lines, type, notime, noLog);
} }
@ -1042,14 +1044,14 @@ public static class Util
} }
#endregion #endregion
#endif #endif
} }
#endregion #endregion
#region Tab Control without Header #region Tab Control without Header
//https://stackoverflow.com/questions/23247941/c-sharp-how-to-remove-tabcontrol-border //https://stackoverflow.com/questions/23247941/c-sharp-how-to-remove-tabcontrol-border
public partial class TabControlWithoutHeader : TabControl public partial class TabControlWithoutHeader : TabControl
{ {
public TabControlWithoutHeader() public TabControlWithoutHeader()
{ {
if (!DesignMode) Multiline = true; if (!DesignMode) Multiline = true;
@ -1062,5 +1064,6 @@ public partial class TabControlWithoutHeader : TabControl
else else
base.WndProc(ref m); base.WndProc(ref m);
} }
}
#endregion
} }
#endregion

View File

@ -1,5 +1,6 @@
#region Usings #region Usings
using Ionic.Zip; using Ionic.Zip;
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;

View File

@ -1,4 +1,5 @@
using System.Windows.Forms; using Novetus.Core;
using System.Windows.Forms;
namespace NovetusLauncher namespace NovetusLauncher
{ {

View File

@ -6,6 +6,8 @@
* *
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using Novetus.Core;
namespace NovetusLauncher namespace NovetusLauncher
{ {
partial class LauncherFormCompact partial class LauncherFormCompact

View File

@ -1,5 +1,6 @@
#region Usings #region Usings
using Mono.Nat; using Mono.Nat;
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@ -6,6 +6,8 @@
* *
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using Novetus.Core;
namespace NovetusLauncher namespace NovetusLauncher
{ {
partial class LauncherFormExtended partial class LauncherFormExtended

View File

@ -10,6 +10,7 @@ using System.Reflection;
using Mono.Nat; using Mono.Nat;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using Novetus.Core;
#endregion #endregion
namespace NovetusLauncher namespace NovetusLauncher

View File

@ -1,5 +1,6 @@
#region Usings #region Usings
using Mono.Nat; using Mono.Nat;
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;

View File

@ -10,6 +10,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using NLog; using NLog;
using Novetus.Core;
namespace NovetusLauncher namespace NovetusLauncher
{ {

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@ -2,10 +2,11 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using System.IO; using System.IO;
using Novetus.Core;
#endregion #endregion
#region ClientScriptDocumentation #region ClientScriptDocumentation
public partial class ClientScriptDocumentation : Form public partial class ClientScriptDocumentation : Form
{ {
#region Constructor #region Constructor
public ClientScriptDocumentation() public ClientScriptDocumentation()

View File

@ -4,6 +4,7 @@ using System.Windows.Forms;
using System.IO; using System.IO;
using System.Globalization; using System.Globalization;
using System.Collections.Generic; using System.Collections.Generic;
using Novetus.Core;
#endregion #endregion
#region Client SDK #region Client SDK

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.IO; using System.IO;
using System.Text; using System.Text;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
#endregion #endregion

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@ -1,4 +1,5 @@
using System; using Novetus.Core;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;

View File

@ -1,5 +1,6 @@
#region Usings #region Usings
using NLog; using NLog;
using Novetus.Core;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;

View File

@ -1,5 +1,6 @@
#region Usings #region Usings
using Microsoft.Win32; using Microsoft.Win32;
using Novetus.Core;
using System; using System;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;

View File

@ -1,4 +1,5 @@
#region Usings #region Usings
using Novetus.Core;
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
#endregion #endregion

View File

@ -5,6 +5,7 @@ using System.Diagnostics;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using NLog; using NLog;
using Novetus.Core;
#endregion #endregion
namespace NovetusURI namespace NovetusURI

View File

@ -3,6 +3,7 @@ using System;
using System.Windows.Forms; using System.Windows.Forms;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using Novetus.Core;
#endregion #endregion
namespace NovetusURI namespace NovetusURI

View File

@ -1,5 +1,6 @@
#region Usings #region Usings
using NLog; using NLog;
using Novetus.Core;
using System; using System;
using System.IO; using System.IO;
using System.Threading; using System.Threading;