Skip to content

Commit

Permalink
Merge pull request #164 from timiimit/organize-repo
Browse files Browse the repository at this point in the history
Organize repo - Major codebase change
  • Loading branch information
timiimit authored Feb 3, 2023
2 parents 6f3e705 + 227d18e commit c44b408
Show file tree
Hide file tree
Showing 118 changed files with 3,326 additions and 4,139 deletions.
6 changes: 1 addition & 5 deletions .Tests/XUnit.Tests/GameServerAttributeTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Text;
using System.Text.Json;
using UT4MasterServer.Models;

namespace XUnit.Tests;
namespace XUnit.Tests;

#if false
public class GameServerAttributeTest
Expand Down
2 changes: 1 addition & 1 deletion .Tests/XUnit.Tests/StringHelperTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text;
using UT4MasterServer.Helpers;
using UT4MasterServer.Common.Helpers;

namespace XUnit.Tests;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright (c) Barry Dorrans. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Security.Claims;
using System.Text.Encodings.Web;
using UT4MasterServer.Services;
using UT4MasterServer.Models;
using UT4MasterServer.Services.Scoped;

namespace UT4MasterServer.Authentication;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Security.Claims;
using System.Text.Encodings.Web;
using UT4MasterServer.Services;
using UT4MasterServer.Services.Scoped;

namespace UT4MasterServer.Authentication;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Security.Claims;
using UT4MasterServer.Models;
using UT4MasterServer.Models.Database;

namespace UT4MasterServer.Authentication;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Security.Claims;
using UT4MasterServer.Models;
using UT4MasterServer.Models.Database;

namespace UT4MasterServer.Authentication;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\UT4MasterServer.Models\UT4MasterServer.Models.csproj" />
<ProjectReference Include="..\UT4MasterServer.Services\UT4MasterServer.Services.csproj" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions UT4MasterServer.Common/Enums/GameServerTrust.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace UT4MasterServer.Common.Enums;

public enum GameServerTrust
{
Epic = 0,
Trusted = 1,
Untrusted = 2
}
6 changes: 6 additions & 0 deletions UT4MasterServer.Common/Enums/OwnerType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace UT4MasterServer.Common.Enums;

public enum OwnerType
{
Default = 1,
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace UT4MasterServer.Enums;
namespace UT4MasterServer.Common.Enums;

public enum StatisticWindow
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Attributes;
using System.Security.Cryptography;
using UT4MasterServer.Exceptions;
using UT4MasterServer.Helpers;
using UT4MasterServer.Common.Helpers;
using UT4MasterServer.Common.Exceptions;

namespace UT4MasterServer.Other;
namespace UT4MasterServer.Common;

[Serializable]
public struct EpicID : IComparable<EpicID>, IEquatable<EpicID>, IConvertible, IBsonClassMapAttribute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Runtime.Serialization;

namespace UT4MasterServer.Exceptions;
namespace UT4MasterServer.Common.Exceptions;

[Serializable]
public class InvalidEpicIDException : Exception
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace UT4MasterServer.Other;
namespace UT4MasterServer.Common.Helpers;

public static class DateTimeExtension
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Security.Cryptography;
using System.Text;
using UT4MasterServer.Other;

namespace UT4MasterServer.Helpers;
namespace UT4MasterServer.Common.Helpers;

public static class PasswordHelper
{
Expand Down
37 changes: 37 additions & 0 deletions UT4MasterServer.Common/Helpers/StreamExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Buffers;
using System.Text;

namespace UT4MasterServer.Common.Helpers;

public static class StreamExtensions
{
public static async Task<string> ReadAsStringAsync(this Stream stream, int maxByteLength)
{
return Encoding.UTF8.GetString(await stream.ReadAsBytesAsync(maxByteLength));
}

public static async Task<byte[]> ReadAsBytesAsync(this Stream stream, int maxByteLength)
{
var bytes = ArrayPool<byte>.Shared.Rent(maxByteLength);
int fillCount = 0;

while (true)
{
int readCount = await stream.ReadAsync(bytes.AsMemory(fillCount, bytes.Length - fillCount));

if (readCount <= 0)
{
// EOF reached
break;
}

fillCount += readCount;
}

byte[] ret = new byte[fillCount];
Array.Copy(bytes, ret, fillCount);
ArrayPool<byte>.Shared.Return(bytes);

return ret;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace UT4MasterServer.Helpers;
namespace UT4MasterServer.Common.Helpers;

public static class StringExtensions
{
Expand All @@ -11,7 +11,7 @@ public static bool IsHexString(this string input)

foreach (var c in input)
{
if (!((c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') || (c >= '0' && c <= '9')))
if (!(c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F' || c >= '0' && c <= '9'))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.RegularExpressions;

namespace UT4MasterServer.Helpers;
namespace UT4MasterServer.Common.Helpers;

public static class ValidationHelper
{
Expand Down
13 changes: 13 additions & 0 deletions UT4MasterServer.Common/UT4MasterServer.Common.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Bson" Version="2.19.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using System.Text;
using UT4MasterServer.Helpers;
using UT4MasterServer.Other;
using UT4MasterServer.Common.Helpers;
using UT4MasterServer.Common;

namespace UT4MasterServer.Authentication;
namespace UT4MasterServer.Models;

public class ClientIdentification
{
public static ClientIdentification Launcher = new ClientIdentification(
public readonly static ClientIdentification Launcher = new(
EpicID.FromString("34a02cf8f4414e29b15921876da36f9a"),
"daafbccc737745039dffe53d94fc76cf"
);
public static ClientIdentification Game = new ClientIdentification(
public readonly static ClientIdentification Game = new(
EpicID.FromString("1252412dc7704a9690f6ea4611bc81ee"),
"2ca0c925b4674852bff92b26f8322434"
);
public static ClientIdentification ServerInstance = new ClientIdentification(
public readonly static ClientIdentification ServerInstance = new(
EpicID.FromString("6ff43e743edc4d1dbac3594877b4bed9"),
"54619d6f84d443e195200b54ab649a53"
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace UT4MasterServer.Models.Requests;
namespace UT4MasterServer.Models.DTO.Request;

public class AdminPanelChangePasswordRequest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
/*
{
"criteria": [
{
"type": "NOT_EQUAL",
"key": "UT_GAMEINSTANCE_i",
"value": 1
},
{
"type": "NOT_EQUAL",
"key": "UT_RANKED_i",
"value": 1
}
],
"buildUniqueId": "256652735",
"maxResults": 10000
}
*/

using System.Text.Json;

namespace UT4MasterServer.Models;
namespace UT4MasterServer.Models.DTO.Request;

public class GameServerAttributeCriteria
{
Expand All @@ -29,7 +10,7 @@ public class GameServerAttributeCriteria
public JsonElement Value { get; set; } = default;
}

public class GameServerFilter
public class GameServerFilterRequest
{
public List<GameServerAttributeCriteria> Criteria { get; set; } = new();
public string? BuildUniqueId { get; set; } = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Text.Json.Serialization;

namespace UT4MasterServer.Models.Requests;
namespace UT4MasterServer.Models.DTO.Request;

public sealed class GrantXP
public sealed class GrantXPRequest
{
[JsonPropertyName("xpAmount")]
public int XPAmount { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Text.Json.Serialization;

namespace UT4MasterServer.Models.Requests;
namespace UT4MasterServer.Models.DTO.Request;

public sealed class SetStars
public sealed class SetStarsRequest
{
[JsonPropertyName("newGoldStars")]
public int NewGoldStars { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Text.Json.Serialization;
using UT4MasterServer.Other;
using UT4MasterServer.Common;

namespace UT4MasterServer.Models.Requests;
namespace UT4MasterServer.Models.DTO.Responses;

public class Entitlement
public class EntitlementResponse
{
/*
Expand Down Expand Up @@ -79,7 +79,7 @@ public class Entitlement
[JsonPropertyName("country")]
public string Country { get; set; } = "US";

public Entitlement(string name, string id, EpicID accountID)
public EntitlementResponse(string name, string id, EpicID accountID)
{
var commonDate = new DateTime(2023, 1, 1, 0, 0, 0, DateTimeKind.Utc);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace UT4MasterServer.Models;
namespace UT4MasterServer.Models.DTO.Responses;

public class ErrorResponse
{
[JsonProperty("errorCode")]
[JsonPropertyName("errorCode")]
public string? ErrorCode { get; set; }

[JsonProperty("errorMessage")]
[JsonPropertyName("errorMessage")]
public string? ErrorMessage { get; set; }

[JsonProperty("messageVars")]
[JsonPropertyName("messageVars")]
public string[] MessageVars { get; set; } = Array.Empty<string>(); // any value inside errorMessage is listed in this array

[JsonProperty("numericErrorCode")]
[JsonPropertyName("numericErrorCode")]
public int NumericErrorCode { get; set; }

[JsonProperty("originatingService")]
[JsonPropertyName("originatingService")]
public string? OriginatingService { get; set; }

[JsonProperty("intent")]
[JsonPropertyName("intent")]
public string? Intent { get; set; }

// TODO: Use one JSON DLL in solution. See https://github.com/timiimit/UT4MasterServer/issues/33
[JsonPropertyName("error_description")] // Fix for API response
[JsonProperty("error_description")]
[JsonPropertyName("error_description")]
public string? ErrorDescription { get; set; }

[JsonProperty("error")]
public string? Error { get; set; }
[JsonPropertyName("error")]
public string? ErrorName { get; set; }

public Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace UT4MasterServer.Models;
namespace UT4MasterServer.Models.DTO.Responses;

/// <summary>
/// Names taken from <see href="https://github.com/EpicGames/UnrealTournament/blob/clean-master/UnrealTournament/Source/UnrealTournament/Private/UTPlayerState.cpp#L2219">LeagueTierToText</see>
Expand All @@ -16,7 +15,7 @@ public enum LeagueTier
GrandMasterLeague = 5,
}

public class League
public class LeagueResponse
{
// i think this structure is in UT source, so it can be explored further there

Expand Down
Loading

0 comments on commit c44b408

Please sign in to comment.