From f2da63fc4d49bd83208b7a8da6425c386bc4076d Mon Sep 17 00:00:00 2001 From: Natalie C Date: Thu, 25 Jun 2020 21:17:33 -0400 Subject: [PATCH] semi-working piece of crap --- AuroraLauncher/AuroraLauncher.csproj | 41 +- AuroraLauncher/Build.cs | 4 - AuroraLauncher/GUI.cs | 84 +- AuroraLauncher/LIBRARIES.txt | 7 - AuroraLauncher/OldGUI.cs | 148 ---- AuroraLauncher/OldGUI.designer.cs | 150 ---- AuroraLauncher/OldGui.resx | 123 --- AuroraLauncher/Program.cs | 164 +--- AuroraLauncher/Providers/Configuration.cs | 4 +- AuroraLauncher/Providers/EpicGames.cs | 7 +- AuroraLauncher/Settings.cs | 24 +- AuroraLauncher/app.config | 13 +- AuroraLauncher/packages.config | 7 + AuroraNative/AuroraNative.vcxproj | 15 +- AuroraNative/AuroraNative.vcxproj.filters | 20 +- AuroraNative/build.h | 6 - AuroraNative/curl.h | 86 ++ AuroraNative/dllmain.cpp | 11 +- AuroraNative/framework.h | 12 - AuroraNative/hook.cpp | 7 +- AuroraNative/hook.h | 8 +- AuroraNative/hooks.h | 130 --- AuroraNative/pch.cpp | 1 - AuroraNative/pch.h | 6 - AuroraNative/string.hpp | 19 - AuroraNative/url.cpp | 926 ---------------------- AuroraNative/url.hpp | 208 ----- AuroraNative/util.h | 10 +- AuroraServer/AuroraServer.csproj | 13 - AuroraServer/Program.cs | 24 - AuroraUnified.sln | 10 - 31 files changed, 237 insertions(+), 2051 deletions(-) delete mode 100644 AuroraLauncher/LIBRARIES.txt delete mode 100644 AuroraLauncher/OldGUI.cs delete mode 100644 AuroraLauncher/OldGUI.designer.cs delete mode 100644 AuroraLauncher/OldGui.resx create mode 100644 AuroraNative/curl.h delete mode 100644 AuroraNative/framework.h delete mode 100644 AuroraNative/hooks.h delete mode 100644 AuroraNative/pch.cpp delete mode 100644 AuroraNative/pch.h delete mode 100644 AuroraNative/string.hpp delete mode 100644 AuroraNative/url.cpp delete mode 100644 AuroraNative/url.hpp delete mode 100644 AuroraServer/AuroraServer.csproj delete mode 100644 AuroraServer/Program.cs diff --git a/AuroraLauncher/AuroraLauncher.csproj b/AuroraLauncher/AuroraLauncher.csproj index c2a1d07..559d739 100644 --- a/AuroraLauncher/AuroraLauncher.csproj +++ b/AuroraLauncher/AuroraLauncher.csproj @@ -6,7 +6,7 @@ Debug x64 {C6D5E15A-5A85-4F00-BECF-854A4A54B1EC} - WinExe + Exe AuroraLauncher FortniteLauncher v4.5.2 @@ -22,7 +22,7 @@ full false bin\Debug\ - TRACE;DEBUG;NATIVE NO_EGL GUI ONLINE + TRACE;DEBUG;NATIVE ONLINE prompt 4 true @@ -33,7 +33,7 @@ pdbonly true bin\Release\ - TRACE;NATIVE NO_EGL GUI ONLINE + TRACE;NATIVE ONLINE FAKE_API prompt 4 true @@ -52,6 +52,12 @@ AuroraMin.ico + + ..\packages\Portable.BouncyCastle.1.8.5.2\lib\net40\BouncyCastle.Crypto.dll + + + ..\packages\BrotliSharpLib.0.3.3\lib\net451\BrotliSharpLib.dll + ..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll @@ -65,19 +71,28 @@ ..\packages\RestSharp.106.11.4\lib\net452\RestSharp.dll + + ..\packages\System.Buffers.4.5.0\lib\netstandard1.1\System.Buffers.dll + + + ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll + + + ..\packages\Titanium.Web.Proxy.3.1.1301\lib\net45\Titanium.Web.Proxy.dll + - - Form - - - OldGui.cs - True True @@ -110,9 +125,6 @@ Gui.cs - - OldGui.cs - ResXFileCodeGenerator Resources.Designer.cs @@ -125,11 +137,6 @@ - - - PreserveNewest - - diff --git a/AuroraLauncher/Build.cs b/AuroraLauncher/Build.cs index 2f2f199..3a66a82 100644 --- a/AuroraLauncher/Build.cs +++ b/AuroraLauncher/Build.cs @@ -3,11 +3,7 @@ internal class Build { internal const string ClientExecutable = "FortniteClient-Win64-Shipping.exe"; -#if !NO_EGL - internal const string ClientArguments = ""; -#else internal const string ClientArguments = "-epicapp=Fortnite -epicenv=Prod -epiclocale=en-us -epicportal"; -#endif internal const string LauncherNative = "AuroraNative.dll"; internal const string LauncherUri = "https://aurorafn.dev"; diff --git a/AuroraLauncher/GUI.cs b/AuroraLauncher/GUI.cs index 23304b6..683115d 100644 --- a/AuroraLauncher/GUI.cs +++ b/AuroraLauncher/GUI.cs @@ -4,49 +4,71 @@ using System; using System.Diagnostics; using System.IO; +using System.Net; using System.Net.Mail; using System.Reflection; using System.Text.RegularExpressions; using System.Threading; +using System.Threading.Tasks; using System.Windows.Forms; +using Titanium.Web.Proxy; +using Titanium.Web.Proxy.EventArguments; +using Titanium.Web.Proxy.Http; +using Titanium.Web.Proxy.Models; namespace AuroraLauncher { partial class Gui : MaterialForm { - MaterialSkinManager _skinManager; + #region Field Region - public Configuration Configuration; + MaterialSkinManager _skinManager; Settings _settings; + ProxyServer _proxy; + Thread _commonHeartbeat; Thread _onlineHeartbeat; bool _onlinePaused; - bool _showedUpdate; Process _clientProcess; /// /// 0 = None, 1 = BattlEye, 2 = EasyAntiCheat /// - int _clientAnticheat = 2; // Forced to EAC, until added into Settings. + int _clientAnticheat = 1; // Forced to BE, until added into Settings. + + #endregion + + #region Property Region + + public Configuration Configuration { get; private set; } + + #endregion + + #region Constructor Region public Gui() { InitializeComponent(); + Text += $" [{App.Version}]"; + _skinManager = MaterialSkinManager.Instance; _skinManager.AddFormToManage(this); Configuration = new Configuration(); Configuration.Open(); - // Settings form manages SkinManager _settings = new Settings(this); - Text += $" [{App.Version}]"; + _proxy = new ProxyServer(); + _proxy.BeforeRequest += OnBeforeRequest; + + _proxy.AddEndPoint(new ExplicitProxyEndPoint(IPAddress.Any, 6000, true)); + _proxy.Start(); materialSingleLineTextFieldEmail.Text = Configuration.Email; materialSingleLineTextFieldPassword.Text = Configuration.Password; @@ -71,6 +93,24 @@ public Gui() #endif } + #endregion + + #region Method Region + + public async Task OnBeforeRequest(object sender, SessionEventArgs e) + { + Console.WriteLine(e.HttpClient.Request.Url); + + if (e.HttpClient.Request.Url.Contains(".epicgames.com")) + { + var builder = new UriBuilder(e.HttpClient.Request.Url); + + builder.Host = "aurorafn.dev"; + + e.HttpClient.Request.Url = builder.Uri.ToString(); + } + } + delegate void SetOnlineTextDelegate(string text); void SetOnlineText(string text) @@ -128,7 +168,7 @@ void CommonHeartbeat() SetHide(); } else - _clientProcess = null; // TODO: Probably a dumb hack? + _clientProcess = null; // TODO (Cyuubi): Probably a dumb hack? } else { @@ -202,20 +242,10 @@ private void materialRaisedButtonPasswordView_Click(object sender, EventArgs e) materialRaisedButtonPasswordView.Text = "Hide"; } - void DiscordClick() - { - Process.Start("https://discord.gg/AuroraFN"); - } + void DiscordClick() => Process.Start("https://discord.gg/AuroraFN"); - private void pictureBoxDiscord_Click(object sender, EventArgs e) - { - DiscordClick(); - } - - private void materialFlatButtonDiscord_Click(object sender, EventArgs e) - { - DiscordClick(); - } + private void pictureBoxDiscord_Click(object sender, EventArgs e) => DiscordClick(); + private void materialFlatButtonDiscord_Click(object sender, EventArgs e) => DiscordClick(); public static bool IsValidPath(string path) { @@ -288,7 +318,7 @@ private void materialRaisedButtonLaunch_Click(object sender, EventArgs e) return; } - // TODO: Fix this? + // TODO (Cyuubi): Fix this? if (materialSingleLineTextFieldPassword.Text.Contains(" ")) { MessageBox.Show("Invalid Password, are you sure it's correct?", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -334,14 +364,14 @@ private void materialRaisedButtonLaunch_Click(object sender, EventArgs e) return; } - var arguments = $"-AUTH_LOGIN={Configuration.Email} -AUTH_PASSWORD={Configuration.Password} -AUTH_TYPE=epic " + Configuration.Arguments; + var arguments = $"-AUTH_LOGIN={Configuration.Email} -AUTH_PASSWORD={Configuration.Password} -AUTH_TYPE=epic {Build.ClientArguments} {Configuration.Arguments}"; if (_clientAnticheat == 0) // None - arguments += $" {Build.ClientArguments} -noeac -nobe -fltoken=none"; + arguments += $" -noeac -nobe -fltoken=none"; else if (_clientAnticheat == 1) // BattlEye - arguments += $" {Build.ClientArguments} -noeac -fromfl=be -fltoken={Build.BeToken}"; + arguments += $" -noeac -fromfl=be -fltoken={Build.BeToken}"; else if (_clientAnticheat == 2) // EasyAntiCheat - arguments += $" {Build.ClientArguments} -nobe -fromfl=eac -fltoken={Build.EacToken}"; + arguments += $" -nobe -fromfl=eac -fltoken={Build.EacToken}"; _clientProcess = new Process { @@ -373,7 +403,7 @@ private void materialRaisedButtonLaunch_Click(object sender, EventArgs e) reader.Start(); #else - Helper.InjectDll(_clientProcess.Id, Build.LauncherNative); + Helper.InjectDll(_clientProcess.Id, nativePath); #endif // NATIVE } @@ -397,5 +427,7 @@ private void materialFlatButtonSettings_Click(object sender, EventArgs e) _settings.Location = Location; _settings.ShowDialog(); } + + #endregion } } diff --git a/AuroraLauncher/LIBRARIES.txt b/AuroraLauncher/LIBRARIES.txt deleted file mode 100644 index 84b2790..0000000 --- a/AuroraLauncher/LIBRARIES.txt +++ /dev/null @@ -1,7 +0,0 @@ -AuroraLauncher uses the following libraries: -- MaterialSkin -- Newtonsoft.Json -- RestSharp - -AuroraNative uses the following libraries: -- CxxUrl diff --git a/AuroraLauncher/OldGUI.cs b/AuroraLauncher/OldGUI.cs deleted file mode 100644 index 1132f8d..0000000 --- a/AuroraLauncher/OldGUI.cs +++ /dev/null @@ -1,148 +0,0 @@ -using AuroraLauncher.Providers; -using System; -using System.Diagnostics; -using System.IO; -using System.Reflection; -using System.Text.RegularExpressions; -using System.Windows.Forms; - -namespace AuroraLauncher -{ - public partial class OldGui : Form - { - static Process _clientProcess; - /// - /// 0 = None, 1 = BattlEye, 2 = EasyAntiCheat - /// - static byte _clientAnticheat = 2; // Forced to EAC. - - public OldGui() - { - InitializeComponent(); - - foreach (EpicGames.Installed.Installation installation - in EpicGames.LauncherInstalled.InstallationList) - { - if (installation.AppName == "Fortnite") - textBoxFortnitePath.Text = installation.InstallLocation; - } - } - - private void OldGui_FormClosing(object sender, FormClosingEventArgs e) - { - if (_clientProcess != null) - { - if (!_clientProcess.HasExited) - { - MessageBox.Show("You cannot close Aurora Launcher while Fortnite is running!", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information); - - e.Cancel = true; - } - } - } - - private void buttonBrowse_Click(object sender, EventArgs e) - { - if (folderBrowserDialogBrowse.ShowDialog() == DialogResult.OK) - textBoxFortnitePath.Text = folderBrowserDialogBrowse.SelectedPath; - } - - private void linkLabelDiscord_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - Process.Start("https://discord.gg/aurorafn"); - } - - private void buttonInfo_Click(object sender, EventArgs e) - { - var text = - "Having problems using Aurora? Make sure you follow these guidelines:\n" + - "- Your Fortnite is up-to-date.\n" + - "- Your username does not contain special characters.\n\n" + - "If you still seem to have problems, then please join our Discord server: https://discord.gg/aurorafn"; - - MessageBox.Show(text); - } - - private void buttonLaunch_Click(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(textBoxUsername.Text) || textBoxUsername.Text.Length < 3) - { - MessageBox.Show("Username cannot be empty or below 3 characters.", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - - textBoxUsername.Text = Regex.Replace(textBoxUsername.Text, "[^a-zA-Z0-9_.]+", string.Empty, RegexOptions.Compiled); - - // Sigh... - try - { - if (!Gui.IsValidPath(textBoxFortnitePath.Text)) - { - MessageBox.Show("Invalid Fortnite path.", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - } - catch - { - MessageBox.Show("Invalid Fortnite path.", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - - var clientPath = Path.Combine(textBoxFortnitePath.Text, $"FortniteGame\\Binaries\\Win64\\{Build.ClientExecutable}"); - if (!File.Exists(clientPath)) - { - MessageBox.Show($"\"{Build.ClientExecutable}\" was not found, please make sure it exists.", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - - var nativePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Build.LauncherNative); - if (!File.Exists(nativePath)) - { - MessageBox.Show($"\"{Build.LauncherNative}\" was not found, please make sure it exists.", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - - var formattedArguments = $"-AUTH_LOGIN=\"{textBoxUsername.Text}@unused.com\" -AUTH_PASSWORD=unused -AUTH_TYPE=epic"; - - if (_clientAnticheat == 0) // None - formattedArguments += $" {Build.ClientArguments} -noeac -nobe -fltoken=none"; - else if (_clientAnticheat == 1) // BattlEye - formattedArguments += $" {Build.ClientArguments} -noeac -fromfl=be -fltoken={Build.BeToken}"; - else if (_clientAnticheat == 2) // EasyAntiCheat - formattedArguments += $" {Build.ClientArguments} -nobe -fromfl=eac -fltoken={Build.EacToken}"; - - _clientProcess = new Process - { - StartInfo = new ProcessStartInfo(clientPath, formattedArguments) - { - UseShellExecute = false, - - RedirectStandardOutput = true, - - CreateNoWindow = false - } - }; - - _clientProcess.Start(); - -#if !NATIVE - // Allocate the console, for standard output. - Win32.AllocConsole(); - - // Setup an AsyncStreamReader, for standard output. - var reader = new AsyncStreamReader(_clientProcess.StandardOutput); - - reader.ValueRecieved += delegate (object sender, string value) - { - Console.ForegroundColor = ConsoleColor.White; - Console.Write(value); - Console.ForegroundColor = ConsoleColor.Gray; - }; - - reader.Start(); -#else - Helper.InjectDll(_clientProcess.Id, Build.LauncherNative); -#endif // NATIVE - } - } -} diff --git a/AuroraLauncher/OldGUI.designer.cs b/AuroraLauncher/OldGUI.designer.cs deleted file mode 100644 index d99c56a..0000000 --- a/AuroraLauncher/OldGUI.designer.cs +++ /dev/null @@ -1,150 +0,0 @@ -namespace AuroraLauncher -{ - partial class OldGui - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonLaunch = new System.Windows.Forms.Button(); - this.labelUsername = new System.Windows.Forms.Label(); - this.textBoxUsername = new System.Windows.Forms.TextBox(); - this.labelFortnitePath = new System.Windows.Forms.Label(); - this.textBoxFortnitePath = new System.Windows.Forms.TextBox(); - this.linkLabelDiscord = new System.Windows.Forms.LinkLabel(); - this.buttonBrowse = new System.Windows.Forms.Button(); - this.folderBrowserDialogBrowse = new System.Windows.Forms.FolderBrowserDialog(); - this.buttonInfo = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // buttonLaunch - // - this.buttonLaunch.Location = new System.Drawing.Point(262, 79); - this.buttonLaunch.Name = "buttonLaunch"; - this.buttonLaunch.Size = new System.Drawing.Size(60, 20); - this.buttonLaunch.TabIndex = 0; - this.buttonLaunch.Text = "Launch"; - this.buttonLaunch.UseVisualStyleBackColor = true; - this.buttonLaunch.Click += new System.EventHandler(this.buttonLaunch_Click); - // - // labelUsername - // - this.labelUsername.AutoSize = true; - this.labelUsername.Location = new System.Drawing.Point(12, 15); - this.labelUsername.Name = "labelUsername"; - this.labelUsername.Size = new System.Drawing.Size(58, 13); - this.labelUsername.TabIndex = 1; - this.labelUsername.Text = "Username:"; - // - // textBoxUsername - // - this.textBoxUsername.Location = new System.Drawing.Point(77, 12); - this.textBoxUsername.Name = "textBoxUsername"; - this.textBoxUsername.Size = new System.Drawing.Size(245, 20); - this.textBoxUsername.TabIndex = 2; - // - // labelFortnitePath - // - this.labelFortnitePath.AutoSize = true; - this.labelFortnitePath.Location = new System.Drawing.Point(12, 42); - this.labelFortnitePath.Name = "labelFortnitePath"; - this.labelFortnitePath.Size = new System.Drawing.Size(70, 13); - this.labelFortnitePath.TabIndex = 3; - this.labelFortnitePath.Text = "Fortnite Path:"; - // - // textBoxFortnitePath - // - this.textBoxFortnitePath.Location = new System.Drawing.Point(88, 39); - this.textBoxFortnitePath.Name = "textBoxFortnitePath"; - this.textBoxFortnitePath.Size = new System.Drawing.Size(203, 20); - this.textBoxFortnitePath.TabIndex = 4; - // - // linkLabelDiscord - // - this.linkLabelDiscord.AutoSize = true; - this.linkLabelDiscord.Location = new System.Drawing.Point(13, 86); - this.linkLabelDiscord.Name = "linkLabelDiscord"; - this.linkLabelDiscord.Size = new System.Drawing.Size(86, 13); - this.linkLabelDiscord.TabIndex = 5; - this.linkLabelDiscord.TabStop = true; - this.linkLabelDiscord.Text = "Join our Discord."; - this.linkLabelDiscord.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelDiscord_LinkClicked); - // - // buttonBrowse - // - this.buttonBrowse.Location = new System.Drawing.Point(297, 39); - this.buttonBrowse.Name = "buttonBrowse"; - this.buttonBrowse.Size = new System.Drawing.Size(25, 20); - this.buttonBrowse.TabIndex = 6; - this.buttonBrowse.Text = "..."; - this.buttonBrowse.UseVisualStyleBackColor = true; - this.buttonBrowse.Click += new System.EventHandler(this.buttonBrowse_Click); - // - // buttonInfo - // - this.buttonInfo.Location = new System.Drawing.Point(224, 79); - this.buttonInfo.Name = "buttonInfo"; - this.buttonInfo.Size = new System.Drawing.Size(35, 20); - this.buttonInfo.TabIndex = 7; - this.buttonInfo.Text = "Info"; - this.buttonInfo.UseVisualStyleBackColor = true; - this.buttonInfo.Click += new System.EventHandler(this.buttonInfo_Click); - // - // OldGUI - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(334, 111); - this.Controls.Add(this.buttonInfo); - this.Controls.Add(this.buttonBrowse); - this.Controls.Add(this.linkLabelDiscord); - this.Controls.Add(this.textBoxFortnitePath); - this.Controls.Add(this.labelFortnitePath); - this.Controls.Add(this.textBoxUsername); - this.Controls.Add(this.labelUsername); - this.Controls.Add(this.buttonLaunch); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.Name = "OldGUI"; - this.Text = "Aurora Launcher"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OldGui_FormClosing); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonLaunch; - private System.Windows.Forms.Label labelUsername; - private System.Windows.Forms.TextBox textBoxUsername; - private System.Windows.Forms.Label labelFortnitePath; - private System.Windows.Forms.TextBox textBoxFortnitePath; - private System.Windows.Forms.LinkLabel linkLabelDiscord; - private System.Windows.Forms.Button buttonBrowse; - private System.Windows.Forms.FolderBrowserDialog folderBrowserDialogBrowse; - private System.Windows.Forms.Button buttonInfo; - } -} \ No newline at end of file diff --git a/AuroraLauncher/OldGui.resx b/AuroraLauncher/OldGui.resx deleted file mode 100644 index fab6828..0000000 --- a/AuroraLauncher/OldGui.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - \ No newline at end of file diff --git a/AuroraLauncher/Program.cs b/AuroraLauncher/Program.cs index b5d5814..bd39b02 100644 --- a/AuroraLauncher/Program.cs +++ b/AuroraLauncher/Program.cs @@ -1,7 +1,4 @@ using System; -using System.Diagnostics; -using System.IO; -using System.Text.RegularExpressions; using System.Windows.Forms; namespace AuroraLauncher @@ -10,175 +7,22 @@ class Program { #region Field Region - static Process _clientProcess; - /// - /// 0 = None, 1 = BattlEye, 2 = EasyAntiCheat - /// - static byte _clientAnticheat; + static Gui _gui; #endregion #region Method Region -#if GUI [STAThread] -#endif // GUI static void Main(string[] args) { - var formattedArguments = string.Join(" ", args); - -#if GUI Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - - // Check if -NOSTALGIA exists in args (regardless of case) to run the old GUI. - if (!formattedArguments.ToUpper().Contains("-NOSTALGIA")) - Application.Run(new Gui()); - else - Application.Run(new OldGui()); -#else - // Check if -FORCEBE exists in args (regardless of case) to force BattlEye. - if (formattedArguments.ToUpper().Contains("-FORCEBE")) - { - formattedArguments = Regex.Replace(formattedArguments, "-FORCEBE", string.Empty, RegexOptions.IgnoreCase); - - _clientAnticheat = 1; - } - - // Check if -FORCEEAC exists in args (regardless of case) to force EasyAntiCheat. - if (formattedArguments.ToUpper().Contains("-FORCEEAC")) - { - formattedArguments = Regex.Replace(formattedArguments, "-FORCEEAC", string.Empty, RegexOptions.IgnoreCase); - - _clientAnticheat = 2; - } - - if (_clientAnticheat == 0) // None - formattedArguments += $" {Build.ClientArguments} -noeac -nobe -fltoken=none"; - else if (_clientAnticheat == 1) // BattlEye - formattedArguments += $" {Build.ClientArguments} -noeac -fromfl=be -fltoken={Build.BeToken}"; - else if (_clientAnticheat == 2) // EasyAntiCheat - formattedArguments += $" {Build.ClientArguments} -nobe -fromfl=eac -fltoken={Build.EacToken}"; - -#if !NATIVE - Win32.AllocConsole(); -#endif // NATIVE - - // Check if the client exists in the current work path, if it doesn't, just exit. - if (!File.Exists(Build.ClientExecutable)) - { -#if NATIVE - Win32.AllocConsole(); -#endif // NATIVE - - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine($"\"{Build.ClientExecutable}\" was not found, please make sure it exists."); - Console.ForegroundColor = ConsoleColor.Gray; - Console.ReadKey(); - - return; - } - -#if NATIVE - // Check if the native exists in the current work path, if it doesn't, just exit. - if (!File.Exists(Build.ClientNative)) - { - Win32.AllocConsole(); - - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine($"\"{Build.ClientNative}\" was not found, please make sure it exists."); - Console.ForegroundColor = ConsoleColor.Gray; - Console.ReadKey(); - - return; - } -#endif // NATIVE - -#if !NATIVE - Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine("Aurora, made with <3 by Cyuubi and Slushia."); - Console.WriteLine("Discord: https://discord.gg/aurorafn\n"); - Console.ForegroundColor = ConsoleColor.Gray; -#endif // NATIVE - - _clientProcess = new Process - { - StartInfo = new ProcessStartInfo(Build.ClientExecutable, formattedArguments) - { - UseShellExecute = false, - - RedirectStandardOutput = true, - - CreateNoWindow = false - } - }; -#if !NO_EGL - Swap(); // Swap the launcher, to prevent Fortnite from detecting it. -#endif // NO_EGL - - _clientProcess.Start(); - -#if !NATIVE - // Setup a HandlerRoutine, for detecting when the console closes. - Win32.SetConsoleCtrlHandler(new Win32.HandlerRoutine(Routine), true); - - // Setup an AsyncStreamReader, for standard output. - var reader = new AsyncStreamReader(_clientProcess.StandardOutput); - - reader.ValueRecieved += delegate (object sender, string value) - { - Console.ForegroundColor = ConsoleColor.White; - Console.Write(value); - Console.ForegroundColor = ConsoleColor.Gray; - }; - - reader.Start(); -#else - Helper.InjectDll(_clientProcess.Id, Build.ClientNative); -#endif // NATIVE - - _clientProcess.WaitForExit(); // Wait for the client process to exit. - -#if !NO_EGL - Swap(); // Before exiting... Swap the launcher, again. -#endif // NO_EGL -#endif // GUI - } - - static void Swap() - { - // Custom -> Original - if (File.Exists("FortniteLauncher.exe.original")) - { - File.Move("FortniteLauncher.exe", "FortniteLauncher.exe.custom"); - File.Move("FortniteLauncher.exe.original", "FortniteLauncher.exe"); - } - - // Original -> Custom - if (File.Exists("FortniteLauncher.exe.custom")) - { - File.Move("FortniteLauncher.exe", "FortniteLauncher.exe.original"); - File.Move("FortniteLauncher.exe.custom", "FortniteLauncher.exe"); - } - } - - static bool Routine(int dwCtrlType) - { - switch (dwCtrlType) - { - case 2: - { - if (!_clientProcess.HasExited) - _clientProcess.Kill(); - - break; - } - } + Application.SetCompatibleTextRenderingDefault(false); - return false; + Application.Run(_gui = new Gui()); } -#endregion + #endregion } } diff --git a/AuroraLauncher/Providers/Configuration.cs b/AuroraLauncher/Providers/Configuration.cs index c535627..fed47d4 100644 --- a/AuroraLauncher/Providers/Configuration.cs +++ b/AuroraLauncher/Providers/Configuration.cs @@ -14,9 +14,8 @@ class Configuration #region Property Region - [JsonProperty("InstallLocation")] //required because fucking confuserex + [JsonProperty("InstallLocation")] public string InstallLocation { get; set; } - [JsonProperty("Arguments")] public string Arguments { get; set; } @@ -35,7 +34,6 @@ class Configuration #region Method Region - // TODO: Add configuration file to Build.cs. public void Open() { if (File.Exists(_path)) diff --git a/AuroraLauncher/Providers/EpicGames.cs b/AuroraLauncher/Providers/EpicGames.cs index 7c7ce3f..bb71a31 100644 --- a/AuroraLauncher/Providers/EpicGames.cs +++ b/AuroraLauncher/Providers/EpicGames.cs @@ -42,7 +42,12 @@ static Installed GetLauncherInstalled() "Epic\\UnrealEngineLauncher\\LauncherInstalled.dat"); if (!File.Exists(path)) - return new Installed(); + { + return new Installed() + { + InstallationList = new Installed.Installation[0] + }; + } else return JsonConvert.DeserializeObject(File.ReadAllText(path)); } diff --git a/AuroraLauncher/Settings.cs b/AuroraLauncher/Settings.cs index 6e6c4de..b353a99 100644 --- a/AuroraLauncher/Settings.cs +++ b/AuroraLauncher/Settings.cs @@ -8,10 +8,16 @@ namespace AuroraLauncher { partial class Settings : MaterialForm { + #region Field Region + Gui _gui; MaterialSkinManager _skinManager; + #endregion + + #region Constructor Region + public Settings(Gui gui) { InitializeComponent(); @@ -34,24 +40,20 @@ public Settings(Gui gui) materialSingleLineTextFieldArguments.Text = _gui.Configuration.Arguments; } + #endregion + + #region Method Region + void Save() { _gui.Configuration.InstallLocation = materialSingleLineTextFieldInstallLocation.Text; - _gui.Configuration.Arguments = materialSingleLineTextFieldArguments.Text; _gui.Configuration.Save(); } - private void Settings_FormClosing(object sender, FormClosingEventArgs e) - { - Save(); - } - - private void materialRaisedButtonSave_Click(object sender, EventArgs e) - { - Save(); - } + private void Settings_FormClosing(object sender, FormClosingEventArgs e) => Save(); + private void materialRaisedButtonSave_Click(object sender, EventArgs e) => Save(); private void materialFlatButtonInstallLocationBrowse_Click(object sender, EventArgs e) { @@ -75,5 +77,7 @@ private void materialRadioButtonThemeDark_CheckedChanged(object sender, EventArg _skinManager.Theme = _gui.Configuration.DarkMode ? MaterialSkinManager.Themes.DARK : MaterialSkinManager.Themes.LIGHT; } + + #endregion } } diff --git a/AuroraLauncher/app.config b/AuroraLauncher/app.config index ff99501..0890152 100644 --- a/AuroraLauncher/app.config +++ b/AuroraLauncher/app.config @@ -1,3 +1,12 @@ - + - + + + + + + + + + + diff --git a/AuroraLauncher/packages.config b/AuroraLauncher/packages.config index 7a6927c..a00c932 100644 --- a/AuroraLauncher/packages.config +++ b/AuroraLauncher/packages.config @@ -1,8 +1,15 @@  + + + + + + + \ No newline at end of file diff --git a/AuroraNative/AuroraNative.vcxproj b/AuroraNative/AuroraNative.vcxproj index 7a768ad..6687929 100644 --- a/AuroraNative/AuroraNative.vcxproj +++ b/AuroraNative/AuroraNative.vcxproj @@ -55,7 +55,7 @@ - Use + NotUsing Level3 true _DEBUG;AURORANATIVE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) @@ -70,7 +70,7 @@ - Use + NotUsing Level3 true true @@ -94,21 +94,12 @@ xcopy "$(TargetPath)" "$(SolutionDir)Build\" /F /I /R /Y - - - - + - - - Create - Create - - diff --git a/AuroraNative/AuroraNative.vcxproj.filters b/AuroraNative/AuroraNative.vcxproj.filters index 3acbbb2..933294f 100644 --- a/AuroraNative/AuroraNative.vcxproj.filters +++ b/AuroraNative/AuroraNative.vcxproj.filters @@ -15,28 +15,16 @@ - - Header Files - - - Header Files - Header Files - - Header Files - - - Header Files - Header Files Header Files - + Header Files @@ -44,12 +32,6 @@ Source Files - - Source Files - - - Source Files - Source Files diff --git a/AuroraNative/build.h b/AuroraNative/build.h index 938971e..7f4e7a2 100644 --- a/AuroraNative/build.h +++ b/AuroraNative/build.h @@ -1,9 +1,3 @@ #pragma once -//#define LOCALHOST // Enables Localhost servers -#define ONLINE // Enables Online servers - -#define DISABLE_PINNING // Disables SSL pinning -//#define DISABLE_PROXY // Disables proxy - //#define VERBOSE // Enables verbose logging \ No newline at end of file diff --git a/AuroraNative/curl.h b/AuroraNative/curl.h new file mode 100644 index 0000000..de67ffd --- /dev/null +++ b/AuroraNative/curl.h @@ -0,0 +1,86 @@ +#ifndef CURL_H +#define CURL_H + +#include +#include + +#include "util.h" +#include "hook.h" + +LPVOID lpCurlSetopt; + +LPVOID lpCurlEasySetopt; +VHook* pCurlEasySetoptHook; + +LONG(*CurlSetopt)(LPVOID, INT, va_list) = nullptr; +LONG CurlSetoptVa(LPVOID lpContext, INT iOption, ...) { + va_list pArg; + + LONG lResult; + + va_start(pArg, iOption); + + lResult = CurlSetopt(lpContext, iOption, pArg); + + va_end(pArg); + + return lResult; +} + +LONG CurlEasySetopt(LPVOID lpContext, INT iTag, ...) { + va_list pArg; + + LONG lResult; + + if (lpContext == nullptr) + return 43; // CURLE_BAD_FUNCTION_ARGUMENT + + va_start(pArg, iTag); + + switch (iTag) { + case 64: // CURLOPT_SSL_VERIFYPEER + lResult = CurlSetoptVa(lpContext, 10004, "http://127.0.0.1:6000/"); // TODO (Cyuubi): Probably should de-hardcode this, eventually. (aka, never) + lResult = CurlSetoptVa(lpContext, 64, false); + break; + + default: + lResult = CurlSetopt(lpContext, iTag, pArg); + break; + } + + va_end(pArg); + + return lResult; +} + +VOID InitCurl() { + auto pCurlSetoptAddress = Util::FindPattern("\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x57\x48\x83\xEC\x30\x33\xED\x49\x8B\xF0\x48\x8B\xD9", "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + if (!pCurlSetoptAddress) { + MessageBox(NULL, (LPCWSTR)L"Finding pattern for CurlSetopt has failed, please re-open Fortnite and try again!", (LPCWSTR)L"Error", MB_ICONERROR); + exit(EXIT_FAILURE); + } + +#ifdef VERBOSE + printf("pCurlSetoptAddress: %" PRIXPTR "\n", pCurlSetoptAddress); +#endif // VERBOSE + + auto pCurlEasySetoptAddress = Util::FindPattern("\x89\x54\x24\x10\x4C\x89\x44\x24\x18\x4C\x89\x4C\x24\x20\x48\x83\xEC\x28\x48\x85\xC9\x75\x08\x8D\x41\x2B\x48\x83\xC4\x28\xC3\x4C", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + if (!pCurlEasySetoptAddress) { + MessageBox(NULL, (LPCWSTR)L"Finding pattern for CurlEasySetopt has failed, please re-open Fortnite and try again!", (LPCWSTR)L"Error", MB_ICONERROR); + exit(EXIT_FAILURE); + } + +#ifdef VERBOSE + printf("pCurlEasySetoptAddress: %" PRIXPTR "\n", pCurlEasySetoptAddress); +#endif // VERBOSE + + lpCurlSetopt = reinterpret_cast(pCurlSetoptAddress); + CurlSetopt = reinterpret_cast(lpCurlSetopt); + + lpCurlEasySetopt = reinterpret_cast(pCurlEasySetoptAddress); + + pCurlEasySetoptHook = new VHook(); + pCurlEasySetoptHook->Hook((uintptr_t)lpCurlEasySetopt, (uintptr_t)CurlEasySetopt); +} + +#endif // CURL_H diff --git a/AuroraNative/dllmain.cpp b/AuroraNative/dllmain.cpp index 9dc0e5a..d25d6bc 100644 --- a/AuroraNative/dllmain.cpp +++ b/AuroraNative/dllmain.cpp @@ -1,15 +1,14 @@ -#include "pch.h" +#include #include "util.h" -#include "hooks.h" +#include "curl.h" VOID Main() { +//#ifdef VERBOSE Util::InitConsole(); +//#endif - printf("Aurora, made with <3 by Cyuubi and Slushia.\n"); - printf("Discord: https://discord.gg/AuroraFN\n\n"); - - InitHooks(); + InitCurl(); } BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) { diff --git a/AuroraNative/framework.h b/AuroraNative/framework.h deleted file mode 100644 index 8e88283..0000000 --- a/AuroraNative/framework.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "build.h" - -#include -#include -#include - -#include -#include -#include -#include diff --git a/AuroraNative/hook.cpp b/AuroraNative/hook.cpp index bdd8e00..70217e9 100644 --- a/AuroraNative/hook.cpp +++ b/AuroraNative/hook.cpp @@ -1,4 +1,3 @@ -#include "pch.h" #include "hook.h" #define XIP Rip @@ -10,11 +9,11 @@ PVOID VHook::hHandle = nullptr; DWORD VHook::dwProtect = 0; -BOOL VHook::Hook(uintptr_t pTarget = 0, uintptr_t pDetour = 0) +BOOL VHook::Hook(uintptr_t pTarget = -1, uintptr_t pDetour = -1) { - if (pTarget != 0) + if (pTarget != -1) VHook::pTarget = pTarget; - if (pDetour != 0) + if (pDetour != -1) VHook::pDetour = pDetour; if (IsSamePage((const uint8_t*)pTarget, (const uint8_t*)pDetour)) diff --git a/AuroraNative/hook.h b/AuroraNative/hook.h index d5102db..2b813fe 100644 --- a/AuroraNative/hook.h +++ b/AuroraNative/hook.h @@ -1,6 +1,8 @@ -#pragma once +#ifndef HOOK_H +#define HOOK_H -#include "pch.h" +#include +#include class VHook { private: @@ -19,3 +21,5 @@ class VHook { static BOOL IsSamePage(const uint8_t* pFirstAddress, const uint8_t* pSecondAddress); }; + +#endif // HOOK_H diff --git a/AuroraNative/hooks.h b/AuroraNative/hooks.h deleted file mode 100644 index 60570b5..0000000 --- a/AuroraNative/hooks.h +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef HOOKS_H -#define HOOKS_H - -#include "pch.h" - -#include "hook.h" -#include "url.hpp" - -LPVOID lpCurlSetopt; -LPVOID lpCurlEasySetopt; - -VHook* pCurlEasySetoptHook; - -LONG(*CurlSetopt)(LPVOID, INT, va_list) = nullptr; - -inline LONG CurlSetoptVa(LPVOID lpContext, INT iOption, ...) { - va_list arg; - LONG result; - - va_start(arg, iOption); - - result = CurlSetopt(lpContext, iOption, arg); - - va_end(arg); - - return result; -} - -inline LONG CurlEasySetopt(LPVOID lpContext, INT iTag, ...) { - va_list arg, copy; - LONG result; - - if (lpContext == nullptr) - return 43; // CURLE_BAD_FUNCTION_ARGUMENT - - va_start(arg, iTag); - - if (IsDebuggerPresent()) - exit(EXIT_FAILURE); - - if (iTag == 10002) { // CURLOPT_URL - va_copy(copy, arg); - - std::string url(va_arg(copy, char*)); - - if (url.find(".epicgames.com") != std::string::npos) { - Url redirect(url); - -#ifdef LOCALHOST - redirect.scheme("http").host("localhost"); -#endif // LOCALHOST -#ifdef ONLINE - redirect.host("aurorafn.dev"); -#endif // ONLINE - - url = redirect.str(); - } - -#ifdef VERBOSE - printf("CurlEasySetopt (va): tag = %i, url = %s\n", tag, url.c_str()); -#endif // VERBOSE - - result = CurlSetoptVa(lpContext, iTag, url.c_str()); - - va_end(copy); -#ifdef DISABLE_PINNING - } else if (iTag == 64) { // CURLOPT_SSL_VERIFYPEER -#ifdef VERBOSE - printf("CurlEasySetopt (va): tag = %i\n", tag); -#endif // VERBOSE - - result = CurlSetoptVa(lpContext, iTag, false); -#endif // DISABLE_PINNING -#ifdef DISABLE_PROXY - } else if (iTag == 10004) { // CURLOPT_PROXY -#ifdef VERBOSE - printf("CurlEasySetopt (va): tag = %i\n", tag); -#endif // VERBOSE - - result = CurlSetoptVa(lpContext, iTag, ""); -#endif // DISABLE_PROXY - } else { -#ifdef VERBOSE - printf("CurlEasySetopt: tag = %i\n", tag); -#endif // VERBOSE - - result = CurlSetopt(lpContext, iTag, arg); - } - -#ifdef VERBOSE - printf("CurlSetopt: result = %i\n", result); -#endif // VERBOSE - - va_end(arg); - - return result; -} - -VOID InitHooks() { - auto pCurlEasySetoptAddress = Util::FindPattern("\x89\x54\x24\x10\x4C\x89\x44\x24\x18\x4C\x89\x4C\x24\x20\x48\x83\xEC\x28\x48\x85\xC9\x75\x08\x8D\x41\x2B\x48\x83\xC4\x28\xC3\x4C", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); - if (!pCurlEasySetoptAddress) { - printf("Finding pattern for CurlEasySetopt has failed, exiting immediately!\n"); - exit(EXIT_FAILURE); - } - -#ifdef VERBOSE - printf("lpCurlEasySetoptAddress: %" PRIXPTR "\n", lpCurlEasySetoptAddress); -#endif // VERBOSE - - auto pCurlSetoptAddress = Util::FindPattern("\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x57\x48\x83\xEC\x30\x33\xED\x49\x8B\xF0\x48\x8B\xD9", "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"); - if (!pCurlSetoptAddress) { - printf("Finding pattern for CurlSetopt has failed, exiting immediately!\n"); - exit(EXIT_FAILURE); - } - -#ifdef VERBOSE - printf("lpCurlSetoptAddress: %" PRIXPTR "\n", lpCurlSetoptAddress); -#endif // VERBOSE - - lpCurlSetopt = reinterpret_cast(pCurlSetoptAddress); - lpCurlEasySetopt = reinterpret_cast(pCurlEasySetoptAddress); - - pCurlEasySetoptHook = new VHook(); - - CurlSetopt = reinterpret_cast(lpCurlSetopt); - - pCurlEasySetoptHook->Hook((uintptr_t)lpCurlEasySetopt, (uintptr_t)CurlEasySetopt); -} - -#endif // HOOKS_H diff --git a/AuroraNative/pch.cpp b/AuroraNative/pch.cpp deleted file mode 100644 index 1d9f38c..0000000 --- a/AuroraNative/pch.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "pch.h" diff --git a/AuroraNative/pch.h b/AuroraNative/pch.h deleted file mode 100644 index 75144ca..0000000 --- a/AuroraNative/pch.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef PCH_H -#define PCH_H - -#include "framework.h" - -#endif // PCH_H diff --git a/AuroraNative/string.hpp b/AuroraNative/string.hpp deleted file mode 100644 index 16194c1..0000000 --- a/AuroraNative/string.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef STRING_H -#define STRING_H - -#include -#include - -#ifdef ANDROID_PLATFORM -namespace std -{ - template < typename T > std::string to_string( const T& n ) - { - std::ostringstream stm ; - stm << n ; - return stm.str() ; - } -} -#endif - -#endif diff --git a/AuroraNative/url.cpp b/AuroraNative/url.cpp deleted file mode 100644 index 7d07407..0000000 --- a/AuroraNative/url.cpp +++ /dev/null @@ -1,926 +0,0 @@ -#include "pch.h" - -#include "url.hpp" -//#include -#include -#include -#include -#include -#include -#include - - - - -namespace { - -static const uint8_t tbl[256] = { - 0,0,0,0, 0,0,0,0, // NUL SOH STX ETX EOT ENQ ACK BEL - 0,0,0,0, 0,0,0,0, // BS HT LF VT FF CR SO SI - 0,0,0,0, 0,0,0,0, // DLE DC1 DC2 DC3 DC4 NAK SYN ETB - 0,0,0,0, 0,0,0,0, // CAN EM SUB ESC FS GS RS US - 0x00,0x01,0x00,0x00, 0x01,0x20,0x01,0x01, // SP ! " # $ % & ' - 0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x08, // ( ) * + , - . / - 0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01, // 0 1 2 3 4 5 6 7 - 0x01,0x01,0x04,0x01, 0x00,0x01,0x00,0x10, // 8 9 : ; < = > ? - 0x02,0x01,0x01,0x01, 0x01,0x01,0x01,0x01, // @ A B C D E F G - 0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01, // H I J K L M N O - 0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01, // P Q R S T U V W - 0x01,0x01,0x01,0x00, 0x00,0x00,0x00,0x01, // X Y Z [ \ ] ^ _ - 0x00,0x01,0x01,0x01, 0x01,0x01,0x01,0x01, // ` a b c d e f g - 0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01, // h i j k l m n o - 0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01, // p q r s t u v w - 0x01,0x01,0x01,0x00, 0x00,0x00,0x01,0x00, // x y z { | } ~ DEL - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0 -}; - - -inline bool is_char(char c, std::uint8_t mask) { - return (tbl[static_cast(c)]&mask) != 0; -} - - -inline bool is_chars(const char* s, const char* e, std::uint8_t mask) { - while(s!=e) - if (!is_char(*s++,mask)) - return false; - return true; -} - - -inline bool is_alpha(char c) { - return (c>='A'&&c<='Z')||(c>='a'&&c<='z'); -} - - -inline bool is_num(char c) { - return c>='0'&&c<='9'; -} - - -inline bool is_alnum(char c) { - return is_alpha(c)||is_num(c); -} - - -inline bool is_hexdigit(char c) { - return is_num(c)||(c>='A'&&c<='F')||(c>='a'&&c<='f'); -} - - -inline bool is_uint(const char *&s, const char *e, uint32_t max) { - if (s==e || !is_num(*s)) - return false; - const char *t=s; - uint32_t val = *t++-'0'; - if (val) - while(t!=e && is_num(*t)) - val=val*10+(*t++-'0'); - if (val>max) - return false; - s=t; - return true; -} - - -inline bool is_pchars(const char *s, const char *e) { - return is_chars(s, e, 0x07); -} - - -inline char get_hex_digit(char c) { - if (c>='0'&&c<='9') - return c-'0'; - if (c>='A'&&c<='F') - return c-'A'+10; - if (c>='a'&&c<='f') - return c-'a'+10; - return -1; -} - - -inline void to_lower(std::string& s) { - for(auto& c : s) - if (c>='A' && c<='Z') - c |= 0x20; -} - - -inline const char* find_first_of(const char *s, const char *e, const char *q) { - for(; s!=e; ++s) - for(const char *t=q; *t; ++t) - if (*s==*t) - return s; - return e; -} - - -inline const char* find_char(const char *s, const char *e, const char c) { - while (s!=e && *s!=c) - ++s; - return s; -} - - -inline bool is_scheme(const char *s, const char *e) -{ - if (!s||!e||s==e||!is_alpha(*s)) - return false; - char c; - while(++s!=e) - if (!is_alnum(c=*s)&&c!='+'&&c!='-'&&c!='.') - return false; - return true; -} - - -inline bool is_scheme(const std::string &s) { - return is_scheme(s.data(),s.data()+s.length()); -} - - -std::string normalize_scheme(const char *b, const char *e) { - std::string o(b,e-b); - to_lower(o); - return o; -} - - -inline bool is_ipv4(const char *s, const char *e) { - size_t l=e-s; - if (l<7 || l>254) - return false; - for (const char *p=s; p!=e; ++p) - if (*p!='.'&&!is_num(*p)) - return false; - return true; -} - - -inline bool is_ipv4(const std::string &s) { - return is_ipv4(s.data(),s.data()+s.length()); -} - - -inline bool is_valid_ipv4(const char *s, const char *e) { - return is_uint(s,e,255) && s!=e && *s++=='.' && - is_uint(s,e,255) && s!=e && *s++=='.' && - is_uint(s,e,255) && s!=e && *s++=='.' && - is_uint(s,e,255) && s==e; -} - - -inline bool is_valid_ipv4(const std::string &s) { - return is_valid_ipv4(s.data(),s.data()+s.length()); -} - - -inline bool is_reg_name(const char *s, const char *e) { - return is_chars(s, e, 0x01); -} - - -inline bool is_reg_name(const std::string &s) { - return is_reg_name(s.data(),s.data()+s.length()); -} - - -std::string normalize_reg_name(const std::string& s) { - std::string o(s); - to_lower(o); // see rfc 4343 - return o; -} - - -bool is_ipv6(const char *s, const char *e) { - size_t l=e-s; - if (l<2 || l>254) - return false; - for (const char *p=s; p!=e; ++p) - if (*p!=':'&&*p!='.'&&!is_hexdigit(*p)) - return false; - return true; -} - - -inline bool is_ipv6(const std::string &s) { - return is_ipv6(s.data(),s.data()+s.length()); -} - - -bool is_valid_ipv6(const char *s, const char *e) { - if ((e-s)>39||(e-s)<2) - return false; - bool null_field=false; - const char *b=s, *p=s; - int nfields=0, ndigits=0; - if (p[0]==':') { - if (p[1]!=':') - return false; - null_field=true; - b=(p+=2); - if (p==e) - return true; - } - while(p!=e) { - if (*p=='.') { - return ((!null_field&&nfields==6)||(null_field&&nfields<7))&&is_valid_ipv4(b, e); - } else if (*p==':') { - if (ndigits==0) { - if (null_field) - return false; - null_field=true; - } else { - ++nfields; - ndigits=0; - } - b=++p; - } else { - if ((++ndigits>4) || !is_hexdigit(*p++)) - return false; - } - } - if (ndigits>0) - ++nfields; - else { - if (e[-1]==':') { - if (e[-2]==':' && nfields<8) - return true; - return false; - } - } - return (!null_field&&nfields==8)||(null_field&&nfields<8); -} - - -inline bool is_valid_ipv6(const std::string &s) { - return is_valid_ipv6(s.data(),s.data()+s.length()); -} - - -std::string normalize_IPv6(const char *s, const char *e) { - if (!is_ipv6(s, e)) - throw Url::parse_error("IPv6 ["+std::string(s,e-s)+"] is invalid"); - if ((e-s)==2 && s[0]==':' && s[1]==':') - return std::string(s,e-s); - - // Split IPv6 at colons - const char *p=s, *tokens[10]; - if (*p==':') - ++p; - if (e[-1]==':') - --e; - const char *b=p; - size_t i=0; - while (p!=e) { - if (*p++==':') { - tokens[i++]=b; - b=p; - } - } - if (i<8) - tokens[i++]=b; - tokens[i]=p; - size_t ntokens=i; - - // Get IPv4 address which is normalized by default - const char *ipv4_b=nullptr, *ipv4_e=nullptr; - if ((tokens[ntokens]-tokens[ntokens-1])>5) { - ipv4_b=tokens[ntokens-1]; - ipv4_e=tokens[ntokens]; - --ntokens; - } - - // Decode the fields - std::uint16_t fields[8]; - size_t null_pos=8, null_len=0, nfields=0; - for(size_t i=0; inull_len) { - null_pos=first; - null_len=i-first; - } - if (i==nfields) - break; - } - if (null_len==1) { - null_pos=nfields; - null_len=1; - } - - // Encode normalized IPv6 - std::stringstream str; - if (null_pos==0) { - str << std::hex << ':'; - i=null_len; - } else { - str << std::hex << fields[0]; - for (i=1; i elems; - std::stringstream si(s); - - while(!std::getline(si, elem, '/').eof()){ - if (elem=="" || elem==".") - continue; - if (elem=="..") { - if (!elems.empty()) - elems.pop_back(); - continue; - } - elems.push_back(elem); - } - if (elem==".") - elems.push_back(""); - else if (elem=="..") { - if (!elems.empty()) - elems.pop_back(); - } - else - elems.push_back(elem); - - std::stringstream so; - if (s[0]=='/') - so << '/'; - if (!elems.empty()) { - auto it=elems.begin(), end=elems.end(); - so << *it; - while(++it!=end) - so << '/' << *it; - } - return so.str(); -} - - -std::string decode(const char *s, const char *e) { - std::string o; - o.reserve(e-s); - while(s!=e) { - char c=*s++, a, b; - if (c=='%') { - if (s==e || (a=get_hex_digit(*s++))<0 || s==e || (b=get_hex_digit(*s++))<0) - throw Url::parse_error("Invalid percent encoding"); - c=(a<<4)|b; - } - o.push_back(c); - } - return o; -} - - -std::string decode_plus(const char *s, const char *e) { - std::string o; - o.reserve(e-s); - while(s!=e) { - char c=*s++, a, b; - if (c=='+') - c=' '; - else if (c=='%') { - if (s==e || (a=get_hex_digit(*s++))<0 || s==e || (b=get_hex_digit(*s++))<0) - throw Url::parse_error("Invalid percent encoding"); - c=(a<<4)|b; - } - o.push_back(c); - } - return o; -} - - -class encode { - public: - encode(const std::string& s, std::uint8_t mask) : m_s(s), m_mask(mask) {} - private: - const std::string& m_s; - std::uint8_t m_mask; - friend std::ostream& operator<< (std::ostream& o, const encode& e) { - for (const char c:e.m_s) - if (is_char(c,e.m_mask)) - o<>4]<<"0123456789ABCDEF"[c&0xF]; - return o; - } -}; - - -class encode_query_key { - public: - encode_query_key(const std::string& s, std::uint8_t mask) : m_s(s), m_mask(mask) {} - private: - const std::string& m_s; - std::uint8_t m_mask; - friend std::ostream& operator<< (std::ostream& o, const encode_query_key& e) { - for (const char c:e.m_s) - if (c==' ') - o<<'+'; - else if (c=='+') - o<<"%2B"; - else if (c=='=') - o<<"%3D"; - else if (c=='&') - o<<"%26"; - else if (c==';') - o<<"%3B"; - else if (is_char(c,e.m_mask)) - o<>4]<<"0123456789ABCDEF"[c&0xF]; - return o; - } -}; - - -class encode_query_val { - public: - encode_query_val(const std::string& s, std::uint8_t mask) : m_s(s), m_mask(mask) {} - private: - const std::string& m_s; - std::uint8_t m_mask; - friend std::ostream& operator<< (std::ostream& o, const encode_query_val& e) { - for (const char c:e.m_s) - if (c==' ') - o<<'+'; - else if (c=='+') - o<<"%2B"; - else if (c=='&') - o<<"%26"; - else if (c==';') - o<<"%3B"; - else if (is_char(c,e.m_mask)) - o<>4]<<"0123456789ABCDEF"[c&0xF]; - return o; - } -}; - - - -} // end of anonymous namnespace -// --------------------------------------------------------------------- - - -// Copy assignment -void Url::assign(const Url &url) { - m_parse=url.m_parse; - m_built=url.m_built; - if (m_parse) { - m_scheme=url.m_scheme; - m_user=url.m_user; - m_host=url.m_host; - m_ip_v=url.m_ip_v; - m_port=url.m_port; - m_path=url.m_path; - m_query=url.m_query; - m_fragment=url.m_fragment; - } - if (!m_parse || m_built) - m_url=url.m_url; -} - - -// Move assignment -void Url::assign(Url&& url) { - m_parse=url.m_parse; - m_built=url.m_built; - if (m_parse) { - m_scheme=std::move(url.m_scheme); - m_user=std::move(url.m_user); - m_host=std::move(url.m_host); - m_ip_v=std::move(url.m_ip_v); - m_port=std::move(url.m_port); - m_path=std::move(url.m_path); - m_query=std::move(url.m_query); - m_fragment=std::move(url.m_fragment); - } - if (!m_parse || m_built) - m_url=std::move(url.m_url); -} - - -Url &Url::scheme(const std::string& s) { - if (!is_scheme(s)) - throw Url::parse_error("Invalid scheme '"+s+"'"); - lazy_parse(); - std::string o(s); - to_lower(o); - if (o!=m_scheme) { - m_scheme=o; - m_built=false; - if ((m_scheme=="http" && m_port=="80") || (m_scheme=="https" && m_port=="443")) - m_port=""; - } - return *this; -} - - -Url &Url::user_info(const std::string& s) { - if (s.length()>256) - throw Url::parse_error("User info is longer than 256 characters '"+s+"'"); - lazy_parse(); - if (m_user!=s) { - m_user=s; - m_built=false; - } - return *this; -} - - -Url &Url::host(const std::string& h, std::uint8_t ip_v) { - if (h.length()>253) - throw Url::parse_error("Host is longer than 253 characters '"+h+"'"); - lazy_parse(); - std::string o; - if (h.empty()) - ip_v=-1; - else if (is_ipv4(h)) { - if (!is_valid_ipv4(h)) - throw Url::parse_error("Invalid IPv4 address '"+h+"'"); - ip_v=4; - o=h; - } else if(ip_v!=0&&ip_v!=4&&ip_v!=6) { - if (!is_ipv6(h)) { - throw Url::parse_error("Invalid IPvFuture address '"+h+"'"); - } - o=h; - } else if (is_ipv6(h)) { - if (!is_valid_ipv6(h)) - throw Url::parse_error("Invalid IPv6 address '"+h+"'"); - ip_v=6; - o=normalize_IPv6(h); - } else if (is_reg_name(h)) { - ip_v=0; - o=normalize_reg_name(h); - } else - throw Url::parse_error("Invalid host '"+h+"'"); - if (m_host!=o||m_ip_v!=ip_v) { - m_host=o; - m_ip_v=ip_v; - m_built=false; - } - return *this; -} - - -Url &Url::port(const std::string& p) { - if (!is_port(p)) - throw Url::parse_error("Invalid port '"+p+"'"); - lazy_parse(); - std::string o(p); - if ((m_scheme=="http" && o=="80") || (m_scheme=="https" && o=="443")) - o=""; - if (m_port!=o) { - m_port=o; - m_built=false; - } - return *this; -} - - -Url &Url::path(const std::string& p) { - if (p.length()>8000) - throw Url::parse_error("Path is longer than 8000 characters '"+p+"'"); - lazy_parse(); - std::string o(normalize_path(p)); - if (m_path!=o) { - m_path=o; - m_built=false; - } - return *this; -} - - -Url &Url::fragment(const std::string& f) { - if (f.length()>256) - throw Url::parse_error("Fragment is longer than 256 characters '"+f+"'"); - lazy_parse(); - if (m_fragment!=f) { - m_fragment=f; - m_built=false; - } - return *this; -} - - -Url &Url::clear() { - m_url.clear(); - m_scheme.clear(); - m_user.clear(); - m_host.clear(); - m_port.clear(); - m_path.clear(); - m_query.clear(); - m_fragment.clear(); - m_ip_v=-1; - m_built=true; - m_parse=true; - return *this; -} - - -void Url::parse_url() const { - if (m_url.empty()) { - const_cast(this)->clear(); - m_parse=m_built=true; - return; - } - if (m_url.length()>8000) - throw Url::parse_error("URI is longer than 8000 characters"); - - const char *s=m_url.data(), *e=s+m_url.length(); - std::int8_t ip_v=-1; - const char *scheme_b, *scheme_e, *user_b, *user_e, *host_b, *host_e, - *port_b, *port_e, *path_b, *path_e, *query_b, *query_e, - *fragment_b, *fragment_e; - scheme_b=scheme_e=user_b=user_e=host_b=host_e=port_b=port_e=path_b= - path_e=query_b=query_e=fragment_b=fragment_e=nullptr; - - const char *b=s, *p=find_first_of(b, e, ":/?#"); - if (p==e) { - if (!is_chars(b, p, 0x2F)) - throw Url::parse_error("Path '"+std::string(b,p)+"' in '"+std::string(s,e-s)+"' is invalid"); - path_b=b; - path_e=e; - } else { - // get schema if any - if (*p==':') { - if (!is_scheme(b, p)) - throw Url::parse_error("Scheme in '"+std::string(s,e-s)+"' is invalid"); - scheme_b=b; - scheme_e=p; - p=find_first_of(b=p+1, e, "/?#"); - } - // get authority if any - if (p!=e && *p=='/' && (e-b)>1 && b[0]=='/' && b[1]=='/') { - const char *ea=find_first_of(b+=2, e, "/?#"); // locate end of authority - p=find_char(b, ea, '@'); - // get user info if any - if (p!=ea) { - if (!is_chars(b, p, 0x05)) - throw Url::parse_error("User info in '"+std::string(s,e-s)+"' is invalid"); - user_b=b; - user_e=p; - b=p+1; - } - // Get IP literal if any - if (*b=='[') { - // locate end of IP literal - p=find_char(++b, ea, ']'); - if (*p!=']') - throw Url::parse_error("Missing ] in '"+std::string(s,e-s)+"'"); - // decode IPvFuture protocol version - if (*b=='v') { - if (is_hexdigit(*++b)) { - ip_v=get_hex_digit(*b); - if (is_hexdigit(*++b)) { - ip_v=(ip_v<<8)|get_hex_digit(*b); - } - } - if (ip_v==-1||*b++!='.'||!is_chars(b,p,0x05)) - throw Url::parse_error("Host address in '"+std::string(s,e-s)+"' is invalid"); - } else if (is_ipv6(b,p)) { - ip_v=6; - } else - throw Url::parse_error("Host address in '"+std::string(s,e-s)+"' is invalid"); - host_b=b; - host_e=p; - b=p+1; - } else { - p=find_char(b, ea, ':'); - if (is_ipv4(b, p)) - ip_v=4; - else if (is_reg_name(b, p)) - ip_v=0; - else - throw Url::parse_error("Host address in '"+std::string(s,e-s)+"' is invalid"); - host_b=b; - host_e=p; - b=p; - } - //get port if any - if (b!=ea&&*b==':') { - if (!is_port(++b, ea)) - throw Url::parse_error("Port '"+std::string(b,ea-b)+"' in '"+std::string(s,e-s)+"' is invalid"); - port_b=b; - port_e=ea; - } - b=ea; - } - p=find_first_of(b,e,"?#"); - if (!is_chars(b, p, 0x2F)) - throw Url::parse_error("Path '"+std::string(b,p)+"' in '"+std::string(s,e-s)+"' is invalid"); - path_b=b; - path_e=p; - if (p!=e && *p=='?') { - p=find_char(b=p+1,e,'#'); - query_b=b; - query_e=p; - } - if (p!=e && *p=='#') { - if (!is_chars(p+1, e, 0x3F)) - throw Url::parse_error("Fragment '"+std::string(p+1,e)+"' in '"+std::string(s,e-s)+"' is invalid"); - fragment_b=p+1; - fragment_e=e; - } - } - std::string _scheme, _user, _host, _port, _path, _query, _fragment; - Query query_v; - - if (scheme_b) - _scheme=normalize_scheme(scheme_b, scheme_e); - if (user_b) - _user=decode(user_b, user_e); - if (host_b) { - _host=decode(host_b, host_e); - if (ip_v==0) - _host=normalize_reg_name(_host); - else if (ip_v==6) - _host=normalize_IPv6(_host); - } - if (port_b) - _port=std::string(port_b,port_e-port_b); - if (path_b) - _path=normalize_path(decode(path_b, path_e)); - if (query_b) { - _query=std::string(query_b, query_e); - p=b=query_b; - while (p!=query_e) { - p=find_first_of(b, query_e, "=;&"); - if (!is_chars(b, p, 0x3F)) - throw Url::parse_error("Query key '"+std::string(b,p)+"' in '"+std::string(s,e-s)+"' is invalid"); - std::string key(decode_plus(b,p)), val; - if (p!=query_e) { - if (*p=='=') { - p=find_first_of(b=p+1, query_e, ";&"); - if (!is_chars(b, p, 0x3F)) - throw Url::parse_error("Query value '"+std::string(b,p)+"' in '"+std::string(s,e-s)+"' is invalid"); - val=decode_plus(b,p); - } - b=p+1; - } - query_v.emplace_back(key, val); - } - } - if (fragment_b) - _fragment=decode(fragment_b, fragment_e); - - m_scheme=_scheme; - m_user=_user; - m_host=_host; - m_ip_v=ip_v; - m_port=_port; - m_path=_path; - m_query=query_v; - m_fragment=_fragment; - m_parse=true; - m_built=false; -} - - -void Url::build_url() const { - lazy_parse(); - std::stringstream url; - if (!m_scheme.empty()) - url<key().empty()) - throw Url::build_error("First query entry has no key"); - url<key(), 0x1F); - if (!it->val().empty()) - url<<"="<val(), 0x1F); - while(++it!=end) { - if (it->key().empty()) - throw Url::build_error("A query entry has no key"); - url<<"&"<key(), 0x1F); - if (!it->val().empty()) - url<<"="<val(), 0x1F); - } - } - if (!m_fragment.empty()) - url<<"#"< -#include -#include -#include -#include -#include -#include "string.hpp" - -class Url { -public: - // Exception thut may be thrown when decoding an URL or an assigning value - class parse_error: public std::invalid_argument { - public: - parse_error(const std::string &reason) : std::invalid_argument(reason) {} - }; - - // Exception that may be thrown when building an URL - class build_error: public std::runtime_error { - public: - build_error(const std::string &reason) : std::runtime_error(reason) {} - }; - - // Default constructor - Url() : m_parse(true),m_built(true),m_ip_v(-1) {} - - // Copy initializer constructor - Url(const Url &url) : m_ip_v(-1) {assign(url);} - - // Move constructor - Url(Url&& url) : m_ip_v(-1) {assign(std::move(url));} - - // Construct Url with the given string - Url(const std::string &url_str) : m_url(url_str),m_parse(false),m_built(false),m_ip_v(-1) {} - - // Assign the given URL string - Url &operator=(const std::string &url_str) {return str(url_str);} - - // Assign the given Url object - Url &operator=(const Url &url) {assign(url); return *this;} - - // Move the given Url object - Url &operator=(Url&& url) {assign(std::move(url)); return *this;} - - // Clear the Url object - Url &clear(); - - // Build Url if needed and return it as string - std::string str() const {if(!m_built) build_url(); return m_url;} - - // Set the Url to the given string. All fields are overwritten - Url& str(const std::string &url_str) {m_url=url_str; m_built=m_parse=false; return *this;} - - // Get scheme - const std::string& scheme() const {lazy_parse(); return m_scheme;} - - // Set scheme - Url &scheme(const std::string& s); - - // Get user info - const std::string& user_info() const {lazy_parse(); return m_user;} - - // Set user info - Url &user_info(const std::string& s); - - // Get host - const std::string& host() const {lazy_parse(); return m_host;} - - // Set host - Url &host(const std::string& h, uint8_t ip_v=0); - - // Get host IP version: 0=name, 4=IPv4, 6=IPv6, -1=undefined - std::int8_t ip_version() const {lazy_parse(); return m_ip_v;} - - // Get port - const std::string& port() const {lazy_parse(); return m_port;} - - // Set Port given as string - Url &port(const std::string& str); - - // Set port given as a 16bit unsigned integer - Url &port(std::uint16_t num) {return port(std::to_string(num));} - - // Get path - const std::string& path() const {lazy_parse(); return m_path;} - - // Set path - Url &path(const std::string& str); - - class KeyVal { - public: - // Default constructor - KeyVal() {} - - // Construct with provided Key and Value strings - KeyVal(const std::string &key, const std::string &val) : m_key(key),m_val(val) {} - - // Construct with provided Key string, val will be empty - KeyVal(const std::string &key) : m_key(key) {} - - // Equality test operator - bool operator==(const KeyVal &q) const {return m_key==q.m_key&&m_val==q.m_val;} - - // Swap this with q - void swap(KeyVal& q) {std::swap(m_key,q.m_key); std::swap(m_val,q.m_val);} - - // Get key - const std::string& key() const {return m_key;} - - // Set key - void key(const std::string &k) {m_key=k;} - - // Get value - const std::string& val() const {return m_val;} - - // Set value - void val(const std::string &v) {m_val=v;} - - // Output key value pair - friend std::ostream& operator<<(std::ostream &o, const KeyVal &kv) - {o<<" "; return o;} - - private: - std::string m_key; - std::string m_val; - }; - - // Define Query as vector of Key Value pairs - typedef std::vector Query; - - // Get a reference to the query vector for read only access - const Query& query() const {lazy_parse(); return m_query;} - - // Get a reference to a specific Key Value pair in the query vector for read only access - const KeyVal& query(size_t i) const { - lazy_parse(); - if (i>=m_query.size()) - throw std::out_of_range("Invalid Url query index ("+std::to_string(i)+")"); - return m_query[i]; - } - - // Get a reference to the query vector for a writable access - Query& set_query() {lazy_parse(); m_built=false; return m_query;} - - // Get a reference to specific Key Value pair in the query vector for a writable access - KeyVal& set_query(size_t i) { - lazy_parse(); - if (i>=m_query.size()) - throw std::out_of_range("Invalid Url query index ("+std::to_string(i)+")"); - m_built=false; - return m_query[i]; - } - - // Set the query vector to the Query vector q - Url &set_query(const Query &q) - {lazy_parse(); if (q != m_query) {m_query=q; m_built=false;} return *this;} - - // Append KeyVal kv to the query - Url &add_query(const KeyVal &kv) - {lazy_parse(); m_built=false; m_query.push_back(kv); return *this;} - - // Append key val pair to the query - Url &add_query(const std::string &key, const std::string &val) - {lazy_parse(); m_built=false; m_query.emplace_back(key,val); return *this;} - - // Append key with empty val to the query - Url &add_query(const std::string &key) - {lazy_parse(); m_built=false; m_query.emplace_back(key); return *this;} - - // Get the fragment - const std::string& fragment() const {lazy_parse(); return m_fragment;} - - // Set the fragment - Url &fragment(const std::string& f); - - // Output - std::ostream& output(std::ostream &o) const; - - // Output strean operator - friend std::ostream& operator<<(std::ostream &o, const Url &u) {return u.output(o);} - -private: - void assign(const Url &url); - void assign(Url&& url); - void build_url() const; - void lazy_parse() const {if (!m_parse) parse_url();} - void parse_url() const; - - mutable std::string m_scheme; - mutable std::string m_user; - mutable std::string m_host; - mutable std::string m_port; - mutable std::string m_path; - mutable Query m_query; - mutable std::string m_fragment; - mutable std::string m_url; - mutable bool m_parse; - mutable bool m_built; - mutable std::int8_t m_ip_v; -}; - - - - -#endif // URL_HPP - diff --git a/AuroraNative/util.h b/AuroraNative/util.h index efd3a87..b25b05d 100644 --- a/AuroraNative/util.h +++ b/AuroraNative/util.h @@ -1,6 +1,10 @@ -#pragma once +#ifndef UTIL_H +#define UTIL_H -#include "pch.h" +#include +#include +#include +#include class Util { private: @@ -42,3 +46,5 @@ class Util { return FindPattern(info.lpBaseOfDll, info.SizeOfImage, lpPattern, lpMask); } }; + +#endif // UTIL_H diff --git a/AuroraServer/AuroraServer.csproj b/AuroraServer/AuroraServer.csproj deleted file mode 100644 index fb60f66..0000000 --- a/AuroraServer/AuroraServer.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - Exe - netcoreapp3.1 - - - - - - - - diff --git a/AuroraServer/Program.cs b/AuroraServer/Program.cs deleted file mode 100644 index e8cda22..0000000 --- a/AuroraServer/Program.cs +++ /dev/null @@ -1,24 +0,0 @@ -using AuroraServer.IO; -using Serilog; -using Serilog.Core; -using System.Linq; - -namespace AuroraServer -{ - class Program - { - static Logger _log = new LoggerConfiguration() - .WriteTo.Console() - .CreateLogger(); - - static void Main(string[] args) - { - _log.Information("AuroraServer by Cyuubi, do not redistribute!"); - - BitReader reader = new BitReader(new byte[] { 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 }); - - _log.Information($"IsValid = {Enumerable.SequenceEqual(reader.ReadBits(4), new bool[] { true, true, true, false })}"); - _log.Information($"IsHandshake = {reader.ReadBit()}"); - } - } -} diff --git a/AuroraUnified.sln b/AuroraUnified.sln index 9e93c5e..b405088 100644 --- a/AuroraUnified.sln +++ b/AuroraUnified.sln @@ -7,8 +7,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AuroraNative", "AuroraNativ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuroraLauncher", "AuroraLauncher\AuroraLauncher.csproj", "{C6D5E15A-5A85-4F00-BECF-854A4A54B1EC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AuroraServer", "AuroraServer\AuroraServer.csproj", "{78AE5454-2195-4FF4-9E95-74F34683A924}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -29,14 +27,6 @@ Global {C6D5E15A-5A85-4F00-BECF-854A4A54B1EC}.Release|Any CPU.ActiveCfg = Release|x64 {C6D5E15A-5A85-4F00-BECF-854A4A54B1EC}.Release|x64.ActiveCfg = Release|x64 {C6D5E15A-5A85-4F00-BECF-854A4A54B1EC}.Release|x64.Build.0 = Release|x64 - {78AE5454-2195-4FF4-9E95-74F34683A924}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {78AE5454-2195-4FF4-9E95-74F34683A924}.Debug|Any CPU.Build.0 = Debug|Any CPU - {78AE5454-2195-4FF4-9E95-74F34683A924}.Debug|x64.ActiveCfg = Debug|Any CPU - {78AE5454-2195-4FF4-9E95-74F34683A924}.Debug|x64.Build.0 = Debug|Any CPU - {78AE5454-2195-4FF4-9E95-74F34683A924}.Release|Any CPU.ActiveCfg = Release|Any CPU - {78AE5454-2195-4FF4-9E95-74F34683A924}.Release|Any CPU.Build.0 = Release|Any CPU - {78AE5454-2195-4FF4-9E95-74F34683A924}.Release|x64.ActiveCfg = Release|Any CPU - {78AE5454-2195-4FF4-9E95-74F34683A924}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE