diff --git a/Partypacker/Core/Server.cs b/Partypacker/Core/Server.cs index f89f38a..40a5dc1 100644 --- a/Partypacker/Core/Server.cs +++ b/Partypacker/Core/Server.cs @@ -9,10 +9,17 @@ namespace Partypacker.Core { internal class Server { + static string BaseURL = +#if DEBUG + "http://localhost:6677"; +#else + "https://api.partypack.mcthe.dev"; +#endif + public static KeyValuePair GET(string URL = "/") { if (URL.StartsWith("/")) - URL = "https://example.com" + URL; + URL = BaseURL + URL; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL); request.Method = "GET"; @@ -38,7 +45,7 @@ namespace Partypacker.Core public static KeyValuePair POST(string URL = "/", string Body = "") { if (URL.StartsWith("/")) - URL = "https://example.com" + URL; + URL = BaseURL + URL; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL); request.Method = "POST"; diff --git a/Partypacker/Program.cs b/Partypacker/Program.cs index c5cd813..c0cf5cc 100644 --- a/Partypacker/Program.cs +++ b/Partypacker/Program.cs @@ -1,4 +1,5 @@ -using Partypacker.Net; +using Partypacker.Core; +using Partypacker.Net; using Pastel; using System.Diagnostics; using System.Drawing; @@ -15,6 +16,8 @@ namespace Partypacker { ushort? port = 6969; + var DiscordLoginLink = Server.GET("/api/discord/url"); + Console.SetWindowSize(75, 20); Console.CursorVisible = false; @@ -39,7 +42,8 @@ namespace Partypacker { new SelectableOption("Launch Fortnite", () => Run(port, () => Process.Start(new ProcessStartInfo { FileName = "com.epicgames.launcher://apps/fn%3A4fe75bbc5a674f4f9b356b5c90567da5%3AFortnite?action=launch&silent=true", UseShellExecute = true }))), - new SelectableOption("Open Dashboard", () => Process.Start(new ProcessStartInfo { FileName = "https://partypack.mcthe.dev", UseShellExecute = true })) + new SelectableOption("Open Dashboard", () => Process.Start(new ProcessStartInfo { FileName = "https://partypack.mcthe.dev", UseShellExecute = true })), + new SelectableOption("Log in using Discord", () => Process.Start(new ProcessStartInfo { FileName = DiscordLoginLink.Value, UseShellExecute = true })) }; try @@ -93,6 +97,8 @@ namespace Partypacker _ => new Proxy((ushort)port) }; Proxx.StartProxy(); + // please make this dynamic later :D + Proxx.Token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6IjQ1NDk2ODU0MjcyMzU3MTcxNSIsImlhdCI6MTcwNTkyODQ0M30.ogINqFZ_3DBkECbHo87HjW9c6p2imT1CnCvfIR3iGJ4"; Finish.Invoke(); } diff --git a/Partypacker/Proxy/Proxy.cs b/Partypacker/Proxy/Proxy.cs index be6a5d8..3a78314 100644 --- a/Partypacker/Proxy/Proxy.cs +++ b/Partypacker/Proxy/Proxy.cs @@ -20,6 +20,7 @@ namespace Partypacker.Net // https://github.com/PsychoPast/LawinServer/blob/master/LawinServer/Proxy/Proxy.cs // without it, fiddler-less proxying would have never been achieved + public string Token = ""; private const string Proxy_Server = "ProxyServer"; private const string Proxy_Enable = "ProxyEnable"; private readonly AppRegistry appRegistry; @@ -129,9 +130,8 @@ namespace Partypacker.Net #region EVENT_HANDLERS private void OnBeforeRequest(Session oSession) { - if (oSession.PathAndQuery.Contains("/content/api/pages/fortnite-game/spark-tracks") + if (oSession.PathAndQuery.Contains("/content/api/pages/fortnite-game") || oSession.HostnameIs("cdn.qstv.on.epicgames.com") - || oSession.HostnameIs("cdn-0001.qstv.on.epicgames.com") || oSession.PathAndQuery.Contains("/master.blurl") || oSession.PathAndQuery.Contains("/main.blurl") ) @@ -149,6 +149,8 @@ namespace Partypacker.Net "https://api.partypack.mcthe.dev"; #endif + oSession.RequestHeaders.Add("X-Partypack-Token", Token); + if (oSession.PathAndQuery.Contains("/master.blurl") || oSession.PathAndQuery.Contains("/main.blurl")) oSession.fullUrl = BaseURL + "/song/download" + oSession.PathAndQuery;