Updated Bnet Server.

Port From (https://github.com/TrinityCore/TrinityCore)
This commit is contained in:
hondacrx
2024-02-21 00:05:48 -05:00
parent 7960e7b192
commit 9e3a7df6a7
62 changed files with 2186 additions and 731 deletions
-10
View File
@@ -1,10 +0,0 @@
using System;
namespace Framework.Web.API
{
public class ApiRequest<T>
{
public uint? SearchId { get; set; }
public Func<T, bool> SearchFunc { get; set; }
}
}
+23 -23
View File
@@ -1,10 +1,12 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using Framework.Networking.Http;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
@@ -15,14 +17,14 @@ namespace Framework.Web
public string Method { get; set; }
public string Path { get; set; }
public string Type { get; set; }
public string Host { get; set; }
public string DeviceId { get; set; }
public string Authorization { get; set; }
public string ContentType { get; set; }
public int ContentLength { get; set; }
public string AcceptLanguage { get; set; }
public string Accept { get; set; }
public string UserAgent { get; set; }
public string Content { get; set; }
public string Content { get; set; } = "";
public HttpStatusCode Status { get; set; } = HttpStatusCode.OK;
public string Cookie { get; set; }
public bool KeepAlive { get; set; }
public string Host { get; set; }
}
public enum HttpCode
@@ -35,43 +37,41 @@ namespace Framework.Web
public class HttpHelper
{
public static byte[] CreateResponse(HttpCode httpCode, string content, bool closeConnection = false)
public static byte[] CreateResponse(RequestContext requestContext)
{
var sb = new StringBuilder();
using (var sw = new StringWriter(sb))
{
sw.WriteLine($"HTTP/1.1 {(int)httpCode} {httpCode}");
sw.WriteLine($"HTTP/1.1 {(int)requestContext.response.Status} {requestContext.response.Status}");
sw.WriteLine($"Content-Length: {requestContext.response.Content.Length}");
//sw.WriteLine($"Date: {DateTime.Now.ToUniversalTime():r}");
//sw.WriteLine("Server: Arctium-Emulation");
//sw.WriteLine("Retry-After: 600");
sw.WriteLine($"Content-Length: {content.Length}");
//sw.WriteLine("Vary: Accept-Encoding");
if (closeConnection)
if (!requestContext.response.KeepAlive)
sw.WriteLine("Connection: close");
sw.WriteLine("Content-Type: application/json;charset=UTF-8");
if (!requestContext.response.Cookie.IsEmpty())
sw.WriteLine($"Set-Cookie: {requestContext.response.Cookie}");
sw.WriteLine($"Content-Type: {requestContext.response.ContentType}");
sw.WriteLine();
sw.WriteLine(content);
sw.WriteLine(requestContext.response.Content);
}
return Encoding.UTF8.GetBytes(sb.ToString());
}
public static HttpHeader ParseRequest(byte[] data, int length)
public static bool ParseRequest(byte[] data, int length, out HttpHeader httpHeader)
{
var headerValues = new Dictionary<string, object>();
var header = new HttpHeader();
httpHeader = new HttpHeader();
using (var sr = new StreamReader(new MemoryStream(data, 0, length)))
{
var info = sr.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
if (info.Length != 3)
return null;
return false;
headerValues.Add("method", info[0]);
headerValues.Add("path", info[1]);
@@ -113,13 +113,13 @@ namespace Framework.Web
if (headerValues.TryGetValue(f.Name.ToLower(), out val))
{
if (f.PropertyType == typeof(int))
f.SetValue(header, Convert.ChangeType(Convert.ToInt32(val), f.PropertyType));
f.SetValue(httpHeader, Convert.ChangeType(Convert.ToInt32(val), f.PropertyType));
else
f.SetValue(header, Convert.ChangeType(val, f.PropertyType));
f.SetValue(httpHeader, Convert.ChangeType(val, f.PropertyType));
}
}
return header;
return true;
}
}
}
@@ -1,27 +0,0 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
namespace Framework.Web
{
[DataContract]
public class LogonData
{
public string this[string inputId] => Inputs.SingleOrDefault(i => i.Id == inputId)?.Value;
[DataMember(Name = "version")]
public string Version { get; set; }
[DataMember(Name = "program_id")]
public string Program { get; set; }
[DataMember(Name = "platform_id")]
public string Platform { get; set; }
[DataMember(Name = "inputs")]
public List<FormInputValue> Inputs { get; set; } = new List<FormInputValue>();
}
}
@@ -1,23 +1,22 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace Framework.Web
namespace Framework.Web.Rest.Login
{
[DataContract]
public class FormInput
{
[DataMember(Name = "input_id")]
[JsonPropertyName("input_id")]
public string Id { get; set; }
[DataMember(Name = "type")]
[JsonPropertyName("type")]
public string Type { get; set; }
[DataMember(Name = "label")]
[JsonPropertyName("label")]
public string Label { get; set; }
[DataMember(Name = "max_length")]
[JsonPropertyName("max_length")]
public int MaxLength { get; set; }
}
}
@@ -1,17 +1,16 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace Framework.Web
namespace Framework.Web.Rest.Login
{
[DataContract]
public class FormInputValue
{
[DataMember(Name = "input_id")]
[JsonPropertyName("input_id")]
public string Id { get; set; }
[DataMember(Name = "value")]
[JsonPropertyName("value")]
public string Value { get; set; }
}
}
@@ -2,20 +2,22 @@
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace Framework.Web
namespace Framework.Web.Rest.Login
{
[DataContract]
public class FormInputs
{
[DataMember(Name = "type")]
[JsonPropertyName("type")]
public string Type { get; set; }
[DataMember(Name = "prompt")]
public string Prompt { get; set; }
[DataMember(Name = "inputs")]
[JsonPropertyName("inputs")]
public List<FormInput> Inputs { get; set; } = new List<FormInput>();
[JsonPropertyName("srp_url")]
public string SrpUrl { get; set; }
[JsonPropertyName("srp_js")]
public string SrpJs { get; set; }
}
}
@@ -0,0 +1,28 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Text.Json.Serialization;
namespace Framework.Web.Rest.Login
{
public class GameAccountInfo
{
[JsonPropertyName("display_name")]
public string DisplayName { get; set; }
[JsonPropertyName("expansion")]
public int Expansion { get; set; }
[JsonPropertyName("is_suspended")]
public bool IsSuspended { get; set; }
[JsonPropertyName("is_banned")]
public bool IsBanned { get; set; }
[JsonPropertyName("suspension_expires")]
public long SuspensionExpires { get; set; }
[JsonPropertyName("suspension_reason")]
public string SuspensionReason { get; set; }
}
}
@@ -0,0 +1,14 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Framework.Web.Rest.Login
{
public class GameAccountList
{
[JsonPropertyName("game_accounts")]
public List<GameAccountInfo> GameAccounts { get; set; }
}
}
@@ -0,0 +1,23 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Framework.Web.Rest.Login
{
public class LoginForm
{
[JsonPropertyName("platform_id")]
public string PlatformId { get; set; }
[JsonPropertyName("program_id")]
public string ProgramId { get; set; }
[JsonPropertyName("version")]
public string Version { get; set; }
[JsonPropertyName("inputs")]
public List<FormInputValue> Inputs { get; set; } = new List<FormInputValue>();
}
}
@@ -0,0 +1,16 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Text.Json.Serialization;
namespace Framework.Web.Rest.Login
{
public class LoginRefreshResult
{
[JsonPropertyName("login_ticket_expiry")]
public long LoginTicketExpiry { get; set; }
[JsonPropertyName("is_expired")]
public bool IsExpired { get; set; }
}
}
@@ -1,30 +1,29 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace Framework.Web
namespace Framework.Web.Rest.Login
{
[DataContract]
public class LogonResult
public class LoginResult
{
[DataMember(Name = "authentication_state")]
[JsonPropertyName("authentication_state")]
public string AuthenticationState { get; set; }
[DataMember(Name = "login_ticket")]
public string LoginTicket { get; set; }
[DataMember(Name = "error_code")]
[JsonPropertyName("error_code")]
public string ErrorCode { get; set; }
[DataMember(Name = "error_message")]
[JsonPropertyName("error_message")]
public string ErrorMessage { get; set; }
[DataMember(Name = "support_error_code")]
public string SupportErrorCode { get; set; }
[JsonPropertyName("url")]
public string Url { get; set; }
[DataMember(Name = "authenticator_form")]
public FormInputs AuthenticatorForm { get; set; } = new FormInputs();
[JsonPropertyName("login_ticket")]
public string LoginTicket { get; set; }
[JsonPropertyName("server_evidence_M2")]
public string ServerEvidenceM2 { get; set; }
}
public enum AuthenticationState
@@ -0,0 +1,37 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Text.Json.Serialization;
namespace Framework.Web.Rest.Login
{
public class SrpLoginChallenge
{
[JsonPropertyName("version")]
public int Version { get; set; }
[JsonPropertyName("iterations")]
public int Iterations { get; set; }
[JsonPropertyName("modulus")]
public string Modulus { get; set; }
[JsonPropertyName("generator")]
public string Generator { get; set; }
[JsonPropertyName("hash_function")]
public string HashFunction { get; set; }
[JsonPropertyName("username")]
public string Username { get; set; }
[JsonPropertyName("salt")]
public string Salt { get; set; }
[JsonPropertyName("public_B")]
public string PublicB { get; set; }
[JsonPropertyName("eligible_credential_upgrade")]
public bool EligibleCredentialUpgrade { get; set; }
}
}
@@ -1,17 +1,16 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace Framework.Web
namespace Framework.Web.Rest.Realmlist
{
[DataContract]
public class Address
{
[DataMember(Name = "ip")]
[JsonPropertyName("ip")]
public string Ip { get; set; }
[DataMember(Name = "port")]
[JsonPropertyName("port")]
public int Port { get; set; }
}
}
@@ -2,17 +2,16 @@
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace Framework.Web
namespace Framework.Web.Rest.Realmlist
{
[DataContract]
public class AddressFamily
{
[DataMember(Name = "family")]
[JsonPropertyName("family")]
public int Id { get; set; }
[DataMember(Name = "addresses")]
[JsonPropertyName("addresses")]
public IList<Address> Addresses { get; set; } = new List<Address>();
}
}
@@ -2,53 +2,53 @@
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using Framework.Web.Rest.Realmlist;
namespace Framework.Web
{
[DataContract]
public class RealmListTicketInformation
public class ClientInformation
{
[DataMember(Name = "platform")]
[JsonPropertyName("platform")]
public int Platform { get; set; }
[DataMember(Name = "buildVariant")]
[JsonPropertyName("buildVariant")]
public string BuildVariant { get; set; }
[DataMember(Name = "type")]
[JsonPropertyName("type")]
public int Type { get; set; }
[DataMember(Name = "timeZone")]
[JsonPropertyName("timeZone")]
public string Timezone { get; set; }
[DataMember(Name = "currentTime")]
[JsonPropertyName("currentTime")]
public int CurrentTime { get; set; }
[DataMember(Name = "textLocale")]
[JsonPropertyName("textLocale")]
public int TextLocale { get; set; }
[DataMember(Name = "audioLocale")]
[JsonPropertyName("audioLocale")]
public int AudioLocale { get; set; }
[DataMember(Name = "versionDataBuild")]
[JsonPropertyName("versionDataBuild")]
public int VersionDataBuild { get; set; }
[DataMember(Name = "version")]
[JsonPropertyName("version")]
public ClientVersion ClientVersion { get; set; } = new ClientVersion();
[DataMember(Name = "secret")]
[JsonPropertyName("secret")]
public List<int> Secret { get; set; }
[DataMember(Name = "clientArch")]
[JsonPropertyName("clientArch")]
public int ClientArch { get; set; }
[DataMember(Name = "systemVersion")]
[JsonPropertyName("systemVersion")]
public string SystemVersion { get; set; }
[DataMember(Name = "platformType")]
[JsonPropertyName("platformType")]
public int PlatformType { get; set; }
[DataMember(Name = "systemArch")]
[JsonPropertyName("systemArch")]
public int SystemArch { get; set; }
}
}
@@ -1,23 +1,22 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace Framework.Web
namespace Framework.Web.Rest.Realmlist
{
[DataContract]
public class ClientVersion
{
[DataMember(Name = "versionMajor")]
[JsonPropertyName("versionMajor")]
public int Major { get; set; }
[DataMember(Name = "versionBuild")]
[JsonPropertyName("versionBuild")]
public int Build { get; set; }
[DataMember(Name = "versionMinor")]
[JsonPropertyName("versionMinor")]
public int Minor { get; set; }
[DataMember(Name = "versionRevision")]
[JsonPropertyName("versionRevision")]
public int Revision { get; set; }
}
}
@@ -1,17 +1,16 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace Framework.Web
namespace Framework.Web.Rest.Realmlist
{
[DataContract]
public class RealmCharacterCountEntry
{
[DataMember(Name = "wowRealmAddress")]
[JsonPropertyName("wowRealmAddress")]
public int WowRealmAddress { get; set; }
[DataMember(Name = "count")]
[JsonPropertyName("count")]
public int Count { get; set; }
}
}
@@ -2,14 +2,14 @@
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using Framework.Web.Rest.Realmlist;
namespace Framework.Web
{
[DataContract]
public class RealmCharacterCountList
{
[DataMember(Name = "counts")]
[JsonPropertyName("counts")]
public IList<RealmCharacterCountEntry> Counts { get; set; } = new List<RealmCharacterCountEntry>();
}
}
@@ -1,42 +1,41 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using Framework.Web.Rest.Realmlist;
namespace Framework.Web
{
[DataContract]
public class RealmEntry
{
[DataMember(Name = "wowRealmAddress")]
[JsonPropertyName("wowRealmAddress")]
public int WowRealmAddress { get; set; }
[DataMember(Name = "cfgTimezonesID")]
[JsonPropertyName("cfgTimezonesID")]
public int CfgTimezonesID { get; set; }
[DataMember(Name = "populationState")]
[JsonPropertyName("populationState")]
public int PopulationState { get; set; }
[DataMember(Name = "cfgCategoriesID")]
[JsonPropertyName("cfgCategoriesID")]
public int CfgCategoriesID { get; set; }
[DataMember(Name = "version")]
[JsonPropertyName("version")]
public ClientVersion Version { get; set; } = new ClientVersion();
[DataMember(Name = "cfgRealmsID")]
[JsonPropertyName("cfgRealmsID")]
public int CfgRealmsID { get; set; }
[DataMember(Name = "flags")]
[JsonPropertyName("flags")]
public int Flags { get; set; }
[DataMember(Name = "name")]
[JsonPropertyName("name")]
public string Name { get; set; }
[DataMember(Name = "cfgConfigsID")]
[JsonPropertyName("cfgConfigsID")]
public int CfgConfigsID { get; set; }
[DataMember(Name = "cfgLanguagesID")]
[JsonPropertyName("cfgLanguagesID")]
public int CfgLanguagesID { get; set; }
}
}
@@ -2,14 +2,14 @@
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using Framework.Web.Rest.Realmlist;
namespace Framework.Web
{
[DataContract]
public class RealmListServerIPAddresses
{
[DataMember(Name = "families")]
[JsonPropertyName("families")]
public IList<AddressFamily> Families { get; set; } = new List<AddressFamily>();
}
}
@@ -1,14 +1,13 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace Framework.Web
{
[DataContract]
public class RealmListTicketClientInformation
{
[DataMember(Name = "info")]
public RealmListTicketInformation Info { get; set; } = new RealmListTicketInformation();
[JsonPropertyName("info")]
public ClientInformation Info { get; set; } = new ClientInformation();
}
}
@@ -1,17 +1,16 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace Framework.Web
{
[DataContract]
public class RealmListTicketIdentity
{
[DataMember(Name = "gameAccountID")]
[JsonPropertyName("gameAccountID")]
public int GameAccountId { get; set; }
[DataMember(Name = "gameAccountRegion")]
[JsonPropertyName("gameAccountRegion")]
public int GameAccountRegion { get; set; }
}
}
@@ -1,17 +1,16 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace Framework.Web
{
[DataContract]
public class RealmListUpdate
{
[DataMember(Name = "update")]
[JsonPropertyName("update")]
public RealmEntry Update { get; set; } = new RealmEntry();
[DataMember(Name = "deleting")]
[JsonPropertyName("deleting")]
public bool Deleting { get; set; }
}
}
@@ -2,14 +2,13 @@
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace Framework.Web
{
[DataContract]
public class RealmListUpdates
{
[DataMember(Name = "updates")]
[JsonPropertyName("updates")]
public IList<RealmListUpdate> Updates { get; set; } = new List<RealmListUpdate>();
}
}