Some REST and Auth improvement;
Small other improvements and refactoring.
This commit is contained in:
parent
9750e23e24
commit
0ba94f6147
@ -227,10 +227,7 @@ namespace DiIiS_NA.LoginServer.AccountsSystem
|
||||
|
||||
public string BattleTag
|
||||
{
|
||||
get
|
||||
{
|
||||
return BattleTagName + "#" + HashCode.ToString("D4");
|
||||
}
|
||||
get => BattleTagName + "#" + HashCode.ToString("D4");
|
||||
set
|
||||
{
|
||||
if (!value.Contains('#'))
|
||||
|
||||
@ -266,12 +266,12 @@ namespace DiIiS_NA.LoginServer.Battle
|
||||
if (method.Name == "KeepAlive")
|
||||
{
|
||||
Logger.Debug(
|
||||
$"Call: {service.GetType().Name}, Service hash: {header.ServiceHash}, Method: {method.Name}, ID: {header.MethodId}");
|
||||
$"Call: $[olive]{service.GetType().Name}$[/]$, Service hash: $[olive]{header.ServiceHash}$[/]$, Method: $[olive]{method.Name}$[/]$, ID: $[olive]{header.MethodId}$[/]$");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Trace(
|
||||
$"Call: {service.GetType().Name}, Service hash: {header.ServiceHash}, Method: {method.Name}, ID: {header.MethodId}");
|
||||
$"Call: $[olive]${service.GetType().Name}$[/]$, Service hash: $[olive]${header.ServiceHash}$[/]$, Method: $[olive]${method.Name}$[/]$, ID: $[olive]${header.MethodId}$[/]$");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -9,12 +9,12 @@ namespace DiIiS_NA.LoginServer.Battle
|
||||
{
|
||||
public static class PlayerManager
|
||||
{
|
||||
public static readonly List<BattleClient> OnlinePlayers = new List<BattleClient>();
|
||||
public static readonly List<BattleClient> OnlinePlayers = new();
|
||||
|
||||
public static void PlayerConnected(BattleClient client)
|
||||
{
|
||||
var already_logged = OnlinePlayers.Where(cli => cli.Account.Email == client.Account.Email);
|
||||
foreach (var logged in already_logged)
|
||||
var alreadyLoggedIn = OnlinePlayers.Where(cli => cli.Account.Email == client.Account.Email).ToArray();
|
||||
foreach (var logged in alreadyLoggedIn)
|
||||
{
|
||||
OnlinePlayers.Remove(client);
|
||||
logged.SocketConnection.DisconnectAsync();
|
||||
@ -23,6 +23,9 @@ namespace DiIiS_NA.LoginServer.Battle
|
||||
OnlinePlayers.Add(client);
|
||||
}
|
||||
|
||||
public static BattleClient GetClientByEmail(string email) => OnlinePlayers.FirstOrDefault(cli => cli.Account.Email == email);
|
||||
public static BattleClient GetClientByBattleTag(string battleTag) => OnlinePlayers.FirstOrDefault(cli => cli.Account.BattleTag == battleTag);
|
||||
|
||||
public static BattleClient GetClientByCID(ulong cid)
|
||||
{
|
||||
return OnlinePlayers.FirstOrDefault(bc => bc.CID == cid);
|
||||
|
||||
@ -43,7 +43,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
//Error 35 - Battle.net service - Disabled
|
||||
//Error 36 - Failed to load authentication module
|
||||
//Error 37 - Authentication service is receiving too many requests.
|
||||
//Error 38 - To play you need to get BattleTag
|
||||
//Error 38 - To play you need to get a BattleTag
|
||||
//Error 42 - You are connecting to the wrong server (Wrong sequence of actions)
|
||||
//Error 43 - You blocked your account from your mobile phone.
|
||||
//Error 44 - Unable to perform this action. The account is deprived of the function of voice communication.
|
||||
@ -105,11 +105,11 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
case "zhCN": ((HandlerController)controller).Client.ClientLanguage = Battle.BattleClient.ClientLocale.zhCN; break;
|
||||
}
|
||||
done(NoData.CreateBuilder().Build());
|
||||
Logger.Info("----------------------------------------------------------------");
|
||||
var builder = ChallengeExternalRequest.CreateBuilder();
|
||||
var complete = LogonResult.CreateBuilder();
|
||||
switch (request.Program.ToLower())
|
||||
{
|
||||
//case "app":
|
||||
case "d3":
|
||||
//if (!request.HasCachedWebCredentials)
|
||||
{
|
||||
@ -129,8 +129,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Logger.Error("Authorization not implemented for Game: {0}", game);
|
||||
Logger.Info("----------------------------------------------------------------");
|
||||
Logger.Error("Authorization not implemented for Game: $[red]${0}$[/]$ ({1})", game, request.Program.ToLower());
|
||||
break;
|
||||
}
|
||||
|
||||
@ -160,34 +159,33 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
{
|
||||
done(NoData.CreateBuilder().Build());
|
||||
#region Authentication complete
|
||||
if (request.WebCredentials.ToStringUtf8().ToLower().Contains("eu-"))
|
||||
{
|
||||
((HandlerController)controller).Client.Account = AccountManager.GetAccountByPersistentID(1);
|
||||
// if (request.WebCredentials.ToStringUtf8().ToLower().Contains("eu-"))
|
||||
// {
|
||||
// ((HandlerController)controller).Client.Account = AccountManager.GetAccountByPersistentID(1);
|
||||
//
|
||||
// var comple = LogonResult.CreateBuilder()
|
||||
// .SetAccountId(((HandlerController)controller).Client.Account.BnetEntityId)
|
||||
// .SetEmail("TEST@MAIL.DU")
|
||||
// .SetBattleTag("Test#0000")
|
||||
// .SetSessionKey(ByteString.CopyFrom("7CB18EDA470F96A4DD70C70B9307CBBA2A4131043075648D8B2F55EE0E383132025D3CC3BA43406DC0740D776B1E5C366BD1123D16E6D6759075B475C28C4022".ToByteArray()))
|
||||
// .AddAvailableRegion(1)
|
||||
// .AddAvailableRegion(2)
|
||||
// .AddAvailableRegion(3)
|
||||
// .SetConnectedRegion(1)
|
||||
// .SetGeoipCountry("RU")
|
||||
// .SetRestrictedMode(false)
|
||||
// .SetErrorCode(0);
|
||||
// comple.AddGameAccountId(((HandlerController)controller).Client.Account.GameAccount.BnetEntityId);
|
||||
// ((HandlerController)controller).Client.Account.GameAccount.LoggedInClient = ((HandlerController)controller).Client;
|
||||
// ((HandlerController)controller).Client.MakeRPC((lid) => AuthenticationListener.CreateStub(((HandlerController)controller).Client).OnLogonComplete(controller, comple.Build(), callback => { }));
|
||||
// ((HandlerController)controller).Client.Account.GameAccount.ProgramField.Value = "FEN";
|
||||
// PlayerManager.PlayerConnected(((HandlerController)controller).Client);
|
||||
// var ga1selected = GameAccountSelectedRequest.CreateBuilder().SetResult(0).SetGameAccountId(((HandlerController)controller).Client.Account.GameAccount.BnetEntityId);
|
||||
// ((HandlerController)controller).Client.MakeRPC((lid) =>
|
||||
// AuthenticationListener.CreateStub(((HandlerController)controller).Client).OnGameAccountSelected(new HandlerController() { ListenerId = lid }, ga1selected.Build(), callback => { }));
|
||||
// return;
|
||||
// }
|
||||
|
||||
var comple = LogonResult.CreateBuilder()
|
||||
.SetAccountId(((HandlerController)controller).Client.Account.BnetEntityId)
|
||||
.SetEmail("TEST@MAIL.DU")
|
||||
.SetBattleTag("Test#0000")
|
||||
.SetSessionKey(ByteString.CopyFrom("7CB18EDA470F96A4DD70C70B9307CBBA2A4131043075648D8B2F55EE0E383132025D3CC3BA43406DC0740D776B1E5C366BD1123D16E6D6759075B475C28C4022".ToByteArray()))
|
||||
.AddAvailableRegion(1)
|
||||
.AddAvailableRegion(2)
|
||||
.AddAvailableRegion(3)
|
||||
.SetConnectedRegion(1)
|
||||
.SetGeoipCountry("RU")
|
||||
.SetRestrictedMode(false)
|
||||
.SetErrorCode(0);
|
||||
comple.AddGameAccountId(((HandlerController)controller).Client.Account.GameAccount.BnetEntityId);
|
||||
((HandlerController)controller).Client.Account.GameAccount.LoggedInClient = ((HandlerController)controller).Client;
|
||||
((HandlerController)controller).Client.MakeRPC((lid) => AuthenticationListener.CreateStub(((HandlerController)controller).Client).OnLogonComplete(controller, comple.Build(), callback => { }));
|
||||
((HandlerController)controller).Client.Account.GameAccount.ProgramField.Value = "FEN";
|
||||
PlayerManager.PlayerConnected(((HandlerController)controller).Client);
|
||||
var ga1selected = GameAccountSelectedRequest.CreateBuilder().SetResult(0).SetGameAccountId(((HandlerController)controller).Client.Account.GameAccount.BnetEntityId);
|
||||
((HandlerController)controller).Client.MakeRPC((lid) =>
|
||||
AuthenticationListener.CreateStub(((HandlerController)controller).Client).OnGameAccountSelected(new HandlerController() { ListenerId = lid }, ga1selected.Build(), callback => { }));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
((HandlerController)controller).Client.Account = AccountManager.GetAccountBySaltTicket(request.WebCredentials.ToStringUtf8());
|
||||
|
||||
if (((HandlerController)controller).Client.Account == null)
|
||||
@ -199,8 +197,8 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Info("Client connected - {0}#{1}", ((HandlerController)controller).Client.Account.DBAccount.BattleTagName, ((HandlerController)controller).Client.Account.HashCode);
|
||||
Logger.Info("----------------------------------------------------------------");
|
||||
Logger.Info(
|
||||
$"Client connected - {((HandlerController)controller).Client.Account.DBAccount.BattleTagName}#{((HandlerController)controller).Client.Account.HashCode}");
|
||||
var complete = LogonResult.CreateBuilder()
|
||||
.SetAccountId(((HandlerController)controller).Client.Account.BnetEntityId)
|
||||
.SetEmail(((HandlerController)controller).Client.Account.Email)
|
||||
@ -209,17 +207,16 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
.SetConnectedRegion(1)
|
||||
.SetGeoipCountry("RU")
|
||||
.SetRestrictedMode(false)
|
||||
.SetErrorCode(0);
|
||||
complete.AddGameAccountId(((HandlerController)controller).Client.Account.GameAccount.BnetEntityId); //D3
|
||||
.SetErrorCode(0)
|
||||
.AddGameAccountId(((HandlerController)controller).Client.Account.GameAccount.BnetEntityId); //D3
|
||||
((HandlerController)controller).Client.Account.GameAccount.LoggedInClient = ((HandlerController)controller).Client;
|
||||
((HandlerController)controller).Client.MakeRPC((lid) => AuthenticationListener.CreateStub(((HandlerController)controller).Client).OnLogonComplete(controller, complete.Build(), callback => { }));
|
||||
|
||||
PlayerManager.PlayerConnected(((HandlerController)controller).Client);
|
||||
|
||||
var gaselected = GameAccountSelectedRequest.CreateBuilder().SetResult(0).SetGameAccountId(((HandlerController)controller).Client.Account.GameAccount.BnetEntityId);
|
||||
var selectedGameAccount = GameAccountSelectedRequest.CreateBuilder().SetResult(0).SetGameAccountId(((HandlerController)controller).Client.Account.GameAccount.BnetEntityId);
|
||||
((HandlerController)controller).Client.MakeRPC((lid) =>
|
||||
AuthenticationListener.CreateStub(((HandlerController)controller).Client).OnGameAccountSelected(new HandlerController() { ListenerId = lid }, gaselected.Build(), callback => { }));
|
||||
}
|
||||
AuthenticationListener.CreateStub(((HandlerController)controller).Client).OnGameAccountSelected(new HandlerController() { ListenerId = lid }, selectedGameAccount.Build(), callback => { }));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
(controller as HandlerController).Client.Services.Add(2119327385, 0x26);
|
||||
|
||||
done(builder.Build());
|
||||
Logger.Info("Connect with $[dodgerblue1]$Blizz$[/]$$[deepskyblue2]$less$[/]$ established. Client - {0}", (controller as HandlerController).Client.SocketConnection.RemoteAddress);
|
||||
Logger.Info("Connect with Blizzless established. Client - {0}", (controller as HandlerController).Client.SocketConnection.RemoteAddress);
|
||||
}
|
||||
|
||||
public override void Echo(IRpcController controller, EchoRequest request, Action<EchoResponse> done)
|
||||
|
||||
@ -49,7 +49,7 @@ namespace DiIiS_NA.REST.Http
|
||||
return Encoding.UTF8.GetBytes(sb.ToString());
|
||||
}
|
||||
|
||||
public static byte[] CreateResponse(HttpCode httpCode, string content, bool closeConnection = false)
|
||||
public static byte[] CreateResponse(HttpCode httpCode, string content, bool closeConnection = false, string contentType = "application/json;charset=UTF-8")
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
@ -60,7 +60,7 @@ namespace DiIiS_NA.REST.Http
|
||||
if (closeConnection)
|
||||
sw.WriteLine("Connection: close");
|
||||
|
||||
sw.WriteLine("Content-Type: application/json;charset=UTF-8");
|
||||
sw.WriteLine("Content-Type: " + contentType);
|
||||
sw.WriteLine();
|
||||
|
||||
sw.WriteLine(content);
|
||||
|
||||
@ -13,6 +13,8 @@ using DiIiS_NA.REST.Data.Authentication;
|
||||
using DiIiS_NA.REST.JSON;
|
||||
using DiIiS_NA.LoginServer.AccountsSystem;
|
||||
using System.IO;
|
||||
using System.Net.Security;
|
||||
using System.Web;
|
||||
using DiIiS_NA.GameServer.MessageSystem;
|
||||
|
||||
namespace DiIiS_NA.REST
|
||||
@ -97,7 +99,7 @@ namespace DiIiS_NA.REST
|
||||
|
||||
void SendResponseHtml(HttpCode code, string response)
|
||||
{
|
||||
AsyncWrite(HttpHelper.CreateResponse(code, response));
|
||||
AsyncWrite(HttpHelper.CreateResponse(code, response, contentType: "text/html"));
|
||||
}
|
||||
|
||||
public override void Start()
|
||||
|
||||
Loading…
Reference in New Issue
user.block.title