Skip to content

Commit

Permalink
Merge pull request #75 from Jump-Suit/EA_BlazeWork
Browse files Browse the repository at this point in the history
Blaze + HTTP
  • Loading branch information
GitHubProUser67 authored Dec 13, 2024
2 parents fe8c3ca + 733f66d commit cb13eb7
Show file tree
Hide file tree
Showing 22 changed files with 2,126 additions and 64 deletions.
351 changes: 351 additions & 0 deletions AuxiliaryServices/WebAPIService/CCPGames/Dust514Class.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion AuxiliaryServices/WebAPIService/HTS/HTSClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public string ProcessRequest(byte[] PostData, string ContentType, bool https)
case "/NPTicketing/get_ticket_data.json":
case "/NPTicketing/get_ticket_data_base64.xml":
case "/NPTicketing/get_ticket_data_base64.json":
return MyResistanceEula.RequestNPTicket(PostData, HTTPProcessor.ExtractBoundary(ContentType));
return NPTicketSample.RequestNPTicket(PostData, HTTPProcessor.ExtractBoundary(ContentType));
#endregion

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace WebAPIService.HTS.Helpers
{
public class MyResistanceEula
public class NPTicketSample
{
public static string RequestNPTicket(byte[] PostData, string boundary)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
using CustomLogger;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace WebAPIService.UBISOFT.BuildAPI.BuildDBPullService
{
public class BuildDBPullServiceHandler
{

public static string buildDBRequestParser(byte[] PostData, string ContentType)
{

if (PostData == null || PostData.Length == 0)
return "Empty PostData";


// Load the XML string into an XDocument
XDocument xdoc = XDocument.Parse(Encoding.UTF8.GetString(PostData));

// Define the namespaces used in the XML document
XNamespace soap = "http://www.w3.org/2003/05/soap-envelope";
XNamespace responseNamespace = "http://builddatabasepullapi/";

var resultElement = xdoc.Descendants(soap + "Body").FirstOrDefault();
string innerRequestName = resultElement.Name.ToString();

List<string> buildDbRequests = new List<string>()
{ "GetCurrentLauncherVersion", "GetConsoleOwner",
"GetProjectDetailWithMacValidation", "GetFilteredBuildVersionsWithMacValidation",
"GetProjectsWithMacValidation", "GetFilteredBuildVersionsWithMacValidation"};


if (buildDbRequests.Contains(innerRequestName))
{
switch (innerRequestName) {
case "GetCurrentLauncherVersion":
{

LoggerAccessor.LogInfo($"[BuildDBPullService] - GetCurrentLauncherVersion: TRIGGERED!");

return @"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope
xmlns:soap=""http://www.w3.org/2003/05/soap-envelope""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<soap:Body>
<LauncherVersion
xmlns=""http://builddatabasepullapi/"">
<VersionName>2.10.1</VersionName>
<VersionPath>/BuildDBPullService.asmx</VersionPath>
<LauncherVersionId>4</LauncherVersionId>
<PlatformId>4</PlatformId>
</LauncherVersion>
</soap:Body>
</soap:Envelope>";
}

default:
{

LoggerAccessor.LogInfo($"[BuildDBPullService] - GetCurrentLauncherVersion: FAILED!");
return @"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope
xmlns:soap=""http://www.w3.org/2003/05/soap-envelope""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<soap:Body>
<LauncherVersion
xmlns=""http://builddatabasepullapi/"">
<VersionName>2.10.1</VersionName>
<VersionPath>/BuildDBPullService.asmx</VersionPath>
<LauncherVersionId>4</LauncherVersionId>
<PlatformId>4</PlatformId>
</LauncherVersion>
</soap:Body>
</soap:Envelope>";
}

}
}
else
{
LoggerAccessor.LogWarn("[BuildDBPullService] - No GetConsoleOwnerResult found.");
}


return @"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope
xmlns:soap=""http://www.w3.org/2003/05/soap-envelope""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<soap:Body>
<LauncherVersion
xmlns=""http://builddatabasepullapi/"">
<VersionName>2.10.2</VersionName>
<VersionPath>/BuildDBPullService.asmx</VersionPath>
<LauncherVersionId>4</LauncherVersionId>
<PlatformId>4</PlatformId>
</LauncherVersion>
</soap:Body>
</soap:Envelope>";


}


public static string getVersion(byte[] PostData, string ContentType) {


return @"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope
xmlns:soap=""http://www.w3.org/2003/05/soap-envelope""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<soap:Body>
<GetConsoleOwnerResponse
xmlns=""http://builddatabasepullapi/"">
<GetConsoleOwnerResult>
<ADLogin>hensley.edwin</ADLogin>
<Name>Hensley Edwin</Name>
</GetConsoleOwnerResult>
</GetConsoleOwnerResponse>
</soap:Body>
</soap:Envelope>";
}

public static string getConsoleOwner(byte[] PostData, string ContentType)
{


return @"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope
xmlns:soap=""http://www.w3.org/2003/05/soap-envelope""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<soap:Body>
<GetConsoleOwnerResponse
xmlns=""http://builddatabasepullapi/"">
<GetConsoleOwnerResult>
<ADLogin>hensley.edwin</ADLogin>
<Name>Hensley Edwin</Name>
</GetConsoleOwnerResult>
</GetConsoleOwnerResponse>
</soap:Body>
</soap:Envelope>";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using CustomLogger;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebAPIService.OUWF;
using WebAPIService.UBISOFT.BuildAPI.BuildDBPullService;

namespace WebAPIService.UBISOFT.BuildAPI
{

public class SoapBuildAPIClass : IDisposable
{
string workpath;
string absolutepath;
string method;
private bool disposedValue;

public SoapBuildAPIClass(string method, string absolutepath, string workpath)
{
this.workpath = workpath;
this.absolutepath = absolutepath;
this.method = method;
}

public string ProcessRequest(byte[] PostData, string ContentType)
{
if (string.IsNullOrEmpty(absolutepath))
return null;

switch (method)
{
case "POST":
switch (absolutepath)
{

case "/BuildDBPullService.asmx":
return BuildDBPullServiceHandler.buildDBRequestParser(PostData, ContentType);
default:
{
LoggerAccessor.LogError($"[BuildDBPullService] - Unhandled server request discovered: {absolutepath} | DETAILS: \n{Encoding.UTF8.GetString(PostData)}");
}
break;
}
break;
default:
{
LoggerAccessor.LogError($"[BuildDBPullService] - Method unhandled {method}");
}
break;
}

return null;
}

protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
absolutepath = string.Empty;
method = string.Empty;
workpath = string.Empty;
}

// TODO: libérer les ressources non managées (objets non managés) et substituer le finaliseur
// TODO: affecter aux grands champs une valeur null
disposedValue = true;
}
}

// // TODO: substituer le finaliseur uniquement si 'Dispose(bool disposing)' a du code pour libérer les ressources non managées
// ~HERMESClass()
// {
// // Ne changez pas ce code. Placez le code de nettoyage dans la méthode 'Dispose(bool disposing)'
// Dispose(disposing: false);
// }

public void Dispose()
{
// Ne changez pas ce code. Placez le code de nettoyage dans la méthode 'Dispose(bool disposing)'
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}
64 changes: 27 additions & 37 deletions SpecializedServers/Horizon/SERVER/Medius/MAPS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ protected override async Task ProcessMessage(BaseScertMessage message, IChannel
}
}

data.ClientObject = MediusClass.Manager.GetClientByAccessToken(clientConnectTcp.AccessToken, clientConnectTcp.AppId);
if (data.ClientObject == null)
data.ClientObject = MediusClass.Manager.GetClientBySessionKey(clientConnectTcp.SessionKey, clientConnectTcp.AppId);
// If booth are null, it means MAS client wants a new object.
if (!string.IsNullOrEmpty(clientConnectTcp.AccessToken) && !string.IsNullOrEmpty(clientConnectTcp.SessionKey))
{
data.ClientObject = MediusClass.Manager.GetClientByAccessToken(clientConnectTcp.AccessToken, clientConnectTcp.AppId);
if (data.ClientObject == null)
data.ClientObject = MediusClass.Manager.GetClientBySessionKey(clientConnectTcp.SessionKey, clientConnectTcp.AppId);
}

if (data.ClientObject != null)
LoggerAccessor.LogInfo($"[MAPS] - Client Connected {clientChannel.RemoteAddress}!");
Expand Down Expand Up @@ -187,15 +191,9 @@ protected virtual void ProcessMediusPluginMessage(BaseMediusPluginMessage messag

case NetMessageHello netMessageHello:
{
/*
data.ClientObject?.Queue(new NetMAPSHelloMessage()
{
m_success = false,
m_isOnline = false,
m_availableFactions = new byte[3] { 1, 2, 3 }
});
*/

//MAGDevBuild3 = 1725
//MAG BCET70016 v1.3 = 7002
data.ClientObject.Queue(new NetMessageTypeProtocolInfo()
{
protocolInfo = EndianUtils.ReverseUint(1725), //1725 //1958
Expand All @@ -209,14 +207,30 @@ protected virtual void ProcessMediusPluginMessage(BaseMediusPluginMessage messag

case NetMessageTypeProtocolInfo protocolInfo:
{
byte[] availFactions = new byte[] { 0b00000111, 0, 0, 0 }; //= new byte[4];

//0b11100000
//availFactions[0] = 0;
//availFactions[1] = 0;
//availFactions[2] = 0;
//availFactions[3] = 31;

data.ClientObject.Queue(new NetMAPSHelloMessage()
{
m_success = true,
m_isOnline = true,
m_availableFactions = availFactions

});

//Time
DateTime time = DateTime.Now;
long timeBS = time.Ticks >> 1;

//bool finBs = true >> 1;
//Content string bitshift
string newsBs = ShiftString("Test News");
string eulaBs = ShiftString("Test Eula");
//string newsBs = ShiftString("Test News");
//string eulaBs = ShiftString("Test Eula");
// News/Eula Type bitshifted
int newsBS = 0;//Convert.ToInt32(NetMessageNewsEulaResponseContentType.News) >> 1;
int eulaBS = 1;//Convert.ToInt32(NetMessageNewsEulaResponseContentType.Eula) >> 1;
Expand Down Expand Up @@ -277,29 +291,5 @@ protected virtual void ProcessMediusPluginMessage(BaseMediusPluginMessage messag
}
}
}

public static string ShiftString(string t)
{
return t[1..] + t[..1];
}

public byte[] BitShift(byte[] sequence, int length)
{
// Check if the length is valid
if (length <= 0 || length >= 8)
{
LoggerAccessor.LogError("[MAPS] - Invalid shift length. The length must be between 1 and 7.");
return Array.Empty<byte>();
}

// Perform the bitwise shift operation
byte[] shiftedSequence = new byte[sequence.Length];
for (int i = 0; i < sequence.Length; i++)
{
shiftedSequence[i] = (byte)(sequence[i] << length);
}

return shiftedSequence;
}
}
}
Loading

0 comments on commit cb13eb7

Please sign in to comment.