Refactoring of BNetServer

This commit is contained in:
hondacrx
2020-07-12 00:06:43 -04:00
parent 4164384b72
commit 581d077acd
318 changed files with 2046 additions and 4694 deletions
+9 -9
View File
@@ -4,15 +4,6 @@
###################################################################################################
# BNet SERVER SETTINGS
#
# LogsDir
# Description: Logs directory setting.
# Important: LogsDir needs to be quoted, as the string might contain space characters.
# Logs directory must exists, or log file creation will be disabled.
# Default: "Logs" - (Log files will be stored in the current path)
LogsDir = "Logs"
#
# BattlenetPort
# Description: TCP port to reach the auth server for battle.net connections.
@@ -177,6 +168,15 @@ Updates.CleanDeadRefMaxCount = 3
###################################################################################################
#
# LOGGING SYSTEM SETTINGS
#
# LogsDir
# Description: Logs directory setting.
# Important: LogsDir needs to be quoted, as the string might contain space characters.
# Logs directory must exists, or log file creation will be disabled.
# Default: "Logs" - (Log files will be stored in the current path)
LogsDir = "Logs"
#
# Appender config values: Given a appender "name"
# Appender.name
+4 -3
View File
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\default.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<StartupObject>BNetServer.Server</StartupObject>
<ApplicationIcon>Red.ico</ApplicationIcon>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Packaging.Tools.Trimming" Version="1.1.0-preview1-26619-01" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Framework\Framework.csproj" />
</ItemGroup>
+7 -22
View File
@@ -1,28 +1,13 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// 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 BNetServer.Services;
using System;
using System.Collections.Generic;
using System.Text;
using BNetServer;
namespace BNetServer
{
public static class Global
{
public static RealmManager RealmMgr { get { return RealmManager.Instance; } }
public static SessionManager SessionMgr { get { return SessionManager.Instance; } }
public static ServiceDispatcher ServiceDispatcher { get { return ServiceDispatcher.Instance; } }
}
public static LoginServiceManager LoginServiceMgr { get { return LoginServiceManager.Instance; } }
}
@@ -0,0 +1,195 @@
// 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 BNetServer.Networking;
using Framework.Configuration;
using Framework.Constants;
using Framework.Web;
using Google.Protobuf;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Net;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
namespace BNetServer
{
public class LoginServiceManager : Singleton<LoginServiceManager>
{
ConcurrentDictionary<(uint ServiceHash, uint MethodId), BnetServiceHandler> serviceHandlers;
FormInputs formInputs;
IPEndPoint externalAddress;
IPEndPoint localAddress;
X509Certificate2 certificate;
LoginServiceManager()
{
serviceHandlers = new ConcurrentDictionary<(uint ServiceHash, uint MethodId), BnetServiceHandler>();
formInputs = new FormInputs();
}
public void Initialize()
{
int port = ConfigMgr.GetDefaultValue("LoginREST.Port", 8081);
if (port < 0 || port > 0xFFFF)
{
Log.outError(LogFilter.Network, $"Specified login service port ({port}) out of allowed range (1-65535), defaulting to 8081");
port = 8081;
}
string configuredAddress = ConfigMgr.GetDefaultValue("LoginREST.ExternalAddress", "127.0.0.1");
IPAddress address;
if (!IPAddress.TryParse(configuredAddress, out address))
{
Log.outError(LogFilter.Network, $"Could not resolve LoginREST.ExternalAddress {configuredAddress}");
return;
}
externalAddress = new IPEndPoint(address, port);
configuredAddress = ConfigMgr.GetDefaultValue("LoginREST.LocalAddress", "127.0.0.1");
if (!IPAddress.TryParse(configuredAddress, out address))
{
Log.outError(LogFilter.Network, $"Could not resolve LoginREST.ExternalAddress {configuredAddress}");
return;
}
localAddress = new IPEndPoint(address, port);
// set up form inputs
formInputs.Type = "LOGIN_FORM";
var input = new FormInput();
input.Id = "account_name";
input.Type = "text";
input.Label = "E-mail";
input.MaxLength = 320;
formInputs.Inputs.Add(input);
input = new FormInput();
input.Id = "password";
input.Type = "password";
input.Label = "Password";
input.MaxLength = 16;
formInputs.Inputs.Add(input);
input = new FormInput();
input.Id = "log_in_submit";
input.Type = "submit";
input.Label = "Log In";
formInputs.Inputs.Add(input);
certificate = new X509Certificate2("BNetServer.pfx");
Assembly currentAsm = Assembly.GetExecutingAssembly();
foreach (var type in currentAsm.GetTypes())
{
foreach (var methodInfo in type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic))
{
foreach (var serviceAttr in methodInfo.GetCustomAttributes<ServiceAttribute>())
{
if (serviceAttr == null)
continue;
var key = (serviceAttr.ServiceHash, serviceAttr.MethodId);
if (serviceHandlers.ContainsKey(key))
{
Log.outError(LogFilter.Network, $"Tried to override ServiceHandler: {serviceHandlers[key]} with {methodInfo.Name} (ServiceHash: {serviceAttr.ServiceHash} MethodId: {serviceAttr.MethodId})");
continue;
}
var parameters = methodInfo.GetParameters();
if (parameters.Length == 0)
{
Log.outError(LogFilter.Network, $"Method: {methodInfo.Name} needs atleast one paramter");
continue;
}
serviceHandlers[key] = new BnetServiceHandler(methodInfo, parameters);
}
}
}
}
public BnetServiceHandler GetHandler(uint serviceHash, uint methodId)
{
return serviceHandlers.LookupByKey((serviceHash, methodId));
}
public IPEndPoint GetAddressForClient(IPAddress address)
{
if (IPAddress.IsLoopback(address))
return localAddress;
return externalAddress;
}
public FormInputs GetFormInput()
{
return formInputs;
}
public X509Certificate2 GetCertificate()
{
return certificate;
}
}
public class BnetServiceHandler
{
Delegate methodCaller;
Type requestType;
Type responseType;
public BnetServiceHandler(MethodInfo info, ParameterInfo[] parameters)
{
requestType = parameters[0].ParameterType;
if (parameters.Length > 1)
responseType = parameters[1].ParameterType;
if (responseType != null)
methodCaller = info.CreateDelegate(Expression.GetDelegateType(new[] { typeof(Session), requestType, responseType, info.ReturnType }));
else
methodCaller = info.CreateDelegate(Expression.GetDelegateType(new[] { typeof(Session), requestType, info.ReturnType }));
}
public void Invoke(Session session, uint token, CodedInputStream stream)
{
var request = (IMessage)Activator.CreateInstance(requestType);
request.MergeFrom(stream);
BattlenetRpcErrorCode status;
if (responseType != null)
{
var response = (IMessage)Activator.CreateInstance(responseType);
status = (BattlenetRpcErrorCode)methodCaller.DynamicInvoke(session, request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server Method: {1}) Returned: {2} Status: {3}.", session.GetClientInfo(), request, response, status);
if (status == 0)
session.SendResponse(token, response);
else
session.SendResponse(token, status);
}
else
{
status = (BattlenetRpcErrorCode)methodCaller.DynamicInvoke(session, request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server Method: {1}) Status: {2}.", session.GetClientInfo(), request, status);
if (status != 0)
session.SendResponse(token, status);
}
}
}
[AttributeUsage(AttributeTargets.Method)]
public sealed class ServiceAttribute : System.Attribute
{
public uint ServiceHash { get; set; }
public uint MethodId { get; set; }
public ServiceAttribute(OriginalHash serviceHash, uint methodId)
{
ServiceHash = (uint)serviceHash;
MethodId = methodId;
}
}
}
@@ -1,116 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Framework.Configuration;
using Framework.Rest;
using System.Net;
using System.Security.Cryptography.X509Certificates;
namespace BNetServer
{
public class SessionManager : Singleton<SessionManager>
{
SessionManager()
{
_formInputs = new FormInputs();
}
public bool Initialize()
{
int _port = ConfigMgr.GetDefaultValue("LoginREST.Port", 8081);
if (_port < 0 || _port > 0xFFFF)
{
Log.outError(LogFilter.Network, "Specified login service port ({0}) out of allowed range (1-65535), defaulting to 8081", _port);
_port = 8081;
}
string configuredAddress = ConfigMgr.GetDefaultValue("LoginREST.ExternalAddress", "127.0.0.1");
IPAddress address;
if (!IPAddress.TryParse(configuredAddress, out address))
{
Log.outError(LogFilter.Network, "Could not resolve LoginREST.ExternalAddress {0}", configuredAddress);
return false;
}
_externalAddress = new IPEndPoint(address, _port);
configuredAddress = ConfigMgr.GetDefaultValue("LoginREST.LocalAddress", "127.0.0.1");
if (!IPAddress.TryParse(configuredAddress, out address))
{
Log.outError(LogFilter.Network, "Could not resolve LoginREST.ExternalAddress {0}", configuredAddress);
return false;
}
_localAddress = new IPEndPoint(address, _port);
// set up form inputs
_formInputs.Type = "LOGIN_FORM";
var input = new FormInput();
input.Id = "account_name";
input.Type = "text";
input.Label = "E-mail";
input.MaxLength = 320;
_formInputs.Inputs.Add(input);
input = new FormInput();
input.Id = "password";
input.Type = "password";
input.Label = "Password";
input.MaxLength = 16;
_formInputs.Inputs.Add(input);
input = new FormInput();
input.Id = "log_in_submit";
input.Type = "submit";
input.Label = "Log In";
_formInputs.Inputs.Add(input);
_certificate = new X509Certificate2("BNetServer.pfx");
return true;
}
public IPEndPoint GetAddressForClient(IPAddress address)
{
if (IPAddress.IsLoopback(address))
return _localAddress;
return _externalAddress;
}
public FormInputs GetFormInput()
{
return _formInputs;
}
public X509Certificate2 GetCertificate()
{
return _certificate;
}
FormInputs _formInputs;
IPEndPoint _externalAddress;
IPEndPoint _localAddress;
X509Certificate2 _certificate;
}
public enum BanMode
{
Ip = 0,
Account = 1
}
}
+28 -47
View File
@@ -1,30 +1,17 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// 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.Configuration;
using Framework.Database;
using Framework.Networking;
using Framework.Rest;
using Framework.Serialization;
using Framework.Web;
using System;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Text;
using Framework.Networking;
using System.Net.Sockets;
using Framework.Web;
using Framework.Constants;
using Framework.Database;
using Framework.Configuration;
using Framework.Serialization;
using System.Security.Cryptography;
namespace BNetServer.Networking
{
@@ -32,14 +19,14 @@ namespace BNetServer.Networking
{
public RestSession(Socket socket) : base(socket) { }
public override void Start()
public override void Accept()
{
AsyncHandshake(Global.SessionMgr.GetCertificate());
AsyncHandshake(Global.LoginServiceMgr.GetCertificate());
}
public override void ReadHandler(int transferredBytes)
public async override void ReadHandler(byte[] data, int receivedLength)
{
var httpRequest = HttpHelper.ParseRequest(GetReceiveBuffer(), transferredBytes);
var httpRequest = HttpHelper.ParseRequest(data, receivedLength);
if (httpRequest == null)
return;
@@ -47,20 +34,14 @@ namespace BNetServer.Networking
{
case "GET":
default:
HandleConnectRequest(httpRequest);
SendResponse(HttpCode.Ok, Global.LoginServiceMgr.GetFormInput());
break;
case "POST":
HandleLoginRequest(httpRequest);
return;
}
AsyncRead();
}
public void HandleConnectRequest(HttpHeader request)
{
// Login form is the same for all clients...
SendResponse(HttpCode.Ok, Global.SessionMgr.GetFormInput());
await AsyncRead();
}
public void HandleLoginRequest(HttpHeader request)
@@ -92,7 +73,7 @@ namespace BNetServer.Networking
}
}
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_AUTHENTICATION);
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetAuthentication);
stmt.AddValue(0, login);
SQLResult result = DB.Login.Query(stmt);
@@ -113,7 +94,7 @@ namespace BNetServer.Networking
loginTicket = "TC-" + ticket.ToHexString();
}
stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_AUTHENTICATION);
stmt = DB.Login.GetPreparedStatement(LoginStatements.UpdBnetAuthentication);
stmt.AddValue(0, loginTicket);
stmt.AddValue(1, Time.UnixTime + 3600);
stmt.AddValue(2, accountId);
@@ -126,39 +107,39 @@ namespace BNetServer.Networking
uint maxWrongPassword = ConfigMgr.GetDefaultValue("WrongPass.MaxCount", 0u);
if (ConfigMgr.GetDefaultValue("WrongPass.Logging", false))
Log.outDebug(LogFilter.Network, "[{0}, Account {1}, Id {2}] Attempted to connect with wrong password!", request.Host, login, accountId);
Log.outDebug(LogFilter.Network, $"[{request.Host}, Account {login}, Id {accountId}] Attempted to connect with wrong password!");
if (maxWrongPassword != 0)
{
SQLTransaction trans = new SQLTransaction();
stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_FAILED_LOGINS);
stmt = DB.Login.GetPreparedStatement(LoginStatements.UpdBnetFailedLogins);
stmt.AddValue(0, accountId);
trans.Append(stmt);
++failedLogins;
Log.outDebug(LogFilter.Network, "MaxWrongPass : {0}, failed_login : {1}", maxWrongPassword, accountId);
Log.outDebug(LogFilter.Network, "MaxWrongPass : {maxWrongPassword}, failed_login : {accountId}");
if (failedLogins >= maxWrongPassword)
{
BanMode banType = ConfigMgr.GetDefaultValue("WrongPass.BanType", BanMode.Ip);
BanMode banType = ConfigMgr.GetDefaultValue("WrongPass.BanType", BanMode.IP);
int banTime = ConfigMgr.GetDefaultValue("WrongPass.BanTime", 600);
if (banType == BanMode.Account)
{
stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_BNET_ACCOUNT_AUTO_BANNED);
stmt = DB.Login.GetPreparedStatement(LoginStatements.InsBnetAccountAutoBanned);
stmt.AddValue(0, accountId);
}
else
{
stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_IP_AUTO_BANNED);
stmt = DB.Login.GetPreparedStatement(LoginStatements.InsIpAutoBanned);
stmt.AddValue(0, request.Host);
}
stmt.AddValue(1, banTime);
trans.Append(stmt);
stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_RESET_FAILED_LOGINS);
stmt = DB.Login.GetPreparedStatement(LoginStatements.UpdBnetResetFailedLogins);
stmt.AddValue(0, accountId);
trans.Append(stmt);
}
@@ -179,9 +160,9 @@ namespace BNetServer.Networking
}
}
void SendResponse<T>(HttpCode code, T response)
async void SendResponse<T>(HttpCode code, T response)
{
AsyncWrite(HttpHelper.CreateResponse(code, Json.CreateString(response)));
await AsyncWrite(HttpHelper.CreateResponse(code, Json.CreateString(response)));
}
string CalculateShaPassHash(string name, string password)
@@ -0,0 +1,76 @@
// 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 Bgs.Protocol.Account.V1;
using Framework.Constants;
using System.Collections.Generic;
namespace BNetServer.Networking
{
public partial class Session
{
[Service(OriginalHash.AccountService, 30)]
BattlenetRpcErrorCode HandleGetAccountState(GetAccountStateRequest request, GetAccountStateResponse response)
{
if (!authed)
return BattlenetRpcErrorCode.Denied;
if (request.Options.FieldPrivacyInfo)
{
response.State = new AccountState();
response.State.PrivacyInfo = new PrivacyInfo();
response.State.PrivacyInfo.IsUsingRid = false;
response.State.PrivacyInfo.IsVisibleForViewFriends = false;
response.State.PrivacyInfo.IsHiddenFromFriendFinder = true;
response.Tags = new AccountFieldTags();
response.Tags.PrivacyInfoTag = 0xD7CA834D;
}
return BattlenetRpcErrorCode.Ok;
}
[Service(OriginalHash.AccountService, 31)]
BattlenetRpcErrorCode HandleGetGameAccountState(GetGameAccountStateRequest request, GetGameAccountStateResponse response)
{
if (!authed)
return BattlenetRpcErrorCode.Denied;
if (request.Options.FieldGameLevelInfo)
{
var gameAccountInfo = accountInfo.GameAccounts.LookupByKey(request.GameAccountId.Low);
if (gameAccountInfo != null)
{
response.State = new GameAccountState();
response.State.GameLevelInfo = new GameLevelInfo();
response.State.GameLevelInfo.Name = gameAccountInfo.DisplayName;
response.State.GameLevelInfo.Program = 5730135; // WoW
}
response.Tags = new GameAccountFieldTags();
response.Tags.GameLevelInfoTag = 0x5C46D483;
}
if (request.Options.FieldGameStatus)
{
if (response.State == null)
response.State = new GameAccountState();
response.State.GameStatus = new GameStatus();
var gameAccountInfo = accountInfo.GameAccounts.LookupByKey(request.GameAccountId.Low);
if (gameAccountInfo != null)
{
response.State.GameStatus.IsSuspended = gameAccountInfo.IsBanned;
response.State.GameStatus.IsBanned = gameAccountInfo.IsPermanenetlyBanned;
response.State.GameStatus.SuspensionExpires = (gameAccountInfo.UnbanDate * 1000000);
}
response.State.GameStatus.Program = 5730135; // WoW
response.Tags.GameStatusTag = 0x98B75F99;
}
return BattlenetRpcErrorCode.Ok;
}
}
}
@@ -0,0 +1,169 @@
// 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 Bgs.Protocol;
using Bgs.Protocol.Authentication.V1;
using Bgs.Protocol.Challenge.V1;
using Framework.Constants;
using Framework.Database;
using Google.Protobuf;
using System;
using Framework.Realm;
using System.Net;
namespace BNetServer.Networking
{
public partial class Session
{
[Service(OriginalHash.AuthenticationService, 1)]
BattlenetRpcErrorCode HandleLogon(LogonRequest logonRequest, NoData response)
{
if (logonRequest.Program != "WoW")
{
Log.outDebug(LogFilter.Session, $"Battlenet.LogonRequest: {GetClientInfo()} attempted to log in with game other than WoW (using {logonRequest.Program})!");
return BattlenetRpcErrorCode.BadProgram;
}
if (logonRequest.Platform != "Win" && logonRequest.Platform != "Wn64" && logonRequest.Platform != "Mc64")
{
Log.outDebug(LogFilter.Session, $"Battlenet.LogonRequest: {GetClientInfo()} attempted to log in from an unsupported platform (using {logonRequest.Platform})!");
return BattlenetRpcErrorCode.BadPlatform;
}
if (logonRequest.Locale.ToEnum<Locale>() == Locale.enUS && logonRequest.Locale != "enUS")
{
Log.outDebug(LogFilter.Session, $"Battlenet.LogonRequest: {GetClientInfo()} attempted to log in with unsupported locale (using {logonRequest.Locale})!");
return BattlenetRpcErrorCode.BadLocale;
}
locale = logonRequest.Locale;
os = logonRequest.Platform;
build = (uint)logonRequest.ApplicationVersion;
var endpoint = Global.LoginServiceMgr.GetAddressForClient(GetRemoteIpEndPoint().Address);
ChallengeExternalRequest externalChallenge = new ChallengeExternalRequest();
externalChallenge.PayloadType = "web_auth_url";
externalChallenge.Payload = ByteString.CopyFromUtf8($"https://{endpoint.Address}:{endpoint.Port}/bnetserver/login/");
SendRequest((uint)OriginalHash.ChallengeListener, 3, externalChallenge);
return BattlenetRpcErrorCode.Ok;
}
[Service(OriginalHash.AuthenticationService, 7)]
BattlenetRpcErrorCode HandleVerifyWebCredentials(VerifyWebCredentialsRequest verifyWebCredentialsRequest)
{
if (verifyWebCredentialsRequest.WebCredentials.IsEmpty)
return BattlenetRpcErrorCode.Denied;
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetAccountInfo);
stmt.AddValue(0, verifyWebCredentialsRequest.WebCredentials.ToStringUtf8());
SQLResult result = DB.Login.Query(stmt);
if (result.IsEmpty())
return BattlenetRpcErrorCode.Denied;
accountInfo = new AccountInfo(result);
if (accountInfo.LoginTicketExpiry < Time.UnixTime)
return BattlenetRpcErrorCode.TimedOut;
stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetCharacterCountsByAccountId);
stmt.AddValue(0, accountInfo.Id);
SQLResult characterCountsResult = DB.Login.Query(stmt);
if (!characterCountsResult.IsEmpty())
{
do
{
var realmId = new RealmId(characterCountsResult.Read<byte>(3), characterCountsResult.Read<byte>(4), characterCountsResult.Read<uint>(2));
accountInfo.GameAccounts[characterCountsResult.Read<uint>(0)].CharacterCounts[realmId.GetAddress()] = characterCountsResult.Read<byte>(1);
} while (characterCountsResult.NextRow());
}
stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetLastPlayerCharacters);
stmt.AddValue(0, accountInfo.Id);
SQLResult lastPlayerCharactersResult = DB.Login.Query(stmt);
if (!lastPlayerCharactersResult.IsEmpty())
{
do
{
var realmId = new RealmId(lastPlayerCharactersResult.Read<byte>(1), lastPlayerCharactersResult.Read<byte>(2), lastPlayerCharactersResult.Read<uint>(3));
LastPlayedCharacterInfo lastPlayedCharacter = new LastPlayedCharacterInfo();
lastPlayedCharacter.RealmId = realmId;
lastPlayedCharacter.CharacterName = lastPlayerCharactersResult.Read<string>(4);
lastPlayedCharacter.CharacterGUID = lastPlayerCharactersResult.Read<ulong>(5);
lastPlayedCharacter.LastPlayedTime = lastPlayerCharactersResult.Read<uint>(6);
accountInfo.GameAccounts[lastPlayerCharactersResult.Read<uint>(0)].LastPlayedCharacters[realmId.GetSubRegionAddress()] = lastPlayedCharacter;
} while (lastPlayerCharactersResult.NextRow());
}
string ip_address = GetRemoteIpEndPoint().ToString();
// If the IP is 'locked', check that the player comes indeed from the correct IP address
if (accountInfo.IsLockedToIP)
{
Log.outDebug(LogFilter.Session, $"Session.HandleVerifyWebCredentials: Account: {accountInfo.Login} is locked to IP: {accountInfo.LastIP} is logging in from IP: {ip_address}");
if (accountInfo.LastIP != ip_address)
return BattlenetRpcErrorCode.RiskAccountLocked;
}
else
{
Log.outDebug(LogFilter.Session, $"Session.HandleVerifyWebCredentials: Account: {accountInfo.Login} is not locked to ip");
if (accountInfo.LockCountry.IsEmpty() || accountInfo.LockCountry == "00")
Log.outDebug(LogFilter.Session, $"Session.HandleVerifyWebCredentials: Account: {accountInfo.Login} is not locked to country");
else if (!accountInfo.LockCountry.IsEmpty() && !ipCountry.IsEmpty())
{
Log.outDebug(LogFilter.Session, $"Session.HandleVerifyWebCredentials: Account: {accountInfo.Login} is locked to Country: {accountInfo.LockCountry} player Country: {ipCountry}");
if (ipCountry != accountInfo.LockCountry)
return BattlenetRpcErrorCode.RiskAccountLocked;
}
}
// If the account is banned, reject the logon attempt
if (accountInfo.IsBanned)
{
if (accountInfo.IsPermanenetlyBanned)
{
Log.outDebug(LogFilter.Session, $"{GetClientInfo()} Session.HandleVerifyWebCredentials: Banned account {accountInfo.Login} tried to login!");
return BattlenetRpcErrorCode.GameAccountBanned;
}
else
{
Log.outDebug(LogFilter.Session, $"{GetClientInfo()} Session.HandleVerifyWebCredentials: Temporarily banned account {accountInfo.Login} tried to login!");
return BattlenetRpcErrorCode.GameAccountSuspended;
}
}
LogonResult logonResult = new LogonResult();
logonResult.ErrorCode = 0;
logonResult.AccountId = new EntityId();
logonResult.AccountId.Low = accountInfo.Id;
logonResult.AccountId.High = 0x100000000000000;
foreach (var pair in accountInfo.GameAccounts)
{
EntityId gameAccountId = new EntityId();
gameAccountId.Low = pair.Value.Id;
gameAccountId.High = 0x200000200576F57;
logonResult.GameAccountId.Add(gameAccountId);
}
if (!ipCountry.IsEmpty())
logonResult.GeoipCountry = ipCountry;
logonResult.SessionKey = ByteString.CopyFrom(new byte[64].GenerateRandomKey(64));
authed = true;
SendRequest((uint)OriginalHash.AuthenticationListener, 5, logonResult);
return BattlenetRpcErrorCode.Ok;
}
}
}
@@ -0,0 +1,48 @@
// 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 Bgs.Protocol.Connection.V1;
using Framework.Constants;
using System.Collections.Generic;
using Google.Protobuf;
using Bgs.Protocol;
using System.Diagnostics;
namespace BNetServer.Networking
{
public partial class Session
{
[Service(OriginalHash.ConnectionService, 1)]
BattlenetRpcErrorCode HandleConnect(ConnectRequest request, ConnectResponse response)
{
if (request.ClientId != null)
response.ClientId.MergeFrom(request.ClientId);
response.ServerId = new ProcessId();
response.ServerId.Label = (uint)Process.GetCurrentProcess().Id;
response.ServerId.Epoch = (uint)Time.UnixTime;
response.ServerTime = (ulong)Time.UnixTimeMilliseconds;
response.UseBindlessRpc = request.UseBindlessRpc;
return BattlenetRpcErrorCode.Ok;
}
[Service(OriginalHash.ConnectionService, 5)]
BattlenetRpcErrorCode HandleKeepAlive(NoData request)
{
return BattlenetRpcErrorCode.Ok;
}
[Service(OriginalHash.ConnectionService, 7)]
BattlenetRpcErrorCode HandleRequestDisconnect(DisconnectRequest request)
{
var disconnectNotification = new DisconnectNotification();
disconnectNotification.ErrorCode = request.ErrorCode;
SendRequest((uint)OriginalHash.ConnectionService, 4, disconnectNotification);
CloseSocket();
return BattlenetRpcErrorCode.Ok;
}
}
}
@@ -0,0 +1,207 @@
// 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 Bgs.Protocol;
using Bgs.Protocol.GameUtilities.V1;
using Framework.Constants;
using Framework.Database;
using Framework.Serialization;
using Framework.Web;
using Google.Protobuf;
using System;
using System.Collections.Generic;
namespace BNetServer.Networking
{
public partial class Session
{
[Service(OriginalHash.GameUtilitiesService, 1)]
BattlenetRpcErrorCode HandleProcessClientRequest(ClientRequest request, ClientResponse response)
{
if (!authed)
return BattlenetRpcErrorCode.Denied;
Bgs.Protocol.Attribute command = null;
Dictionary<string, Variant> Params = new Dictionary<string, Variant>();
for (int i = 0; i < request.Attribute.Count; ++i)
{
Bgs.Protocol.Attribute attr = request.Attribute[i];
Params[attr.Name] = attr.Value;
if (attr.Name.Contains("Command_"))
command = attr;
}
if (command == null)
{
Log.outError(LogFilter.SessionRpc, $"{GetClientInfo()} sent ClientRequest with no command.");
return BattlenetRpcErrorCode.RpcMalformedRequest;
}
return command.Name switch
{
"Command_RealmListTicketRequest_v1_b9" => GetRealmListTicket(Params, response),
"Command_LastCharPlayedRequest_v1_b9" => GetLastCharPlayed(Params, response),
"Command_RealmListRequest_v1_b9" => GetRealmList(Params, response),
"Command_RealmJoinRequest_v1_b9" => JoinRealm(Params, response),
_ => BattlenetRpcErrorCode.RpcNotImplemented
};
}
[Service(OriginalHash.GameUtilitiesService, 10)]
BattlenetRpcErrorCode HandleGetAllValuesForAttribute(GetAllValuesForAttributeRequest request, GetAllValuesForAttributeResponse response)
{
if (!authed)
return BattlenetRpcErrorCode.Denied;
if (request.AttributeKey == "Command_RealmListRequest_v1_b9")
{
Global.RealmMgr.WriteSubRegions(response);
return BattlenetRpcErrorCode.Ok;
}
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode GetRealmListTicket(Dictionary<string, Variant> Params, ClientResponse response)
{
Variant identity = Params.LookupByKey("Param_Identity");
if (identity != null)
{
var realmListTicketIdentity = Json.CreateObject<RealmListTicketIdentity>(identity.BlobValue.ToStringUtf8(), true);
var gameAccount = accountInfo.GameAccounts.LookupByKey(realmListTicketIdentity.GameAccountId);
if (gameAccount != null)
gameAccountInfo = gameAccount;
}
if (gameAccountInfo == null)
return BattlenetRpcErrorCode.UtilServerInvalidIdentityArgs;
if (gameAccountInfo.IsPermanenetlyBanned)
return BattlenetRpcErrorCode.GameAccountBanned;
else if (gameAccountInfo.IsBanned)
return BattlenetRpcErrorCode.GameAccountSuspended;
bool clientInfoOk = false;
Variant clientInfo = Params.LookupByKey("Param_ClientInfo");
if (clientInfo != null)
{
var realmListTicketClientInformation = Json.CreateObject<RealmListTicketClientInformation>(clientInfo.BlobValue.ToStringUtf8(), true);
clientInfoOk = true;
int i = 0;
foreach (byte b in realmListTicketClientInformation.Info.Secret)
clientSecret[i++] = b;
}
if (!clientInfoOk)
return BattlenetRpcErrorCode.WowServicesDeniedRealmListTicket;
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UpdBnetLastLoginInfo);
stmt.AddValue(0, GetRemoteIpEndPoint().ToString());
stmt.AddValue(1, Enum.Parse(typeof(Locale), locale));
stmt.AddValue(2, os);
stmt.AddValue(3, accountInfo.Id);
DB.Login.Execute(stmt);
var attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_RealmListTicket";
attribute.Value = new Variant();
attribute.Value.BlobValue = ByteString.CopyFrom("AuthRealmListTicket", System.Text.Encoding.UTF8);
response.Attribute.Add(attribute);
return BattlenetRpcErrorCode.Ok;
}
BattlenetRpcErrorCode GetLastCharPlayed(Dictionary<string, Variant> Params, ClientResponse response)
{
Variant subRegion = Params.LookupByKey("Command_LastCharPlayedRequest_v1_b9");
if (subRegion != null)
{
var lastPlayerChar = gameAccountInfo.LastPlayedCharacters.LookupByKey(subRegion.StringValue);
if (lastPlayerChar != null)
{
var compressed = Global.RealmMgr.GetRealmEntryJSON(lastPlayerChar.RealmId, build);
if (compressed.Length == 0)
return BattlenetRpcErrorCode.UtilServerFailedToSerializeResponse;
var attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_RealmEntry";
attribute.Value = new Variant();
attribute.Value.BlobValue = ByteString.CopyFrom(compressed);
response.Attribute.Add(attribute);
attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_CharacterName";
attribute.Value = new Variant();
attribute.Value.StringValue = lastPlayerChar.CharacterName;
response.Attribute.Add(attribute);
attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_CharacterGUID";
attribute.Value = new Variant();
attribute.Value.BlobValue = ByteString.CopyFrom(BitConverter.GetBytes(lastPlayerChar.CharacterGUID));
response.Attribute.Add(attribute);
attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_LastPlayedTime";
attribute.Value = new Variant();
attribute.Value.IntValue = (int)lastPlayerChar.LastPlayedTime;
response.Attribute.Add(attribute);
}
return BattlenetRpcErrorCode.Ok;
}
return BattlenetRpcErrorCode.UtilServerUnknownRealm;
}
BattlenetRpcErrorCode GetRealmList(Dictionary<string, Variant> Params, ClientResponse response)
{
if (gameAccountInfo == null)
return BattlenetRpcErrorCode.UserServerBadWowAccount;
string subRegionId = "";
Variant subRegion = Params.LookupByKey("Command_RealmListRequest_v1_b9");
if (subRegion != null)
subRegionId = subRegion.StringValue;
var compressed = Global.RealmMgr.GetRealmList(build, subRegionId);
if (compressed.Length == 0)
return BattlenetRpcErrorCode.UtilServerFailedToSerializeResponse;
var attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_RealmList";
attribute.Value = new Variant();
attribute.Value.BlobValue = ByteString.CopyFrom(compressed);
response.Attribute.Add(attribute);
var realmCharacterCounts = new RealmCharacterCountList();
foreach (var characterCount in gameAccountInfo.CharacterCounts)
{
var countEntry = new RealmCharacterCountEntry();
countEntry.WowRealmAddress = (int)characterCount.Key;
countEntry.Count = characterCount.Value;
realmCharacterCounts.Counts.Add(countEntry);
}
compressed = Json.Deflate("JSONRealmCharacterCountList", realmCharacterCounts);
attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_CharacterCountList";
attribute.Value = new Variant();
attribute.Value.BlobValue = ByteString.CopyFrom(compressed);
response.Attribute.Add(attribute);
return BattlenetRpcErrorCode.Ok;
}
BattlenetRpcErrorCode JoinRealm(Dictionary<string, Variant> Params, ClientResponse response)
{
Variant realmAddress = Params.LookupByKey("Param_RealmAddress");
if (realmAddress != null)
return Global.RealmMgr.JoinRealm((uint)realmAddress.UintValue, build, GetRemoteIpEndPoint().Address, clientSecret, (Locale)Enum.Parse(typeof(Locale), locale), os, gameAccountInfo.Name, response);
return BattlenetRpcErrorCode.WowServicesInvalidJoinTicket;
}
}
}
+115 -553
View File
@@ -1,64 +1,56 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// 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 Bgs.Protocol;
using Bgs.Protocol.Challenge.V1;
using Framework.Constants;
using Framework.Database;
using Framework.IO;
using Framework.Networking;
using Framework.Rest;
using Framework.Serialization;
using Framework.Realm;
using Google.Protobuf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
namespace BNetServer.Networking
{
public class Session : SSLSocket
partial class Session : SSLSocket
{
AccountInfo accountInfo;
GameAccountInfo gameAccountInfo;
string locale;
string os;
uint build;
string ipCountry;
byte[] clientSecret;
bool authed;
uint requestToken;
AsyncCallbackProcessor<QueryCallback> queryProcessor;
Dictionary<uint, Action<CodedInputStream>> responseCallbacks;
public Session(Socket socket) : base(socket)
{
_accountInfo = new AccountInfo();
ClientRequestHandlers.Add("Command_RealmListTicketRequest_v1_b9", GetRealmListTicket);
ClientRequestHandlers.Add("Command_LastCharPlayedRequest_v1_b9", GetLastCharPlayed);
ClientRequestHandlers.Add("Command_RealmListRequest_v1_b9", GetRealmList);
ClientRequestHandlers.Add("Command_RealmJoinRequest_v1_b9", JoinRealm);
clientSecret = new byte[32];
queryProcessor = new AsyncCallbackProcessor<QueryCallback>();
responseCallbacks = new Dictionary<uint, Action<CodedInputStream>>();
}
public override void Start()
public override void Accept()
{
string ip_address = GetRemoteIpAddress().ToString();
Log.outInfo(LogFilter.Network, "{0} Accepted connection", GetClientInfo());
string ipAddress = GetRemoteIpEndPoint().ToString();
Log.outInfo(LogFilter.Network, $"{GetClientInfo()} Connection Accepted.");
// Verify that this IP is not in the ip_banned table
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.DEL_EXPIRED_IP_BANS));
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.DelExpiredIpBans));
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_IP_INFO);
stmt.AddValue(0, ip_address);
stmt.AddValue(1, BitConverter.ToUInt32(GetRemoteIpAddress().GetAddressBytes(), 0));
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SelIpInfo);
stmt.AddValue(0, ipAddress);
stmt.AddValue(1, BitConverter.ToUInt32(GetRemoteIpEndPoint().Address.GetAddressBytes(), 0));
_queryProcessor.AddCallback(DB.Login.AsyncQuery(stmt).WithCallback(CheckIpCallback));
}
void CheckIpCallback(SQLResult result)
queryProcessor.AddCallback(DB.Login.AsyncQuery(stmt).WithCallback(async result =>
{
if (!result.IsEmpty())
{
@@ -69,19 +61,20 @@ namespace BNetServer.Networking
banned = true;
if (!string.IsNullOrEmpty(result.Read<string>(1)))
_ipCountry = result.Read<string>(1);
ipCountry = result.Read<string>(1);
} while (result.NextRow());
if (banned)
{
Log.outDebug(LogFilter.Session, "{0} tries to log in using banned IP!", GetClientInfo());
Log.outDebug(LogFilter.Session, $"{GetClientInfo()} trying to login with banned ipaddress!");
CloseSocket();
return;
}
}
AsyncHandshake(Global.SessionMgr.GetCertificate());
await AsyncHandshake(Global.LoginServiceMgr.GetCertificate());
}));
}
public override bool Update()
@@ -89,557 +82,137 @@ namespace BNetServer.Networking
if (!base.Update())
return false;
_queryProcessor.ProcessReadyCallbacks();
queryProcessor.ProcessReadyCallbacks();
return true;
}
public override void ReadHandler(int transferredBytes)
public async override void ReadHandler(byte[] data, int receivedLength)
{
if (!IsOpen())
return;
var stream = new CodedInputStream(GetReceiveBuffer(), 0, transferredBytes);
var stream = new CodedInputStream(data);
while (!stream.IsAtEnd)
{
var header = new Header();
stream.ReadMessage(header);
if (header.ServiceId != 0xFE)
if (header.ServiceId != 0xFE && header.ServiceHash != 0)
{
Global.ServiceDispatcher.Dispatch(this, header.ServiceHash, header.Token, header.MethodId, stream);
var handler = Global.LoginServiceMgr.GetHandler(header.ServiceHash, header.MethodId);
if (handler != null)
handler.Invoke(this, header.Token, stream);
else
{
Log.outError(LogFilter.ServiceProtobuf, $"{GetClientInfo()} tried to call not implemented methodId: {header.MethodId} for servicehash: {header.ServiceHash}");
SendResponse(header.Token, BattlenetRpcErrorCode.RpcNotImplemented);
}
}
else
{
var handler = _responseCallbacks.LookupByKey(header.Token);
var handler = responseCallbacks.LookupByKey(header.Token);
if (handler != null)
{
handler(stream);
_responseCallbacks.Remove(header.Token);
responseCallbacks.Remove(header.Token);
}
}
}
AsyncRead();
await AsyncRead();
}
void AsyncWrite(ByteBuffer packet)
{
if (!IsOpen())
return;
AsyncWrite(packet.GetData());
}
public void SendResponse(uint token, IMessage response)
public async void SendResponse(uint token, IMessage response)
{
Header header = new Header();
header.Token = token;
header.ServiceId = 0xFE;
header.Size = (uint)response.CalculateSize();
var headerSizeBytes = BitConverter.GetBytes((ushort)header.CalculateSize());
Array.Reverse(headerSizeBytes);
ByteBuffer buffer = new ByteBuffer();
buffer.WriteBytes(GetHeaderSize(header), 2);
buffer.WriteBytes(header.ToByteArray());
buffer.WriteBytes(response.ToByteArray());
ByteBuffer packet = new ByteBuffer();
packet.WriteBytes(headerSizeBytes, 2);
packet.WriteBytes(header.ToByteArray());
packet.WriteBytes(response.ToByteArray());
AsyncWrite(packet.GetData());
await AsyncWrite(buffer.GetData());
}
public void SendResponse(uint token, BattlenetRpcErrorCode status)
public async void SendResponse(uint token, BattlenetRpcErrorCode status)
{
Header header = new Header();
header.Token = token;
header.Status = (uint)status;
header.ServiceId = 0xFE;
var headerSizeBytes = BitConverter.GetBytes((ushort)header.CalculateSize());
Array.Reverse(headerSizeBytes);
ByteBuffer buffer = new ByteBuffer();
buffer.WriteBytes(GetHeaderSize(header), 2);
buffer.WriteBytes(header.ToByteArray());
ByteBuffer packet = new ByteBuffer();
packet.WriteBytes(headerSizeBytes, 2);
packet.WriteBytes(header.ToByteArray());
AsyncWrite(packet);
await AsyncWrite(buffer.GetData());
}
public void SendRequest(uint serviceHash, uint methodId, IMessage request, Action<CodedInputStream> callback)
{
_responseCallbacks[_requestToken] = callback;
SendRequest(serviceHash, methodId, request);
}
public void SendRequest(uint serviceHash, uint methodId, IMessage request)
public async void SendRequest(uint serviceHash, uint methodId, IMessage request)
{
Header header = new Header();
header.ServiceId = 0;
header.ServiceHash = serviceHash;
header.MethodId = methodId;
header.Size = (uint)request.CalculateSize();
header.Token = _requestToken++;
header.Token = requestToken++;
ByteBuffer buffer = new ByteBuffer();
buffer.WriteBytes(GetHeaderSize(header), 2);
buffer.WriteBytes(header.ToByteArray());
buffer.WriteBytes(request.ToByteArray());
await AsyncWrite(buffer.GetData());
}
public byte[] GetHeaderSize(Header header)
{
var size = (ushort)header.CalculateSize();
byte[] bytes = new byte[2];
bytes[0] = (byte)((size >> 8) & 0xff);
bytes[1] = (byte)(size & 0xff);
var headerSizeBytes = BitConverter.GetBytes((ushort)header.CalculateSize());
Array.Reverse(headerSizeBytes);
ByteBuffer packet = new ByteBuffer();
packet.WriteBytes(headerSizeBytes, 2);
packet.WriteBytes(header.ToByteArray());
packet.WriteBytes(request.ToByteArray());
AsyncWrite(packet);
}
public BattlenetRpcErrorCode HandleLogon(Bgs.Protocol.Authentication.V1.LogonRequest logonRequest)
{
if (logonRequest.Program != "WoW")
{
Log.outDebug(LogFilter.Session, "Battlenet.LogonRequest: {0} attempted to log in with game other than WoW (using {1})!", GetClientInfo(), logonRequest.Program);
return BattlenetRpcErrorCode.BadProgram;
}
if (logonRequest.Platform != "Win" && logonRequest.Platform != "Wn64" && logonRequest.Platform != "Mc64")
{
Log.outDebug(LogFilter.Session, "Battlenet.LogonRequest: {0} attempted to log in from an unsupported platform (using {1})!", GetClientInfo(), logonRequest.Platform);
return BattlenetRpcErrorCode.BadPlatform;
}
if (logonRequest.Locale.ToEnum<LocaleConstant>() == LocaleConstant.enUS && logonRequest.Locale != "enUS")
{
Log.outDebug(LogFilter.Session, "Battlenet.LogonRequest: {0} attempted to log in with unsupported locale (using {1})!", GetClientInfo(), logonRequest.Locale);
return BattlenetRpcErrorCode.BadLocale;
}
_locale = logonRequest.Locale;
_os = logonRequest.Platform;
_build = (uint)logonRequest.ApplicationVersion;
var endpoint = Global.SessionMgr.GetAddressForClient(GetRemoteIpAddress());
ChallengeExternalRequest externalChallenge = new ChallengeExternalRequest();
externalChallenge.PayloadType = "web_auth_url";
externalChallenge.Payload = ByteString.CopyFromUtf8(string.Format("https://{0}:{1}/bnetserver/login/", endpoint.Address, endpoint.Port));
SendRequest((uint)OriginalHash.ChallengeListener, 3, externalChallenge);
return BattlenetRpcErrorCode.Ok;
}
public BattlenetRpcErrorCode HandleVerifyWebCredentials(Bgs.Protocol.Authentication.V1.VerifyWebCredentialsRequest verifyWebCredentialsRequest)
{
if (verifyWebCredentialsRequest.WebCredentials.IsEmpty)
return BattlenetRpcErrorCode.Denied;
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_ACCOUNT_INFO);
stmt.AddValue(0, verifyWebCredentialsRequest.WebCredentials.ToStringUtf8());
SQLResult result = DB.Login.Query(stmt);
if (result.IsEmpty())
return BattlenetRpcErrorCode.Denied;
_accountInfo = new AccountInfo();
_accountInfo.LoadResult(result);
if (_accountInfo.LoginTicketExpiry < Time.UnixTime)
return BattlenetRpcErrorCode.TimedOut;
stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_CHARACTER_COUNTS_BY_BNET_ID);
stmt.AddValue(0, _accountInfo.Id);
SQLResult characterCountsResult = DB.Login.Query(stmt);
if (!characterCountsResult.IsEmpty())
{
do
{
RealmHandle realmId = new RealmHandle(characterCountsResult.Read<byte>(3), characterCountsResult.Read<byte>(4), characterCountsResult.Read<uint>(2));
_accountInfo.GameAccounts[characterCountsResult.Read<uint>(0)].CharacterCounts[realmId.GetAddress()] = characterCountsResult.Read<byte>(1);
} while (characterCountsResult.NextRow());
}
stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_LAST_PLAYER_CHARACTERS);
stmt.AddValue(0, _accountInfo.Id);
SQLResult lastPlayerCharactersResult = DB.Login.Query(stmt);
if (!lastPlayerCharactersResult.IsEmpty())
{
do
{
RealmHandle realmId = new RealmHandle(lastPlayerCharactersResult.Read<byte>(1), lastPlayerCharactersResult.Read<byte>(2), lastPlayerCharactersResult.Read<uint>(3));
LastPlayedCharacterInfo lastPlayedCharacter = new LastPlayedCharacterInfo();
lastPlayedCharacter.RealmId = realmId;
lastPlayedCharacter.CharacterName = lastPlayerCharactersResult.Read<string>(4);
lastPlayedCharacter.CharacterGUID = lastPlayerCharactersResult.Read<ulong>(5);
lastPlayedCharacter.LastPlayedTime = lastPlayerCharactersResult.Read<uint>(6);
_accountInfo.GameAccounts[lastPlayerCharactersResult.Read<uint>(0)].LastPlayedCharacters[realmId.GetSubRegionAddress()] = lastPlayedCharacter;
} while (lastPlayerCharactersResult.NextRow());
}
string ip_address = GetRemoteIpAddress().ToString();
// If the IP is 'locked', check that the player comes indeed from the correct IP address
if (_accountInfo.IsLockedToIP)
{
Log.outDebug(LogFilter.Session, "Session.HandleVerifyWebCredentials: Account '{0}' is locked to IP - '{1}' is logging in from '{2}'",
_accountInfo.Login, _accountInfo.LastIP, ip_address);
if (_accountInfo.LastIP != ip_address)
return BattlenetRpcErrorCode.RiskAccountLocked;
}
else
{
Log.outDebug(LogFilter.Session, "Session.HandleVerifyWebCredentials: Account '{0}' is not locked to ip", _accountInfo.Login);
if (_accountInfo.LockCountry.IsEmpty() || _accountInfo.LockCountry == "00")
Log.outDebug(LogFilter.Session, "Session.HandleVerifyWebCredentials: Account '{0}' is not locked to country", _accountInfo.Login);
else if (!_accountInfo.LockCountry.IsEmpty() && !_ipCountry.IsEmpty())
{
Log.outDebug(LogFilter.Session, "Session.HandleVerifyWebCredentials: Account '{0}' is locked to country: '{1}' Player country is '{2}'",
_accountInfo.Login, _accountInfo.LockCountry, _ipCountry);
if (_ipCountry != _accountInfo.LockCountry)
return BattlenetRpcErrorCode.RiskAccountLocked;
}
}
// If the account is banned, reject the logon attempt
if (_accountInfo.IsBanned)
{
if (_accountInfo.IsPermanenetlyBanned)
{
Log.outDebug(LogFilter.Session, "{0} Session.HandleVerifyWebCredentials: Banned account {1} tried to login!", GetClientInfo(), _accountInfo.Login);
return BattlenetRpcErrorCode.GameAccountBanned;
}
else
{
Log.outDebug(LogFilter.Session, "{0} Session.HandleVerifyWebCredentials: Temporarily banned account {1} tried to login!", GetClientInfo(), _accountInfo.Login);
return BattlenetRpcErrorCode.GameAccountSuspended;
}
}
Bgs.Protocol.Authentication.V1.LogonResult logonResult = new Bgs.Protocol.Authentication.V1.LogonResult();
logonResult.ErrorCode = 0;
logonResult.AccountId = new EntityId();
logonResult.AccountId.Low = _accountInfo.Id;
logonResult.AccountId.High = 0x100000000000000;
foreach (var pair in _accountInfo.GameAccounts)
{
EntityId gameAccountId = new EntityId();
gameAccountId.Low = pair.Value.Id;
gameAccountId.High = 0x200000200576F57;
logonResult.GameAccountId.Add(gameAccountId);
}
if (!_ipCountry.IsEmpty())
logonResult.GeoipCountry = _ipCountry;
logonResult.SessionKey = ByteString.CopyFrom(new byte[64].GenerateRandomKey(64));
_authed = true;
SendRequest((uint)OriginalHash.AuthenticationListener, 5, logonResult);
return BattlenetRpcErrorCode.Ok;
}
public BattlenetRpcErrorCode HandleGetAccountState(Bgs.Protocol.Account.V1.GetAccountStateRequest request, Bgs.Protocol.Account.V1.GetAccountStateResponse response)
{
if (!_authed)
return BattlenetRpcErrorCode.Denied;
if (request.Options.FieldPrivacyInfo)
{
response.State = new Bgs.Protocol.Account.V1.AccountState();
response.State.PrivacyInfo = new Bgs.Protocol.Account.V1.PrivacyInfo();
response.State.PrivacyInfo.IsUsingRid = false;
response.State.PrivacyInfo.IsVisibleForViewFriends = false;
response.State.PrivacyInfo.IsHiddenFromFriendFinder = true;
response.Tags = new Bgs.Protocol.Account.V1.AccountFieldTags();
response.Tags.PrivacyInfoTag = 0xD7CA834D;
}
return BattlenetRpcErrorCode.Ok;
}
public BattlenetRpcErrorCode HandleGetGameAccountState(Bgs.Protocol.Account.V1.GetGameAccountStateRequest request, Bgs.Protocol.Account.V1.GetGameAccountStateResponse response)
{
if (!_authed)
return BattlenetRpcErrorCode.Denied;
if (request.Options.FieldGameLevelInfo)
{
var gameAccountInfo = _accountInfo.GameAccounts.LookupByKey(request.GameAccountId.Low);
if (gameAccountInfo != null)
{
response.State = new Bgs.Protocol.Account.V1.GameAccountState();
response.State.GameLevelInfo = new Bgs.Protocol.Account.V1.GameLevelInfo();
response.State.GameLevelInfo.Name = gameAccountInfo.DisplayName;
response.State.GameLevelInfo.Program = 5730135; // WoW
}
response.Tags = new Bgs.Protocol.Account.V1.GameAccountFieldTags();
response.Tags.GameLevelInfoTag = 0x5C46D483;
}
if (request.Options.FieldGameStatus)
{
if (response.State == null)
response.State = new Bgs.Protocol.Account.V1.GameAccountState();
response.State.GameStatus = new Bgs.Protocol.Account.V1.GameStatus();
var gameAccountInfo = _accountInfo.GameAccounts.LookupByKey(request.GameAccountId.Low);
if (gameAccountInfo != null)
{
response.State.GameStatus.IsSuspended = gameAccountInfo.IsBanned;
response.State.GameStatus.IsBanned = gameAccountInfo.IsPermanenetlyBanned;
response.State.GameStatus.SuspensionExpires = (gameAccountInfo.UnbanDate * 1000000);
}
response.State.GameStatus.Program = 5730135; // WoW
response.Tags.GameStatusTag = 0x98B75F99;
}
return BattlenetRpcErrorCode.Ok;
}
public BattlenetRpcErrorCode HandleProcessClientRequest(Bgs.Protocol.GameUtilities.V1.ClientRequest request, Bgs.Protocol.GameUtilities.V1.ClientResponse response)
{
if (!_authed)
return BattlenetRpcErrorCode.Denied;
Bgs.Protocol.Attribute command = null;
Dictionary<string, Variant> Params = new Dictionary<string, Variant>();
for (int i = 0; i < request.Attribute.Count; ++i)
{
Bgs.Protocol.Attribute attr = request.Attribute[i];
Params[attr.Name] = attr.Value;
if (attr.Name.Contains("Command_"))
command = attr;
}
if (command == null)
{
Log.outError(LogFilter.SessionRpc, "{0} sent ClientRequest with no command.", GetClientInfo());
return BattlenetRpcErrorCode.RpcMalformedRequest;
}
var handler = ClientRequestHandlers.LookupByKey(command.Name);
if (handler == null)
{
Log.outError(LogFilter.SessionRpc, "{0} sent ClientRequest with unknown command {1}.", GetClientInfo(), command.Name);
return BattlenetRpcErrorCode.RpcNotImplemented;
}
return handler(Params, response);
}
Variant GetParam(Dictionary<string, Variant> Params, string paramName)
{
return Params.LookupByKey(paramName);
}
delegate BattlenetRpcErrorCode ClientRequestHandler(Dictionary<string, Variant> Params, Bgs.Protocol.GameUtilities.V1.ClientResponse response);
BattlenetRpcErrorCode GetRealmListTicket(Dictionary<string, Variant> Params, Bgs.Protocol.GameUtilities.V1.ClientResponse response)
{
Variant identity = GetParam(Params, "Param_Identity");
if (identity != null)
{
var realmListTicketIdentity = Json.CreateObject<RealmListTicketIdentity>(identity.BlobValue.ToStringUtf8(), true);
var gameAccountInfo = _accountInfo.GameAccounts.LookupByKey(realmListTicketIdentity.GameAccountId);
if (gameAccountInfo != null)
_gameAccountInfo = gameAccountInfo;
}
if (_gameAccountInfo == null)
return BattlenetRpcErrorCode.UtilServerInvalidIdentityArgs;
if (_gameAccountInfo.IsPermanenetlyBanned)
return BattlenetRpcErrorCode.GameAccountBanned;
else if (_gameAccountInfo.IsBanned)
return BattlenetRpcErrorCode.GameAccountSuspended;
bool clientInfoOk = false;
Variant clientInfo = GetParam(Params, "Param_ClientInfo");
if (clientInfo != null)
{
var realmListTicketClientInformation = Json.CreateObject<RealmListTicketClientInformation>(clientInfo.BlobValue.ToStringUtf8(), true);
clientInfoOk = true;
int i = 0;
foreach (var b in realmListTicketClientInformation.Info.Secret.Select(Convert.ToByte))
_clientSecret[i++] = b;
}
if (!clientInfoOk)
return BattlenetRpcErrorCode.WowServicesDeniedRealmListTicket;
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_LAST_LOGIN_INFO);
stmt.AddValue(0, GetRemoteIpAddress().ToString());
stmt.AddValue(1, Enum.Parse(typeof(LocaleConstant), _locale));
stmt.AddValue(2, _os);
stmt.AddValue(3, _accountInfo.Id);
DB.Login.Execute(stmt);
var attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_RealmListTicket";
attribute.Value = new Variant();
attribute.Value.BlobValue = ByteString.CopyFrom("AuthRealmListTicket", System.Text.Encoding.UTF8);
response.Attribute.Add(attribute);
return BattlenetRpcErrorCode.Ok;
}
BattlenetRpcErrorCode GetLastCharPlayed(Dictionary<string, Variant> Params, Bgs.Protocol.GameUtilities.V1.ClientResponse response)
{
Variant subRegion = GetParam(Params, "Command_LastCharPlayedRequest_v1_b9");
if (subRegion != null)
{
var lastPlayerChar = _gameAccountInfo.LastPlayedCharacters.LookupByKey(subRegion.StringValue);
if (lastPlayerChar != null)
{
var compressed = Global.RealmMgr.GetRealmEntryJSON(lastPlayerChar.RealmId, _build);
if (compressed.Length == 0)
return BattlenetRpcErrorCode.UtilServerFailedToSerializeResponse;
var attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_RealmEntry";
attribute.Value = new Variant();
attribute.Value.BlobValue = ByteString.CopyFrom(compressed);
response.Attribute.Add(attribute);
attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_CharacterName";
attribute.Value = new Variant();
attribute.Value.StringValue = lastPlayerChar.CharacterName;
response.Attribute.Add(attribute);
attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_CharacterGUID";
attribute.Value = new Variant();
attribute.Value.BlobValue = ByteString.CopyFrom(BitConverter.GetBytes(lastPlayerChar.CharacterGUID));
response.Attribute.Add(attribute);
attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_LastPlayedTime";
attribute.Value = new Variant();
attribute.Value.IntValue = (int)lastPlayerChar.LastPlayedTime;
response.Attribute.Add(attribute);
}
return BattlenetRpcErrorCode.Ok;
}
return BattlenetRpcErrorCode.UtilServerUnknownRealm;
}
BattlenetRpcErrorCode GetRealmList(Dictionary<string, Variant> Params, Bgs.Protocol.GameUtilities.V1.ClientResponse response)
{
if (_gameAccountInfo == null)
return BattlenetRpcErrorCode.UserServerBadWowAccount;
string subRegionId = "";
Variant subRegion = GetParam(Params, "Command_RealmListRequest_v1_b9");
if (subRegion != null)
subRegionId = subRegion.StringValue;
var compressed = Global.RealmMgr.GetRealmList(_build, subRegionId);
if (compressed.Length == 0)
return BattlenetRpcErrorCode.UtilServerFailedToSerializeResponse;
var attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_RealmList";
attribute.Value = new Variant();
attribute.Value.BlobValue = ByteString.CopyFrom(compressed);
response.Attribute.Add(attribute);
var realmCharacterCounts = new RealmCharacterCountList();
foreach (var characterCount in _gameAccountInfo.CharacterCounts)
{
var countEntry = new RealmCharacterCountEntry();
countEntry.WowRealmAddress = (int)characterCount.Key;
countEntry.Count = characterCount.Value;
realmCharacterCounts.Counts.Add(countEntry);
}
compressed = Json.Deflate("JSONRealmCharacterCountList", realmCharacterCounts);
attribute = new Bgs.Protocol.Attribute();
attribute.Name = "Param_CharacterCountList";
attribute.Value = new Variant();
attribute.Value.BlobValue = ByteString.CopyFrom(compressed);
response.Attribute.Add(attribute);
return BattlenetRpcErrorCode.Ok;
}
BattlenetRpcErrorCode JoinRealm(Dictionary<string, Variant> Params, Bgs.Protocol.GameUtilities.V1.ClientResponse response)
{
Variant realmAddress = GetParam(Params, "Param_RealmAddress");
if (realmAddress != null)
return Global.RealmMgr.JoinRealm((uint)realmAddress.UintValue, _build, GetRemoteIpAddress(), _clientSecret, (LocaleConstant)Enum.Parse(typeof(LocaleConstant), _locale), _os, _gameAccountInfo.Name, response);
return BattlenetRpcErrorCode.WowServicesInvalidJoinTicket;
}
public BattlenetRpcErrorCode HandleGetAllValuesForAttribute(Bgs.Protocol.GameUtilities.V1.GetAllValuesForAttributeRequest request, Bgs.Protocol.GameUtilities.V1.GetAllValuesForAttributeResponse response)
{
if (!_authed)
return BattlenetRpcErrorCode.Denied;
if (request.AttributeKey == "Command_RealmListRequest_v1_b9")
{
Global.RealmMgr.WriteSubRegions(response);
return BattlenetRpcErrorCode.Ok;
}
return BattlenetRpcErrorCode.RpcNotImplemented;
return bytes;
}
public string GetClientInfo()
{
string stream = '[' + GetRemoteIpAddress().ToString() + ':' + GetRemotePort();
if (_accountInfo != null && !string.IsNullOrEmpty(_accountInfo.Login))
stream += ", Account: " + _accountInfo.Login;
string stream = '[' + GetRemoteIpEndPoint().ToString();
if (accountInfo != null && !accountInfo.Login.IsEmpty())
stream += ", Account: " + accountInfo.Login;
if (_gameAccountInfo != null)
stream += ", Game account: " + _gameAccountInfo.Name;
if (gameAccountInfo != null)
stream += ", Game account: " + gameAccountInfo.Name;
stream += ']';
return stream;
}
public uint GetAccountId() { return _accountInfo.Id; }
public uint GetGameAccountId() { return _gameAccountInfo.Id; }
Dictionary<string, ClientRequestHandler> ClientRequestHandlers = new Dictionary<string, ClientRequestHandler>();
AccountInfo _accountInfo;
GameAccountInfo _gameAccountInfo; // Points at selected game account (inside _gameAccounts)
string _locale;
string _os;
uint _build;
string _ipCountry;
Array<byte> _clientSecret = new Array<byte>(32);
bool _authed;
AsyncCallbackProcessor<QueryCallback> _queryProcessor = new AsyncCallbackProcessor<QueryCallback>();
Dictionary<uint, Action<CodedInputStream>> _responseCallbacks = new Dictionary<uint, Action<CodedInputStream>>();
uint _requestToken;
}
public class AccountInfo
{
public void LoadResult(SQLResult result)
public uint Id;
public string Login;
public bool IsLockedToIP;
public string LockCountry;
public string LastIP;
public uint LoginTicketExpiry;
public bool IsBanned;
public bool IsPermanenetlyBanned;
public string PasswordVerifier;
public string Salt;
public Dictionary<uint, GameAccountInfo> GameAccounts;
public AccountInfo(SQLResult result)
{
Id = result.Read<uint>(0);
Login = result.Read<string>(1);
@@ -652,34 +225,31 @@ namespace BNetServer.Networking
PasswordVerifier = result.Read<string>(9);
Salt = result.Read<string>(10);
GameAccounts = new Dictionary<uint, GameAccountInfo>();
const int GameAccountFieldsOffset = 8;
do
{
var account = new GameAccountInfo();
account.LoadResult(result.GetFields(), GameAccountFieldsOffset);
var account = new GameAccountInfo(result.GetFields(), GameAccountFieldsOffset);
GameAccounts[result.Read<uint>(GameAccountFieldsOffset)] = account;
} while (result.NextRow());
}
public uint Id;
public string Login;
public bool IsLockedToIP;
public string LockCountry;
public string LastIP;
public uint LoginTicketExpiry;
public bool IsBanned;
public bool IsPermanenetlyBanned;
public string PasswordVerifier;
public string Salt;
public Dictionary<uint, GameAccountInfo> GameAccounts = new Dictionary<uint, GameAccountInfo>();
}
public class GameAccountInfo
{
public void LoadResult(SQLFields fields, int startColumn)
public uint Id;
public string Name;
public string DisplayName;
public uint UnbanDate;
public bool IsBanned;
public bool IsPermanenetlyBanned;
public AccountTypes SecurityLevel;
public Dictionary<uint, byte> CharacterCounts;
public Dictionary<string, LastPlayedCharacterInfo> LastPlayedCharacters;
public GameAccountInfo(SQLFields fields, int startColumn)
{
Id = fields.Read<uint>(startColumn + 0);
Name = fields.Read<string>(startColumn + 1);
@@ -693,23 +263,15 @@ namespace BNetServer.Networking
DisplayName = "WoW" + Name.Substring(hashPos + 1);
else
DisplayName = Name;
CharacterCounts = new Dictionary<uint, byte>();
LastPlayedCharacters = new Dictionary<string, LastPlayedCharacterInfo>();
}
public uint Id;
public string Name;
public string DisplayName;
public uint UnbanDate;
public bool IsBanned;
public bool IsPermanenetlyBanned;
public AccountTypes SecurityLevel;
public Dictionary<uint /*realmAddress*/, byte> CharacterCounts = new Dictionary<uint, byte>();
public Dictionary<string /*subRegion*/, LastPlayedCharacterInfo> LastPlayedCharacters = new Dictionary<string, LastPlayedCharacterInfo>();
}
public class LastPlayedCharacterInfo
{
public RealmHandle RealmId;
public RealmId RealmId;
public string CharacterName;
public ulong CharacterGUID;
public uint LastPlayedTime;
+21 -38
View File
@@ -1,28 +1,20 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// 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 BNetServer.Networking;
using Framework.Configuration;
using Framework.Database;
using Framework.Networking;
using Framework.Web.API;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Timers;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace BNetServer
{
@@ -34,18 +26,10 @@ namespace BNetServer
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Console.CancelKeyPress += (o, e) =>
{
Global.RealmMgr.Close();
Log.outInfo(LogFilter.Server, "Halting process...");
Environment.Exit(-1);
};
if (!ConfigMgr.Load(Process.GetCurrentProcess().ProcessName + ".conf"))
if (!ConfigMgr.Load("BNetServer.conf"))
ExitNow();
// Initialize the database connection
// Initialize the database
if (!StartDB())
ExitNow();
@@ -55,7 +39,7 @@ namespace BNetServer
int restPort = ConfigMgr.GetDefaultValue("LoginREST.Port", 8081);
if (restPort < 0 || restPort > 0xFFFF)
{
Log.outError(LogFilter.Network, "Specified login service port ({0}) out of allowed range (1-65535), defaulting to 8081", restPort);
Log.outError(LogFilter.Network, "Specified login service port ({restPort}) out of allowed range (1-65535), defaulting to 8081");
restPort = 8081;
}
@@ -67,14 +51,14 @@ namespace BNetServer
// Get the list of realms for the server
Global.RealmMgr.Initialize(ConfigMgr.GetDefaultValue("RealmsStateUpdateDelay", 10));
Global.SessionMgr.Initialize();
Global.LoginServiceMgr.Initialize();
var sessionSocketServer = new SocketManager<Session>();
// Start the listening port (acceptor) for auth connections
int bnPort = ConfigMgr.GetDefaultValue("BattlenetPort", 1119);
if (bnPort < 0 || bnPort > 0xFFFF)
{
Log.outError(LogFilter.Server, "Specified battle.net port ({0}) out of allowed range (1-65535)", bnPort);
Log.outError(LogFilter.Server, $"Specified battle.net port ({bnPort}) out of allowed range (1-65535)");
ExitNow();
}
@@ -84,11 +68,9 @@ namespace BNetServer
ExitNow();
}
Log.outInfo(LogFilter.Server, $"Bnetserver started successfully, listening on {bindIp}:{bnPort}");
uint _banExpiryCheckInterval = ConfigMgr.GetDefaultValue("BanExpiryCheckInterval", 60u);
_banExpiryCheckTimer = new Timer(_banExpiryCheckInterval);
_banExpiryCheckTimer.Elapsed += _banExpiryCheckTimer_Elapsed;
_banExpiryCheckTimer.Elapsed += BanExpiryCheckTimer_Elapsed;
_banExpiryCheckTimer.Start();
}
@@ -106,15 +88,16 @@ namespace BNetServer
static void ExitNow()
{
Log.outInfo(LogFilter.Server, "Halting process...");
Console.WriteLine("Halting process...");
System.Threading.Thread.Sleep(10000);
Environment.Exit(-1);
}
static void _banExpiryCheckTimer_Elapsed(object sender, ElapsedEventArgs e)
static void BanExpiryCheckTimer_Elapsed(object sender, ElapsedEventArgs e)
{
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.DEL_EXPIRED_IP_BANS));
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.UPD_EXPIRED_ACCOUNT_BANS));
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.DEL_BNET_EXPIRED_ACCOUNT_BANNED));
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.DelExpiredIpBans));
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.UpdExpiredAccountBans));
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.DelBnetExpiredAccountBanned));
}
static Timer _banExpiryCheckTimer;
@@ -1,360 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Bgs.Protocol;
using Bgs.Protocol.Account.V1;
using BNetServer.Services;
using Framework.Constants;
using Google.Protobuf;
namespace BNetServer.Networking
{
class AccountService : ServiceBase
{
public AccountService(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 13:
{
ResolveAccountRequest request = new ResolveAccountRequest();
request.MergeFrom(stream);
ResolveAccountResponse response = new ResolveAccountResponse();
BattlenetRpcErrorCode status = HandleResolveAccount(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetAccount(GetAccountRequest: {1}) returned GetAccountResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 15:
{
IsIgrAddressRequest request = new IsIgrAddressRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleIsIgrAddress(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.IsIgrAddress(IsIgrAddressRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 25:
{
SubscriptionUpdateRequest request = new SubscriptionUpdateRequest();
request.MergeFrom(stream);
SubscriptionUpdateResponse response = new SubscriptionUpdateResponse();
BattlenetRpcErrorCode status = HandleSubscribe(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.Subscribe(SubscriptionUpdateRequest: {1}) returned SubscriptionUpdateResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 26:
{
SubscriptionUpdateRequest request = new SubscriptionUpdateRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleUnsubscribe(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.Unsubscribe(SubscriptionUpdateRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 30:
{
GetAccountStateRequest request = new GetAccountStateRequest();
request.MergeFrom(stream);
GetAccountStateResponse response = new GetAccountStateResponse();
BattlenetRpcErrorCode status = HandleGetAccountState(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetAccountState(GetAccountStateRequest: {1}) returned GetAccountStateResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 31:
{
GetGameAccountStateRequest request = new GetGameAccountStateRequest();
request.MergeFrom(stream);
GetGameAccountStateResponse response = new GetGameAccountStateResponse();
BattlenetRpcErrorCode status = HandleGetGameAccountState(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetGameAccountState(GetGameAccountStateRequest: {1}) returned GetGameAccountStateResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 32:
{
GetLicensesRequest request = new GetLicensesRequest();
request.MergeFrom(stream);
GetLicensesResponse response = new GetLicensesResponse();
BattlenetRpcErrorCode status = HandleGetLicenses(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetLicenses(GetLicensesRequest: {1}) returned GetLicensesResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 33:
{
GetGameTimeRemainingInfoRequest request = new GetGameTimeRemainingInfoRequest();
request.MergeFrom(stream);
GetGameTimeRemainingInfoResponse response = new GetGameTimeRemainingInfoResponse();
BattlenetRpcErrorCode status = HandleGetGameTimeRemainingInfo(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetGameTimeRemainingInfo(GetGameTimeRemainingInfoRequest: {1}) returned GetGameTimeRemainingInfoResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 34:
{
GetGameSessionInfoRequest request = new GetGameSessionInfoRequest();
request.MergeFrom(stream);
GetGameSessionInfoResponse response = new GetGameSessionInfoResponse();
BattlenetRpcErrorCode status = HandleGetGameSessionInfo(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetGameSessionInfo(GetGameSessionInfoRequest: {1}) returned GetGameSessionInfoResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 35:
{
GetCAISInfoRequest request = new GetCAISInfoRequest();
request.MergeFrom(stream);
GetCAISInfoResponse response = new GetCAISInfoResponse();
BattlenetRpcErrorCode status = HandleGetCAISInfo(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetCAISInfo(GetCAISInfoRequest: {1}) returned GetCAISInfoResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 37:
{
GetAuthorizedDataRequest request = new GetAuthorizedDataRequest();
request.MergeFrom(stream);
GetAuthorizedDataResponse response = new GetAuthorizedDataResponse();
BattlenetRpcErrorCode status = HandleGetAuthorizedData(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetAuthorizedData(GetAuthorizedDataRequest: {1}) returned GetAuthorizedDataResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleResolveAccount(ResolveAccountRequest request, ResolveAccountResponse response)
{
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.ResolveAccount({1})", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleIsIgrAddress(IsIgrAddressRequest request, NoData response)
{
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.IsIgrAddress({1})", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleSubscribe(SubscriptionUpdateRequest request, SubscriptionUpdateResponse response)
{
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.Subscribe({1})", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleUnsubscribe(SubscriptionUpdateRequest request, NoData response)
{
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.Unsubscribe({1})", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleGetAccountState(GetAccountStateRequest request, GetAccountStateResponse response)
{
return _session.HandleGetAccountState(request, response);
}
BattlenetRpcErrorCode HandleGetGameAccountState(GetGameAccountStateRequest request, GetGameAccountStateResponse response)
{
return _session.HandleGetGameAccountState(request, response);
}
BattlenetRpcErrorCode HandleGetLicenses(GetLicensesRequest request, GetLicensesResponse response)
{
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetLicenses({1})", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleGetGameTimeRemainingInfo(GetGameTimeRemainingInfoRequest request, GetGameTimeRemainingInfoResponse response)
{
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetGameTimeRemainingInfo({1})", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleGetGameSessionInfo(GetGameSessionInfoRequest request, GetGameSessionInfoResponse response)
{
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetGameSessionInfo({1})", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleGetCAISInfo(GetCAISInfoRequest request, GetCAISInfoResponse response)
{
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetCAISInfo({1})", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleGetAuthorizedData(GetAuthorizedDataRequest request, GetAuthorizedDataResponse response)
{
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetAuthorizedData({1})", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleGameAccountFlagUpdate(GameAccountFlagUpdateRequest request)
{
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GameAccountFlagUpdate({1})", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
}
class AccountListener : ServiceBase
{
public AccountListener(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 1:
{
AccountStateNotification request = new AccountStateNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnAccountStateUpdated(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountListener.OnAccountStateUpdated(AccountStateNotification: {1} status: {2}.", GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 2:
{
GameAccountStateNotification request = new GameAccountStateNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnGameAccountStateUpdated(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountListener.OnGameAccountStateUpdated(GameAccountStateNotification: {1} status: {2}.", GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 3:
{
GameAccountNotification request = new GameAccountNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnGameAccountsUpdated(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountListener.OnGameAccountsUpdated(GameAccountNotification: {1} status: {2}.", GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 4:
{
GameAccountSessionNotification request = new GameAccountSessionNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnGameSessionUpdated(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountListener.OnGameSessionUpdated(GameAccountSessionNotification: {1} status: {2}.", GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleOnAccountStateUpdated(AccountStateNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountListener.OnAccountStateUpdated: {1}", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnGameAccountStateUpdated(GameAccountStateNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountListener.OnGameAccountStateUpdated: {1}", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnGameAccountsUpdated(GameAccountNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountListener.OnGameAccountsUpdated: {1}", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnGameSessionUpdated(GameAccountSessionNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountListener.OnGameSessionUpdated: {1}", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
}
}
@@ -1,442 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Bgs.Protocol;
using Bgs.Protocol.Authentication.V1;
using BNetServer.Services;
using Framework.Constants;
using Google.Protobuf;
namespace BNetServer.Networking
{
class AuthenticationService : ServiceBase
{
public AuthenticationService(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 1:
{
LogonRequest request = new LogonRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleLogon(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.Logon(bgs.protocol.authentication.v1.LogonRequest: {1}) returned bgs.protocol.NoData: {2} status {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 2:
{
ModuleNotification request = new ModuleNotification();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleModuleNotify(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.ModuleNotify(bgs.protocol.authentication.v1.ModuleNotification: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 3:
{
ModuleMessageRequest request = new ModuleMessageRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleModuleMessage(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.ModuleMessage(bgs.protocol.authentication.v1.ModuleMessageRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 4:
{
EntityId request = new EntityId();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleSelectGameAccount_DEPRECATED(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.SelectGameAccount_DEPRECATED(bgs.protocol.EntityId: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 5:
{
GenerateSSOTokenRequest request = new GenerateSSOTokenRequest();
request.MergeFrom(stream);
GenerateSSOTokenResponse response = new GenerateSSOTokenResponse();
BattlenetRpcErrorCode status = HandleGenerateSSOToken(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.GenerateSSOToken(bgs.protocol.authentication.v1.GenerateSSOTokenRequest: {1}) returned bgs.protocol.authentication.v1.GenerateSSOTokenResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 6:
{
SelectGameAccountRequest request = new SelectGameAccountRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleSelectGameAccount(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.SelectGameAccount(bgs.protocol.authentication.v1.SelectGameAccountRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 7:
{
VerifyWebCredentialsRequest request = new VerifyWebCredentialsRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleVerifyWebCredentials(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.VerifyWebCredentials(bgs.protocol.authentication.v1.VerifyWebCredentialsRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 8:
{
GenerateWebCredentialsRequest request = new GenerateWebCredentialsRequest();
request.MergeFrom(stream);
GenerateWebCredentialsResponse response = new GenerateWebCredentialsResponse();
BattlenetRpcErrorCode status = HandleGenerateWebCredentials(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.GenerateWebCredentials(bgs.protocol.authentication.v1.GenerateWebCredentialsRequest: {1}) returned bgs.protocol.authentication.v1.GenerateWebCredentialsResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleLogon(LogonRequest request, NoData response)
{
return _session.HandleLogon(request);
}
BattlenetRpcErrorCode HandleModuleNotify(ModuleNotification request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationService.ModuleNotify: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleModuleMessage(ModuleMessageRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationService.ModuleMessage: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleSelectGameAccount_DEPRECATED(EntityId request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationService.SelectGameAccount_DEPRECATED: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleGenerateSSOToken(GenerateSSOTokenRequest request, GenerateSSOTokenResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationService.GenerateSSOToken: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleSelectGameAccount(SelectGameAccountRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationService.SelectGameAccount: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleVerifyWebCredentials(VerifyWebCredentialsRequest request, NoData response)
{
return _session.HandleVerifyWebCredentials(request);
}
BattlenetRpcErrorCode HandleGenerateWebCredentials(GenerateWebCredentialsRequest request, GenerateWebCredentialsResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationService.GenerateWebCredentials: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
}
class AuthenticationListener : ServiceBase
{
public AuthenticationListener(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 1:
{
ModuleLoadRequest request = new ModuleLoadRequest();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnModuleLoad(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnModuleLoad(bgs.protocol.authentication.v1.ModuleLoadRequest: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 2:
{
ModuleMessageRequest request = new ModuleMessageRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleOnModuleMessage(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnModuleMessage(bgs.protocol.authentication.v1.ModuleMessageRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 4:
{
ServerStateChangeRequest request = new ServerStateChangeRequest();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnServerStateChange(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnServerStateChange(bgs.protocol.authentication.v1.ServerStateChangeRequest: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 5:
{
LogonResult request = new LogonResult();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnLogonComplete(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnLogonComplete(bgs.protocol.authentication.v1.LogonResult: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 6:
{
MemModuleLoadRequest request = new MemModuleLoadRequest();
request.MergeFrom(stream);
MemModuleLoadResponse response = new MemModuleLoadResponse();
BattlenetRpcErrorCode status = HandleOnMemModuleLoad(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnMemModuleLoad(bgs.protocol.authentication.v1.MemModuleLoadRequest: {1}) returned bgs.protocol.authentication.v1.MemModuleLoadResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 10:
{
LogonUpdateRequest request = new LogonUpdateRequest();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnLogonUpdate(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnLogonUpdate(bgs.protocol.authentication.v1.LogonUpdateRequest: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 11:
{
VersionInfoNotification request = new VersionInfoNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnVersionInfoUpdated(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnVersionInfoUpdated(bgs.protocol.authentication.v1.VersionInfoNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 12:
{
LogonQueueUpdateRequest request = new LogonQueueUpdateRequest();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnLogonQueueUpdate(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnLogonQueueUpdate(bgs.protocol.authentication.v1.LogonQueueUpdateRequest: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 13:
{
NoData request = new NoData();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnLogonQueueEnd(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnLogonQueueEnd(bgs.protocol.NoData: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 14:
{
GameAccountSelectedRequest request = new GameAccountSelectedRequest();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnGameAccountSelected(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnGameAccountSelected(bgs.protocol.authentication.v1.GameAccountSelectedRequest: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleOnModuleLoad(ModuleLoadRequest request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnModuleLoad: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnModuleMessage(ModuleMessageRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnModuleMessage: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnServerStateChange(ServerStateChangeRequest request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnServerStateChange: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnLogonComplete(LogonResult request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnLogonComplete: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnMemModuleLoad(MemModuleLoadRequest request, MemModuleLoadResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnMemModuleLoad: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnLogonUpdate(LogonUpdateRequest request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnLogonUpdate: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnVersionInfoUpdated(VersionInfoNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnVersionInfoUpdated: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnLogonQueueUpdate(LogonQueueUpdateRequest request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnLogonQueueUpdate: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnLogonQueueEnd(NoData request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnLogonQueueEnd: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnGameAccountSelected(GameAccountSelectedRequest request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnGameAccountSelected: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
}
}
@@ -1,81 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Bgs.Protocol;
using Bgs.Protocol.Challenge.V1;
using BNetServer.Services;
using Framework.Constants;
using Google.Protobuf;
namespace BNetServer.Networking
{
class ChallengeListener : ServiceBase
{
public ChallengeListener(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 3:
{
ChallengeExternalRequest request = new ChallengeExternalRequest();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnExternalChallenge(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeListener.OnExternalChallenge(bgs.protocol.challenge.v1.ChallengeExternalRequest: {1} status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 4:
{
ChallengeExternalResult request = new ChallengeExternalResult();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnExternalChallengeResult(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeListener.OnExternalChallengeResult(bgs.protocol.challenge.v1.ChallengeExternalResult: {1} status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleOnExternalChallenge(ChallengeExternalRequest request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChallengeListener.OnExternalChallenge: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnExternalChallengeResult(ChallengeExternalResult request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChallengeListener.OnExternalChallengeResult: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
}
}
@@ -1,187 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Bgs.Protocol;
using Bgs.Protocol.Connection.V1;
using BNetServer.Services;
using Framework.Constants;
using Google.Protobuf;
using System.Diagnostics;
namespace BNetServer.Networking
{
class ConnectionService : ServiceBase
{
public ConnectionService(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 1:
{
ConnectRequest request = ConnectRequest.Parser.ParseFrom(stream);
ConnectResponse response = new ConnectResponse();
BattlenetRpcErrorCode status = HandleConnect(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Connect(bgs.protocol.connection.v1.ConnectRequest: {1}) returned bgs.protocol.connection.v1.ConnectResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 2:
{
BindRequest request = new BindRequest();
request.MergeFrom(stream);
BindResponse response = new BindResponse();
BattlenetRpcErrorCode status = HandleBind(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Bind(bgs.protocol.connection.v1.BindRequest: {1}) returned bgs.protocol.connection.v1.BindResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 3:
{
EchoRequest request = new EchoRequest();
request.MergeFrom(stream);
EchoResponse response = new EchoResponse();
BattlenetRpcErrorCode status = HandleEcho(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Echo(bgs.protocol.connection.v1.EchoRequest: {1}) returned bgs.protocol.connection.v1.EchoResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 4:
{
DisconnectNotification request = DisconnectNotification.Parser.ParseFrom(stream);
BattlenetRpcErrorCode status = HandleForceDisconnect(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.ForceDisconnect(bgs.protocol.connection.v1.DisconnectNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 5:
{
NoData request = NoData.Parser.ParseFrom(stream);
BattlenetRpcErrorCode status = HandleKeepAlive(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.KeepAlive(bgs.protocol.NoData: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 6:
{
EncryptRequest request = EncryptRequest.Parser.ParseFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleEncrypt(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Encrypt(bgs.protocol.connection.v1.EncryptRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 7:
{
DisconnectRequest request = DisconnectRequest.Parser.ParseFrom(stream);
BattlenetRpcErrorCode status = HandleRequestDisconnect(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.RequestDisconnect(bgs.protocol.connection.v1.DisconnectRequest: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleConnect(ConnectRequest request, ConnectResponse response)
{
if (request.ClientId != null)
response.ClientId.MergeFrom(request.ClientId);
response.ServerId = new ProcessId();
response.ServerId.Label = (uint)Process.GetCurrentProcess().Id;
response.ServerId.Epoch = (uint)Time.UnixTime;
response.ServerTime = (ulong)Time.UnixTimeMilliseconds;
response.UseBindlessRpc = request.UseBindlessRpc;
return BattlenetRpcErrorCode.Ok;
}
BattlenetRpcErrorCode HandleBind(BindRequest request, BindResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ConnectionService.Bind: {1}", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleEcho(EchoRequest request, EchoResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ConnectionService.Echo: {1}", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleForceDisconnect(DisconnectNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ConnectionService.ForceDisconnect: {1}", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleKeepAlive(NoData request)
{
return BattlenetRpcErrorCode.Ok;
}
BattlenetRpcErrorCode HandleEncrypt(EncryptRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ConnectionService.Encrypt: {1}", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleRequestDisconnect(DisconnectRequest request)
{
var disconnectNotification = new DisconnectNotification();
disconnectNotification.ErrorCode = request.ErrorCode;
SendRequest(4, disconnectNotification);
_session.CloseSocket();
return BattlenetRpcErrorCode.Ok;
}
}
}
-432
View File
@@ -1,432 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Bgs.Protocol;
using Bgs.Protocol.Friends.V1;
using BNetServer.Services;
using Framework.Constants;
using Google.Protobuf;
namespace BNetServer.Networking
{
class FriendsService : ServiceBase
{
public FriendsService(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 1:
{
SubscribeRequest request = new SubscribeRequest();
request.MergeFrom(stream);
SubscribeResponse response = new SubscribeResponse();
BattlenetRpcErrorCode status = HandleSubscribe(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.Subscribe(bgs.protocol.friends.v1.SubscribeRequest: {1}) returned bgs.protocol.friends.v1.SubscribeResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 2:
{
SendInvitationRequest request = new SendInvitationRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleSendInvitation(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.SendInvitation(bgs.protocol.SendInvitationRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 3:
{
AcceptInvitationRequest request = new AcceptInvitationRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleAcceptInvitation(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.AcceptInvitation(bgs.protocol.GenericInvitationRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 4:
{
RevokeInvitationRequest request = new RevokeInvitationRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleRevokeInvitation(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.RevokeInvitation(bgs.protocol.GenericInvitationRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 5:
{
DeclineInvitationRequest request = new DeclineInvitationRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleDeclineInvitation(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.DeclineInvitation(bgs.protocol.GenericInvitationRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 6:
{
IgnoreInvitationRequest request = new IgnoreInvitationRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleIgnoreInvitation(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.IgnoreInvitation(bgs.protocol.GenericInvitationRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 8:
{
RemoveFriendRequest request = new RemoveFriendRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleRemoveFriend(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.RemoveFriend(bgs.protocol.friends.v1.GenericFriendRequest: {1}) returned bgs.protocol.friends.v1.GenericFriendResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 9:
{
ViewFriendsRequest request = new ViewFriendsRequest();
request.MergeFrom(stream);
ViewFriendsResponse response = new ViewFriendsResponse();
BattlenetRpcErrorCode status = HandleViewFriends(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.ViewFriends(bgs.protocol.friends.v1.ViewFriendsRequest: {1}) returned bgs.protocol.friends.v1.ViewFriendsResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 10:
{
UpdateFriendStateRequest request = new UpdateFriendStateRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleUpdateFriendState(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.UpdateFriendState(bgs.protocol.friends.v1.UpdateFriendStateRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 11:
{
UnsubscribeRequest request = new UnsubscribeRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleUnsubscribe(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.Unsubscribe(bgs.protocol.friends.v1.UnsubscribeRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 12:
{
RevokeAllInvitationsRequest request = new RevokeAllInvitationsRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleRevokeAllInvitations(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.RevokeAllInvitations(bgs.protocol.friends.v1.GenericFriendRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleSubscribe(SubscribeRequest request, SubscribeResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.Subscribe: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleSendInvitation(SendInvitationRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.SendInvitation: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleAcceptInvitation(AcceptInvitationRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.AcceptInvitation: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleRevokeInvitation(RevokeInvitationRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.RevokeInvitation: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleDeclineInvitation(DeclineInvitationRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.DeclineInvitation: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleIgnoreInvitation(IgnoreInvitationRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.IgnoreInvitation: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleRemoveFriend(RemoveFriendRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.RemoveFriend: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleViewFriends(ViewFriendsRequest request, ViewFriendsResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.ViewFriends: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleUpdateFriendState(UpdateFriendStateRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.UpdateFriendState: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleUnsubscribe(UnsubscribeRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.Unsubscribe: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleRevokeAllInvitations(RevokeAllInvitationsRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.RevokeAllInvitations: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
}
class FriendsListener : ServiceBase
{
public FriendsListener(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 1:
{
FriendNotification request = new FriendNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnFriendAdded(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnFriendAdded(bgs.protocol.friends.v1.FriendNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 2:
{
FriendNotification request = new FriendNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnFriendRemoved(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnFriendRemoved(bgs.protocol.friends.v1.FriendNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 3:
{
InvitationNotification request = new InvitationNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnReceivedInvitationAdded(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnReceivedInvitationAdded(bgs.protocol.friends.v1.InvitationNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 4:
{
InvitationNotification request = new InvitationNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnReceivedInvitationRemoved(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnReceivedInvitationRemoved(bgs.protocol.friends.v1.InvitationNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 5:
{
InvitationNotification request = new InvitationNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnSentInvitationAdded(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnSentInvitationAdded(bgs.protocol.friends.v1.InvitationNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 6:
{
InvitationNotification request = new InvitationNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnSentInvitationRemoved(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnSentInvitationRemoved(bgs.protocol.friends.v1.InvitationNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 7:
{
UpdateFriendStateNotification request = new UpdateFriendStateNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnUpdateFriendState(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnUpdateFriendState(bgs.protocol.friends.v1.UpdateFriendStateNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleOnFriendAdded(FriendNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnFriendAdded: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnFriendRemoved(FriendNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnFriendRemoved: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnReceivedInvitationAdded(InvitationNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnReceivedInvitationAdded: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnReceivedInvitationRemoved(InvitationNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnReceivedInvitationRemoved: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnSentInvitationAdded(InvitationNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnSentInvitationAdded: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnSentInvitationRemoved(InvitationNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnSentInvitationRemoved: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnUpdateFriendState(UpdateFriendStateNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnUpdateFriendState: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
}
}
@@ -1,215 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Bgs.Protocol;
using Bgs.Protocol.GameUtilities.V1;
using BNetServer.Services;
using Framework.Constants;
using Google.Protobuf;
namespace BNetServer.Networking
{
class GameUtilitiesService : ServiceBase
{
public GameUtilitiesService(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 1:
{
ClientRequest request = new ClientRequest();
request.MergeFrom(stream);
ClientResponse response = new ClientResponse();
BattlenetRpcErrorCode status = HandleProcessClientRequest(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.ProcessClientRequest(bgs.protocol.game_utilities.v1.ClientRequest: {1}) returned bgs.protocol.game_utilities.v1.ClientResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 2:
{
PresenceChannelCreatedRequest request = new PresenceChannelCreatedRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandlePresenceChannelCreated(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.PresenceChannelCreated(bgs.protocol.game_utilities.v1.PresenceChannelCreatedRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 3:
{
GetPlayerVariablesRequest request = new GetPlayerVariablesRequest();
request.MergeFrom(stream);
GetPlayerVariablesResponse response = new GetPlayerVariablesResponse();
BattlenetRpcErrorCode status = HandleGetPlayerVariables(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.GetPlayerVariables(bgs.protocol.game_utilities.v1.GetPlayerVariablesRequest: {1}) returned bgs.protocol.game_utilities.v1.GetPlayerVariablesResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 6:
{
ServerRequest request = new ServerRequest();
request.MergeFrom(stream);
ServerResponse response = new ServerResponse();
BattlenetRpcErrorCode status = HandleProcessServerRequest(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.ProcessServerRequest(bgs.protocol.game_utilities.v1.ServerRequest: {1}) returned bgs.protocol.game_utilities.v1.ServerResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 7:
{
GameAccountOnlineNotification request = new GameAccountOnlineNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnGameAccountOnline(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.OnGameAccountOnline(bgs.protocol.game_utilities.v1.GameAccountOnlineNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 8:
{
GameAccountOfflineNotification request = new GameAccountOfflineNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnGameAccountOffline(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.OnGameAccountOffline(bgs.protocol.game_utilities.v1.GameAccountOfflineNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 9:
{
GetAchievementsFileRequest request = new GetAchievementsFileRequest();
request.MergeFrom(stream);
GetAchievementsFileResponse response = new GetAchievementsFileResponse();
BattlenetRpcErrorCode status = HandleGetAchievementsFile(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.GetAchievementsFile(bgs.protocol.game_utilities.v1.GetAchievementsFileRequest: {1}) returned bgs.protocol.game_utilities.v1.GetAchievementsFileResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 10:
{
GetAllValuesForAttributeRequest request = new GetAllValuesForAttributeRequest();
request.MergeFrom(stream);
GetAllValuesForAttributeResponse response = new GetAllValuesForAttributeResponse();
BattlenetRpcErrorCode status = HandleGetAllValuesForAttribute(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.GetAllValuesForAttribute(bgs.protocol.game_utilities.v1.GetAllValuesForAttributeRequest: {1}) returned bgs.protocol.game_utilities.v1.GetAllValuesForAttributeResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleProcessClientRequest(ClientRequest request, ClientResponse response)
{
return _session.HandleProcessClientRequest(request, response);
}
BattlenetRpcErrorCode HandlePresenceChannelCreated(PresenceChannelCreatedRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method GameUtilitiesService.PresenceChannelCreated: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleGetPlayerVariables(GetPlayerVariablesRequest request, GetPlayerVariablesResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method GameUtilitiesService.GetPlayerVariables: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleProcessServerRequest(ServerRequest request, ServerResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method GameUtilitiesService.ProcessServerRequest: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnGameAccountOnline(GameAccountOnlineNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method GameUtilitiesService.OnGameAccountOnline: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnGameAccountOffline(GameAccountOfflineNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method GameUtilitiesService.OnGameAccountOffline: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleGetAchievementsFile(GetAchievementsFileRequest request, GetAchievementsFileResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method GameUtilitiesService.GetAchievementsFile: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleGetAllValuesForAttribute(GetAllValuesForAttributeRequest request, GetAllValuesForAttributeResponse response)
{
return _session.HandleGetAllValuesForAttribute(request, response);
}
}
}
@@ -1,203 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Bgs.Protocol;
using Bgs.Protocol.Presence.V1;
using BNetServer.Services;
using Framework.Constants;
using Google.Protobuf;
namespace BNetServer.Networking
{
class PresenceService : ServiceBase
{
public PresenceService(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 1:
{
SubscribeRequest request = new SubscribeRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleSubscribe(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.Subscribe(bgs.protocol.presence.v1.SubscribeRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 2:
{
UnsubscribeRequest request = new UnsubscribeRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleUnsubscribe(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.Unsubscribe(bgs.protocol.presence.v1.UnsubscribeRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 3:
{
UpdateRequest request = new UpdateRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleUpdate(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.Update(bgs.protocol.presence.v1.UpdateRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 4:
{
QueryRequest request = new QueryRequest();
request.MergeFrom(stream);
QueryResponse response = new QueryResponse();
BattlenetRpcErrorCode status = HandleQuery(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.Query(bgs.protocol.presence.v1.QueryRequest: {1}) returned bgs.protocol.presence.v1.QueryResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 5:
{
OwnershipRequest request = new OwnershipRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleOwnership(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.Ownership(bgs.protocol.presence.v1.OwnershipRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 7:
{
SubscribeNotificationRequest request = new SubscribeNotificationRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleSubscribeNotification(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.SubscribeNotification(bgs.protocol.presence.v1.SubscribeNotificationRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
/*case 8:
{
MigrateOlympusCustomMessageRequest request = new MigrateOlympusCustomMessageRequest();
request.MergeFrom(stream);
MigrateOlympusCustomMessageResponse response = new MigrateOlympusCustomMessageResponse();
BattlenetRpcErrorCode status = HandleMigrateOlympusCustomMessage(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.MigrateOlympusCustomMessage(bgs.protocol.presence.v1.MigrateOlympusCustomMessageRequest: {1}) returned bgs.protocol.presence.v1.MigrateOlympusCustomMessageResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}*/
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleSubscribe(SubscribeRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.Subscribe: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleUnsubscribe(UnsubscribeRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.Unsubscribe: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleUpdate(UpdateRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.Update: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleQuery(QueryRequest request, QueryResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.Query: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOwnership(OwnershipRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.Ownership: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleSubscribeNotification(SubscribeNotificationRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.SubscribeNotification: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
/*BattlenetRpcErrorCode HandleMigrateOlympusCustomMessage(MigrateOlympusCustomMessageRequest request, MigrateOlympusCustomMessageResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.MigrateOlympusCustomMessage: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
*/
}
}
@@ -1,87 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Bgs.Protocol;
using Bgs.Protocol.Report.V1;
using BNetServer.Services;
using Framework.Constants;
using Google.Protobuf;
namespace BNetServer.Networking
{
class ReportService : ServiceBase
{
public ReportService(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 1:
{
SendReportRequest request = new SendReportRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleSendReport(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ReportService.SendReport(bgs.protocol.report.v1.SendReportRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
/*case 2:
{
SubmitReportRequest request = new SubmitReportRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleSubmitReport(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ReportService.SubmitReport(bgs.protocol.report.v1.SubmitReportRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}*/
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleSendReport(SendReportRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ReportService.SendReport: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
/* BattlenetRpcErrorCode HandleSubmitReport(SubmitReportRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ReportService.SubmitReport: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}*/
}
}
@@ -1,60 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using BNetServer.Services;
using Framework.Constants;
using Google.Protobuf;
namespace BNetServer.Networking
{
class ResourcesService : ServiceBase
{
public ResourcesService(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
/*case 1:
{
ContentHandleRequest request = new ContentHandleRequest();
request.MergeFrom(stream);
ContentHandle response = new ContentHandle();
BattlenetRpcErrorCode status = HandleGetContentHandle(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ResourcesService.GetContentHandle(bgs.protocol.resources.v1.ContentHandleRequest: {1}) returned bgs.protocol.ContentHandle: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}*/
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
/*BattlenetRpcErrorCode HandleGetContentHandle(ContentHandleRequest request, ContentHandle response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ResourcesService.GetContentHandle({1})", GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}*/
}
}
@@ -1,90 +0,0 @@
/*
* Copyright (C) 2012-2016 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using BNetServer.Networking;
using Framework.Constants;
using Google.Protobuf;
using System;
using System.Collections.Generic;
namespace BNetServer.Services
{
public class ServiceDispatcher : Singleton<ServiceDispatcher>
{
ServiceDispatcher()
{
AddService<AccountService>(OriginalHash.AccountService);
AddService<AccountListener>(OriginalHash.AccountListener);
AddService<AuthenticationService>(OriginalHash.AuthenticationService);
AddService<ConnectionService>(OriginalHash.ConnectionService);
AddService<FriendsService>(OriginalHash.FriendsService);
AddService<GameUtilitiesService>(OriginalHash.GameUtilitiesService);
AddService<PresenceService>(OriginalHash.PresenceService);
AddService<ReportService>(OriginalHash.ReportService);
AddService<ResourcesService>(OriginalHash.ResourcesService);
AddService<UserManagerService>(OriginalHash.UserManagerService);
}
public void Dispatch(Session session, uint serviceHash, uint token, uint methodId, CodedInputStream stream)
{
var action = _dispatchers.LookupByKey(serviceHash);
if (action != null)
action(session, serviceHash, token, methodId, stream);
else
Log.outDebug(LogFilter.SessionRpc, "{0} tried to call invalid service {1}", session.GetClientInfo(), serviceHash);
}
void AddService<Service>(OriginalHash OriginalHash) where Service : ServiceBase
{
_dispatchers[(uint)OriginalHash] = Dispatch<Service>;
}
void Dispatch<Service>(Session session, uint serviceHash, uint token, uint methodId, CodedInputStream stream) where Service : ServiceBase
{
var obj = (Service)Activator.CreateInstance(typeof(Service), session, serviceHash);
obj.CallServerMethod(token, methodId, stream);
}
Dictionary<uint, DispatcherHandler> _dispatchers = new Dictionary<uint, DispatcherHandler>();
delegate void DispatcherHandler(Session session, uint serviceHash, uint token, uint methodId, CodedInputStream stream);
}
abstract class ServiceBase
{
protected ServiceBase(Session session, uint serviceHash)
{
_session = session;
_serviceHash = serviceHash;
}
public abstract void CallServerMethod(uint token, uint methodId, CodedInputStream stream);
public void SendRequest(uint methodId, IMessage request, Action<CodedInputStream> callback) { _session.SendRequest(_serviceHash, methodId, request, callback); }
public void SendRequest(uint methodId, IMessage request) { _session.SendRequest(_serviceHash, methodId, request); }
public void SendResponse(uint token, BattlenetRpcErrorCode status) { _session.SendResponse(token, status); }
public void SendResponse(uint token, IMessage response) { _session.SendResponse(token, response); }
public string GetCallerInfo()
{
return _session.GetClientInfo();
}
protected Session _session;
protected uint _serviceHash;
}
}
@@ -1,319 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Bgs.Protocol;
using Bgs.Protocol.UserManager.V1;
using BNetServer.Services;
using Framework.Constants;
using Google.Protobuf;
namespace BNetServer.Networking
{
class UserManagerService : ServiceBase
{
public UserManagerService(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 1:
{
SubscribeRequest request = new SubscribeRequest();
request.MergeFrom(stream);
SubscribeResponse response = new SubscribeResponse();
BattlenetRpcErrorCode status = HandleSubscribe(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.Subscribe(bgs.protocol.user_manager.v1.SubscribeRequest: {1}) returned bgs.protocol.user_manager.v1.SubscribeResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 10:
{
AddRecentPlayersRequest request = new AddRecentPlayersRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleAddRecentPlayers(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.AddRecentPlayers(bgs.protocol.user_manager.v1.AddRecentPlayersRequest: {1}) returned bgs.protocol.user_manager.v1.AddRecentPlayersResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 11:
{
ClearRecentPlayersRequest request = new ClearRecentPlayersRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleClearRecentPlayers(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.ClearRecentPlayers(bgs.protocol.user_manager.v1.ClearRecentPlayersRequest: {1}) returned bgs.protocol.user_manager.v1.ClearRecentPlayersResponse: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 20:
{
BlockPlayerRequest request = new BlockPlayerRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleBlockPlayer(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.BlockPlayer(bgs.protocol.user_manager.v1.BlockPlayerRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 21:
{
UnblockPlayerRequest request = new UnblockPlayerRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleUnblockPlayer(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.UnblockPlayer(bgs.protocol.user_manager.v1.UnblockPlayerRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 40:
{
BlockPlayerRequest request = new BlockPlayerRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleBlockPlayerForSession(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.BlockPlayerForSession(bgs.protocol.user_manager.v1.BlockPlayerRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 50:
{
EntityId request = new EntityId();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleLoadBlockList(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.LoadBlockList(bgs.protocol.EntityId: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
case 51:
{
UnsubscribeRequest request = new UnsubscribeRequest();
request.MergeFrom(stream);
NoData response = new NoData();
BattlenetRpcErrorCode status = HandleUnsubscribe(request, response);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.Unsubscribe(bgs.protocol.user_manager.v1.UnsubscribeRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
GetCallerInfo(), request.ToString(), response.ToString(), status);
if (status == 0)
SendResponse(token, response);
else
SendResponse(token, status);
break;
}
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleSubscribe(SubscribeRequest request, SubscribeResponse response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.Subscribe: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleAddRecentPlayers(AddRecentPlayersRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.AddRecentPlayers: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleClearRecentPlayers(ClearRecentPlayersRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.ClearRecentPlayers: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleBlockPlayer(BlockPlayerRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.BlockPlayer: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleUnblockPlayer(UnblockPlayerRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.UnblockPlayer: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleBlockPlayerForSession(BlockPlayerRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.BlockPlayerForSession: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleLoadBlockList(EntityId request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.LoadBlockList: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleUnsubscribe(UnsubscribeRequest request, NoData response)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.Unsubscribe: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
}
class UserManagerListener : ServiceBase
{
public UserManagerListener(Session session, uint serviceHash) : base(session, serviceHash) { }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
{
switch (methodId)
{
case 1:
{
BlockedPlayerAddedNotification request = new BlockedPlayerAddedNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnBlockedPlayerAdded(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerListener.OnBlockedPlayerAdded(bgs.protocol.user_manager.v1.BlockedPlayerAddedNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 2:
{
BlockedPlayerRemovedNotification request = new BlockedPlayerRemovedNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnBlockedPlayerRemoved(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerListener.OnBlockedPlayerRemoved(bgs.protocol.user_manager.v1.BlockedPlayerRemovedNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 11:
{
RecentPlayersAddedNotification request = new RecentPlayersAddedNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnRecentPlayersAdded(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerListener.OnRecentPlayersAdded(bgs.protocol.user_manager.v1.RecentPlayersAddedNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
case 12:
{
RecentPlayersRemovedNotification request = new RecentPlayersRemovedNotification();
request.MergeFrom(stream);
BattlenetRpcErrorCode status = HandleOnRecentPlayersRemoved(request);
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerListener.OnRecentPlayersRemoved(bgs.protocol.user_manager.v1.RecentPlayersRemovedNotification: {1}) status: {2}.",
GetCallerInfo(), request.ToString(), status);
if (status != 0)
SendResponse(token, status);
break;
}
default:
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
break;
}
}
BattlenetRpcErrorCode HandleOnBlockedPlayerAdded(BlockedPlayerAddedNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerListener.OnBlockedPlayerAdded: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnBlockedPlayerRemoved(BlockedPlayerRemovedNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerListener.OnBlockedPlayerRemoved: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnRecentPlayersAdded(RecentPlayersAddedNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerListener.OnRecentPlayersAdded: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
BattlenetRpcErrorCode HandleOnRecentPlayersRemoved(RecentPlayersRemovedNotification request)
{
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerListener.OnRecentPlayersRemoved: {1}",
GetCallerInfo(), request.ToString());
return BattlenetRpcErrorCode.RpcNotImplemented;
}
}
}
+2 -2
View File
@@ -142,7 +142,7 @@ namespace Framework.Constants
/// </summary>
public const uint CalendarMaxInvites = 100;
public const uint CalendarDefaultResponseTime = 946684800; // 01/01/2000 00:00:00
public const LocaleConstant DefaultLocale = LocaleConstant.enUS;
public const Locale DefaultLocale = Locale.enUS;
public const int MaxAccountTutorialValues = 8;
public const int MinAuctionTime = (12 * Time.Hour);
public const int MaxConditionTargets = 3;
@@ -372,7 +372,7 @@ namespace Framework.Constants
}
}
public enum LocaleConstant
public enum Locale
{
enUS = 0,
koKR = 1,
@@ -25,11 +25,11 @@ namespace Framework.Database
const string BnetGameAccountInfo = "a.id, a.username, ab.unbandate, ab.unbandate = ab.bandate, aa.gmlevel";
PrepareStatement(LoginStatements.SEL_REALMLIST, "SELECT id, name, address, localAddress, localSubnetMask, port, icon, flag, timezone, allowedSecurityLevel, population, gamebuild, Region, Battlegroup FROM realmlist WHERE flag <> 3 ORDER BY name");
PrepareStatement(LoginStatements.DEL_EXPIRED_IP_BANS, "DELETE FROM ip_banned WHERE unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()");
PrepareStatement(LoginStatements.UPD_EXPIRED_ACCOUNT_BANS, "UPDATE account_banned SET active = 0 WHERE active = 1 AND unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()");
PrepareStatement(LoginStatements.SEL_IP_INFO, "SELECT unbandate > UNIX_TIMESTAMP() OR unbandate = bandate AS banned, NULL as country FROM ip_banned WHERE ip = ?");
PrepareStatement(LoginStatements.DelExpiredIpBans, "DELETE FROM ip_banned WHERE unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()");
PrepareStatement(LoginStatements.UpdExpiredAccountBans, "UPDATE account_banned SET active = 0 WHERE active = 1 AND unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()");
PrepareStatement(LoginStatements.SelIpInfo, "SELECT unbandate > UNIX_TIMESTAMP() OR unbandate = bandate AS banned, NULL as country FROM ip_banned WHERE ip = ?");
PrepareStatement(LoginStatements.INS_IP_AUTO_BANNED, "INSERT INTO ip_banned (ip, bandate, unbandate, bannedby, banreason) VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Cypher Auth', 'Failed login autoban')");
PrepareStatement(LoginStatements.InsIpAutoBanned, "INSERT INTO ip_banned (ip, bandate, unbandate, bannedby, banreason) VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Cypher Auth', 'Failed login autoban')");
PrepareStatement(LoginStatements.SEL_IP_BANNED_ALL, "SELECT ip, bandate, unbandate, bannedby, banreason FROM ip_banned WHERE (bandate = unbandate OR unbandate > UNIX_TIMESTAMP()) ORDER BY unbandate");
PrepareStatement(LoginStatements.SEL_IP_BANNED_BY_IP, "SELECT ip, bandate, unbandate, bannedby, banreason FROM ip_banned WHERE (bandate = unbandate OR unbandate > UNIX_TIMESTAMP()) AND ip LIKE CONCAT('%%', ?, '%%') ORDER BY unbandate");
PrepareStatement(LoginStatements.SEL_ACCOUNT_BANNED_ALL, "SELECT account.id, username FROM account, account_banned WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id");
@@ -113,16 +113,16 @@ namespace Framework.Database
PrepareStatement(LoginStatements.SEL_ACCOUNT_MUTE_INFO, "SELECT mutedate, mutetime, mutereason, mutedby FROM account_muted WHERE guid = ? ORDER BY mutedate ASC");
PrepareStatement(LoginStatements.DEL_ACCOUNT_MUTED, "DELETE FROM account_muted WHERE guid = ?");
PrepareStatement(LoginStatements.SEL_BNET_AUTHENTICATION, "SELECT ba.id, ba.sha_pass_hash, ba.failed_logins, ba.LoginTicket, ba.LoginTicketExpiry, bab.unbandate > UNIX_TIMESTAMP() OR bab.unbandate = bab.bandate FROM battlenet_accounts ba LEFT JOIN battlenet_account_bans bab ON ba.id = bab.id WHERE email = ?");
PrepareStatement(LoginStatements.UPD_BNET_AUTHENTICATION, "UPDATE battlenet_accounts SET LoginTicket = ?, LoginTicketExpiry = ? WHERE id = ?");
PrepareStatement(LoginStatements.SEL_BNET_ACCOUNT_INFO, "SELECT " + BnetAccountInfo + ", " + BnetGameAccountInfo +
PrepareStatement(LoginStatements.SelBnetAuthentication, "SELECT ba.id, ba.sha_pass_hash, ba.failed_logins, ba.LoginTicket, ba.LoginTicketExpiry, bab.unbandate > UNIX_TIMESTAMP() OR bab.unbandate = bab.bandate FROM battlenet_accounts ba LEFT JOIN battlenet_account_bans bab ON ba.id = bab.id WHERE email = ?");
PrepareStatement(LoginStatements.UpdBnetAuthentication, "UPDATE battlenet_accounts SET LoginTicket = ?, LoginTicketExpiry = ? WHERE id = ?");
PrepareStatement(LoginStatements.SelBnetAccountInfo, "SELECT " + BnetAccountInfo + ", " + BnetGameAccountInfo +
" FROM battlenet_accounts ba LEFT JOIN battlenet_account_bans bab ON ba.id = bab.id LEFT JOIN account a ON ba.id = a.battlenet_account" +
" LEFT JOIN account_banned ab ON a.id = ab.id AND ab.active = 1 LEFT JOIN account_access aa ON a.id = aa.id AND aa.RealmID = -1 WHERE ba.LoginTicket = ? ORDER BY a.id");
PrepareStatement(LoginStatements.UPD_BNET_LAST_LOGIN_INFO, "UPDATE battlenet_accounts SET last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ? WHERE id = ?");
PrepareStatement(LoginStatements.UpdBnetLastLoginInfo, "UPDATE battlenet_accounts SET last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ? WHERE id = ?");
PrepareStatement(LoginStatements.UPD_BNET_GAME_ACCOUNT_LOGIN_INFO, "UPDATE account SET sessionkey = ?, last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ? WHERE username = ?");
PrepareStatement(LoginStatements.SEL_BNET_CHARACTER_COUNTS_BY_ACCOUNT_ID, "SELECT rc.acctid, rc.numchars, r.id, r.Region, r.Battlegroup FROM realmcharacters rc INNER JOIN realmlist r ON rc.realmid = r.id WHERE rc.acctid = ?");
PrepareStatement(LoginStatements.SelBnetCharacterCountsByAccountId, "SELECT rc.acctid, rc.numchars, r.id, r.Region, r.Battlegroup FROM realmcharacters rc INNER JOIN realmlist r ON rc.realmid = r.id WHERE rc.acctid = ?");
PrepareStatement(LoginStatements.SEL_BNET_CHARACTER_COUNTS_BY_BNET_ID, "SELECT rc.acctid, rc.numchars, r.id, r.Region, r.Battlegroup FROM realmcharacters rc INNER JOIN realmlist r ON rc.realmid = r.id LEFT JOIN account a ON rc.acctid = a.id WHERE a.battlenet_account = ?");
PrepareStatement(LoginStatements.SEL_BNET_LAST_PLAYER_CHARACTERS, "SELECT lpc.accountId, lpc.region, lpc.battlegroup, lpc.realmId, lpc.characterName, lpc.characterGUID, lpc.lastPlayedTime FROM account_last_played_character lpc LEFT JOIN account a ON lpc.accountId = a.id WHERE a.battlenet_account = ?");
PrepareStatement(LoginStatements.SelBnetLastPlayerCharacters, "SELECT lpc.accountId, lpc.region, lpc.battlegroup, lpc.realmId, lpc.characterName, lpc.characterGUID, lpc.lastPlayedTime FROM account_last_played_character lpc LEFT JOIN account a ON lpc.accountId = a.id WHERE a.battlenet_account = ?");
PrepareStatement(LoginStatements.DEL_BNET_LAST_PLAYER_CHARACTERS, "DELETE FROM account_last_played_character WHERE accountId = ? AND region = ? AND battlegroup = ?");
PrepareStatement(LoginStatements.INS_BNET_LAST_PLAYER_CHARACTERS, "INSERT INTO account_last_played_character (accountId, region, battlegroup, realmId, characterName, characterGUID, lastPlayedTime) VALUES (?,?,?,?,?,?,?)");
PrepareStatement(LoginStatements.INS_BNET_ACCOUNT, "INSERT INTO battlenet_accounts (`email`,`sha_pass_hash`) VALUES (?, ?)");
@@ -137,10 +137,10 @@ namespace Framework.Database
PrepareStatement(LoginStatements.SEL_BNET_MAX_ACCOUNT_INDEX, "SELECT MAX(battlenet_index) FROM account WHERE battlenet_account = ?");
PrepareStatement(LoginStatements.SEL_BNET_GAME_ACCOUNT_LIST, "SELECT a.id, a.username FROM account a LEFT JOIN battlenet_accounts ba ON a.battlenet_account = ba.id WHERE ba.email = ?");
PrepareStatement(LoginStatements.UPD_BNET_FAILED_LOGINS, "UPDATE battlenet_accounts SET failed_logins = failed_logins + 1 WHERE id = ?");
PrepareStatement(LoginStatements.INS_BNET_ACCOUNT_AUTO_BANNED, "INSERT INTO battlenet_account_bans(id, bandate, unbandate, bannedby, banreason) VALUES(?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Trinity Auth', 'Failed login autoban')");
PrepareStatement(LoginStatements.DEL_BNET_EXPIRED_ACCOUNT_BANNED, "DELETE FROM battlenet_account_bans WHERE unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()");
PrepareStatement(LoginStatements.UPD_BNET_RESET_FAILED_LOGINS, "UPDATE battlenet_accounts SET failed_logins = 0 WHERE id = ?");
PrepareStatement(LoginStatements.UpdBnetFailedLogins, "UPDATE battlenet_accounts SET failed_logins = failed_logins + 1 WHERE id = ?");
PrepareStatement(LoginStatements.InsBnetAccountAutoBanned, "INSERT INTO battlenet_account_bans(id, bandate, unbandate, bannedby, banreason) VALUES(?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Trinity Auth', 'Failed login autoban')");
PrepareStatement(LoginStatements.DelBnetExpiredAccountBanned, "DELETE FROM battlenet_account_bans WHERE unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()");
PrepareStatement(LoginStatements.UpdBnetResetFailedLogins, "UPDATE battlenet_accounts SET failed_logins = 0 WHERE id = ?");
PrepareStatement(LoginStatements.SEL_LAST_CHAR_UNDELETE, "SELECT LastCharacterUndelete FROM battlenet_accounts WHERE Id = ?");
PrepareStatement(LoginStatements.UPD_LAST_CHAR_UNDELETE, "UPDATE battlenet_accounts SET LastCharacterUndelete = UNIX_TIMESTAMP() WHERE Id = ?");
@@ -178,10 +178,10 @@ namespace Framework.Database
public enum LoginStatements
{
SEL_REALMLIST,
DEL_EXPIRED_IP_BANS,
UPD_EXPIRED_ACCOUNT_BANS,
SEL_IP_INFO,
INS_IP_AUTO_BANNED,
DelExpiredIpBans,
UpdExpiredAccountBans,
SelIpInfo,
InsIpAutoBanned,
SEL_ACCOUNT_BANNED_ALL,
SEL_ACCOUNT_BANNED_BY_USERNAME,
DEL_ACCOUNT_BANNED,
@@ -260,14 +260,14 @@ namespace Framework.Database
SEL_ACCOUNT_MUTE_INFO,
DEL_ACCOUNT_MUTED,
SEL_BNET_AUTHENTICATION,
UPD_BNET_AUTHENTICATION,
SEL_BNET_ACCOUNT_INFO,
UPD_BNET_LAST_LOGIN_INFO,
SelBnetAuthentication,
UpdBnetAuthentication,
SelBnetAccountInfo,
UpdBnetLastLoginInfo,
UPD_BNET_GAME_ACCOUNT_LOGIN_INFO,
SEL_BNET_CHARACTER_COUNTS_BY_ACCOUNT_ID,
SelBnetCharacterCountsByAccountId,
SEL_BNET_CHARACTER_COUNTS_BY_BNET_ID,
SEL_BNET_LAST_PLAYER_CHARACTERS,
SelBnetLastPlayerCharacters,
DEL_BNET_LAST_PLAYER_CHARACTERS,
INS_BNET_LAST_PLAYER_CHARACTERS,
INS_BNET_ACCOUNT,
@@ -283,10 +283,10 @@ namespace Framework.Database
SEL_BNET_MAX_ACCOUNT_INDEX,
SEL_BNET_GAME_ACCOUNT_LIST,
UPD_BNET_FAILED_LOGINS,
INS_BNET_ACCOUNT_AUTO_BANNED,
DEL_BNET_EXPIRED_ACCOUNT_BANNED,
UPD_BNET_RESET_FAILED_LOGINS,
UpdBnetFailedLogins,
InsBnetAccountAutoBanned,
DelBnetExpiredAccountBanned,
UpdBnetResetFailedLogins,
SEL_LAST_CHAR_UNDELETE,
UPD_LAST_CHAR_UNDELETE,
+9
View File
@@ -50,6 +50,15 @@ namespace Framework.Database
return (T)value;
}
public T[] ReadValues<T>(int startIndex, int numColumns)
{
T[] values = new T[numColumns];
for (var c = 0; c < numColumns; ++c)
values[c] = Read<T>(startIndex + c);
return values;
}
public bool IsNull(int column)
{
return _reader.IsDBNull(column);
+4 -4
View File
@@ -25,12 +25,15 @@ namespace Framework.Networking
public class AsyncAcceptor
{
TcpListener _listener;
volatile bool _closed;
public bool Start(string ip, int port)
{
IPAddress bindIP;
if (!IPAddress.TryParse(ip, out bindIP))
{
Log.outError(LogFilter.Network, "Server can't be started: Invalid IP-Address ({0})", ip);
Log.outError(LogFilter.Network, $"Server can't be started: Invalid IP-Address: {ip}");
return false;
}
@@ -73,8 +76,5 @@ namespace Framework.Networking
_closed = true;
_listener.Stop();
}
TcpListener _listener;
volatile bool _closed;
}
}
+9 -8
View File
@@ -22,6 +22,14 @@ namespace Framework.Networking
{
public class NetworkThread<TSocketType> where TSocketType : ISocket
{
int _connections;
volatile bool _stopped;
Thread _thread;
List<TSocketType> _Sockets = new List<TSocketType>();
List<TSocketType> _newSockets = new List<TSocketType>();
public void Stop()
{
_stopped = true;
@@ -56,6 +64,7 @@ namespace Framework.Networking
}
protected virtual void SocketAdded(TSocketType sock) { }
protected virtual void SocketRemoved(TSocketType sock) { }
void AddNewSockets()
@@ -114,13 +123,5 @@ namespace Framework.Networking
_newSockets.Clear();
_Sockets.Clear();
}
int _connections;
volatile bool _stopped;
Thread _thread;
List<TSocketType> _Sockets = new List<TSocketType>();
List<TSocketType> _newSockets = new List<TSocketType>();
}
}
+37 -58
View File
@@ -20,46 +20,56 @@ using System.Net;
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
namespace Framework.Networking
{
public abstract class SSLSocket : ISocket
public abstract class SSLSocket : ISocket, IDisposable
{
Socket _socket;
internal SslStream _stream;
IPEndPoint _remoteEndPoint;
byte[] _receiveBuffer;
protected SSLSocket(Socket socket)
{
_socket = socket;
_remoteAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;
_remotePort = (ushort)((IPEndPoint)_socket.RemoteEndPoint).Port;
_remoteEndPoint = (IPEndPoint)_socket.RemoteEndPoint;
_receiveBuffer = new byte[ushort.MaxValue];
_stream = new SslStream(new NetworkStream(socket), false);
}
public abstract void Start();
public virtual void Dispose()
{
_receiveBuffer = null;
_stream.Dispose();
}
public abstract void Accept();
public virtual bool Update()
{
return IsOpen();
return _socket.Connected;
}
public IPAddress GetRemoteIpAddress()
public IPEndPoint GetRemoteIpEndPoint()
{
return _remoteAddress;
return _remoteEndPoint;
}
public ushort GetRemotePort()
{
return _remotePort;
}
public void AsyncRead()
public async Task AsyncRead()
{
if (!IsOpen())
return;
try
{
_stream.BeginRead(_receiveBuffer, 0, _receiveBuffer.Length, ReadHandlerInternal, _stream);
var result = await _stream.ReadAsync(_receiveBuffer, 0, _receiveBuffer.Length);
byte[] data = new byte[result];
Buffer.BlockCopy(_receiveBuffer, 0, data, 0, result);
ReadHandler(data, result);
}
catch (Exception ex)
{
@@ -67,28 +77,11 @@ namespace Framework.Networking
}
}
void ReadHandlerInternal(IAsyncResult result)
{
int bytes = 0;
try
{
bytes = _stream.EndRead(result);
}
catch (Exception ex)
{
Log.outException(ex);
}
ReadHandler(bytes);
}
public abstract void ReadHandler(int transferredBytes);
public void AsyncHandshake(X509Certificate2 certificate)
public async Task AsyncHandshake(X509Certificate2 certificate)
{
try
{
_stream.AuthenticateAsServer(certificate, false, System.Security.Authentication.SslProtocols.Tls, false);
await _stream.AuthenticateAsServerAsync(certificate, false, System.Security.Authentication.SslProtocols.Tls, false);
}
catch(Exception ex)
{
@@ -96,17 +89,20 @@ namespace Framework.Networking
CloseSocket();
return;
}
AsyncRead();
await AsyncRead();
}
public void AsyncWrite(byte[] data)
public abstract void ReadHandler(byte[] data, int receivedLength);
public async Task AsyncWrite(byte[] data)
{
if (!IsOpen())
return;
try
{
_stream.Write(data, 0, data.Length);
await _stream.WriteAsync(data, 0, data.Length);
}
catch (Exception ex)
{
@@ -118,39 +114,22 @@ namespace Framework.Networking
{
try
{
_closed = true;
_socket.Shutdown(SocketShutdown.Both);
_socket.Close();
}
catch (Exception ex)
{
Log.outDebug(LogFilter.Network, "WorldSocket.CloseSocket: {0} errored when shutting down socket: {1}", GetRemoteIpAddress().ToString(), ex.Message);
Log.outDebug(LogFilter.Network, $"WorldSocket.CloseSocket: {GetRemoteIpEndPoint()} errored when shutting down socket: {ex.Message}");
}
}
OnClose();
}
public virtual void OnClose() { Dispose(); }
public bool IsOpen() { return _socket.Connected; }
public void SetNoDelay(bool enable)
{
_socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, enable);
}
public virtual void OnClose() { }
public bool IsOpen() { return !_closed; }
public byte[] GetReceiveBuffer()
{
return _receiveBuffer;
}
Socket _socket;
internal SslStream _stream;
byte[] _receiveBuffer;
volatile bool _closed;
IPAddress _remoteAddress;
ushort _remotePort;
}
}
+36 -61
View File
@@ -18,42 +18,50 @@
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
namespace Framework.Networking
{
public interface ISocket
{
void Accept();
bool Update();
bool IsOpen();
void CloseSocket();
}
public abstract class SocketBase : ISocket, IDisposable
{
Socket _socket;
IPEndPoint _remoteIPEndPoint;
byte[] _receiveBuffer;
protected SocketBase(Socket socket)
{
_socket = socket;
_remoteAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;
_remotePort = (ushort)((IPEndPoint)_socket.RemoteEndPoint).Port;
_remoteIPEndPoint = (IPEndPoint)_socket.RemoteEndPoint;
_receiveBuffer = new byte[ushort.MaxValue];
}
public virtual void Dispose()
{
_receiveBuffer = null;
_socket.Dispose();
}
public abstract void Start();
public abstract void Accept();
public virtual bool Update()
{
return IsOpen();
}
public IPAddress GetRemoteIpAddress()
public IPEndPoint GetRemoteIpAddress()
{
return _remoteAddress;
return _remoteIPEndPoint;
}
public ushort GetRemotePort()
{
return _remotePort;
}
public void AsyncRead()
public async Task AsyncRead()
{
if (!IsOpen())
return;
@@ -63,12 +71,12 @@ namespace Framework.Networking
using (var socketEventargs = new SocketAsyncEventArgs())
{
socketEventargs.SetBuffer(_receiveBuffer, 0, _receiveBuffer.Length);
socketEventargs.Completed += (sender, args) => ReadHandlerInternal(args);
socketEventargs.Completed += async (sender, args) => await ProcessReadAsync(args);
socketEventargs.SocketFlags = SocketFlags.None;
socketEventargs.RemoteEndPoint = _socket.RemoteEndPoint;
if (!_socket.ReceiveAsync(socketEventargs))
ReadHandlerInternal(socketEventargs);
await ProcessReadAsync(socketEventargs);
}
}
catch (Exception ex)
@@ -77,8 +85,7 @@ namespace Framework.Networking
}
}
public delegate void SocketReadCallback(SocketAsyncEventArgs args);
public void AsyncReadWithCallback(SocketReadCallback callback)
public async Task AsyncReadWithCallback(SocketReadCallback callback)
{
if (!IsOpen())
return;
@@ -92,7 +99,7 @@ namespace Framework.Networking
socketEventargs.UserToken = _socket;
socketEventargs.SocketFlags = SocketFlags.None;
if (!_socket.ReceiveAsync(socketEventargs))
callback(socketEventargs);
await callback(socketEventargs);
}
}
catch (Exception ex)
@@ -101,7 +108,7 @@ namespace Framework.Networking
}
}
void ReadHandlerInternal(SocketAsyncEventArgs args)
async Task ProcessReadAsync(SocketAsyncEventArgs args)
{
if (args.SocketError != SocketError.Success)
{
@@ -115,31 +122,19 @@ namespace Framework.Networking
return;
}
ReadHandler(args.BytesTransferred);
byte[] data = new byte[args.BytesTransferred];
Buffer.BlockCopy(_receiveBuffer, 0, data, 0, args.BytesTransferred);
await ReadHandler(data, args.BytesTransferred);
}
public abstract void ReadHandler(int transferredBytes);
public abstract Task ReadHandler(byte[] data, int bytesTransferred);
public void AsyncWrite(byte[] data)
public async void AsyncWrite(byte[] data)
{
if (!IsOpen())
return;
using (var socketEventargs = new SocketAsyncEventArgs())
{
socketEventargs.SetBuffer(data, 0, data.Length);
socketEventargs.Completed += WriteHandlerInternal;
socketEventargs.RemoteEndPoint = _socket.RemoteEndPoint;
socketEventargs.UserToken = _socket;
socketEventargs.SocketFlags = SocketFlags.None;
_socket.SendAsync(socketEventargs);
}
}
void WriteHandlerInternal(object sender, SocketAsyncEventArgs args)
{
args.Completed -= WriteHandlerInternal;
await _socket.SendAsync(data, SocketFlags.None);
}
public void CloseSocket()
@@ -149,46 +144,26 @@ namespace Framework.Networking
try
{
_closed = true;
_socket.Shutdown(SocketShutdown.Both);
_socket.Close();
}
catch (Exception ex)
{
Log.outDebug(LogFilter.Network, "WorldSocket.CloseSocket: {0} errored when shutting down socket: {1}", GetRemoteIpAddress().ToString(), ex.Message);
Log.outDebug(LogFilter.Network, $"WorldSocket.CloseSocket: {GetRemoteIpAddress()} errored when shutting down socket: {ex.Message}");
}
OnClose();
}
public virtual void OnClose() { Dispose(); }
public bool IsOpen() { return _socket.Connected; }
public void SetNoDelay(bool enable)
{
_socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, enable);
}
public virtual void OnClose() { Dispose(); }
public bool IsOpen() { return !_closed; }
public byte[] GetReceiveBuffer()
{
return _receiveBuffer;
}
Socket _socket;
byte[] _receiveBuffer;
volatile bool _closed;
IPAddress _remoteAddress;
ushort _remotePort;
}
public interface ISocket
{
void Start();
bool Update();
bool IsOpen();
void CloseSocket();
public delegate Task SocketReadCallback(SocketAsyncEventArgs args);
}
}
+5 -5
View File
@@ -22,6 +22,10 @@ namespace Framework.Networking
{
public class SocketManager<TSocketType> where TSocketType : ISocket
{
public AsyncAcceptor Acceptor;
NetworkThread<TSocketType>[] _threads;
int _threadCount;
public virtual bool StartNetwork(string bindIp, int port, int threadCount = 1)
{
Cypher.Assert(threadCount > 0);
@@ -74,7 +78,7 @@ namespace Framework.Networking
try
{
TSocketType newSocket = (TSocketType)Activator.CreateInstance(typeof(TSocketType), sock);
newSocket.Start();
newSocket.Accept();
_threads[SelectThreadWithMinConnections()].AddSocket(newSocket);
}
@@ -96,9 +100,5 @@ namespace Framework.Networking
return min;
}
public AsyncAcceptor Acceptor;
NetworkThread<TSocketType>[] _threads;
int _threadCount;
}
}
+2 -50
View File
@@ -16,6 +16,7 @@
*/
using Framework.Constants;
using Framework.Realm;
using System;
using System.Net;
using System.Net.Sockets;
@@ -94,7 +95,7 @@ public class Realm : IEquatable<Realm>
return new { ExternalAddress, LocalAddress, LocalSubnetMask, Port, Name, Type, Flags, Timezone, AllowedSecurityLevel, PopulationLevel }.GetHashCode();
}
public RealmHandle Id;
public RealmId Id;
public uint Build;
public IPAddress ExternalAddress;
public IPAddress LocalAddress;
@@ -109,52 +110,3 @@ public class Realm : IEquatable<Realm>
public float PopulationLevel;
}
public struct RealmHandle : IEquatable<RealmHandle>
{
public RealmHandle(byte region, byte battlegroup, uint index)
{
Region = region;
Site = battlegroup;
Realm = index;
}
public RealmHandle(uint realmAddress)
{
Region = (byte)((realmAddress >> 24) & 0xFF);
Site = (byte)((realmAddress >> 16) & 0xFF);
Realm = realmAddress & 0xFFFF;
}
public uint GetAddress()
{
return (uint)((Region << 24) | (Site << 16) | (ushort)Realm);
}
public string GetAddressString()
{
return $"{Region}-{Site}-{Realm}";
}
public string GetSubRegionAddress()
{
return $"{Region}-{Site}-0";
}
public override bool Equals(object obj)
{
return obj != null && obj is RealmHandle && Equals((RealmHandle)obj);
}
public bool Equals(RealmHandle other)
{
return other.Realm == Realm;
}
public override int GetHashCode()
{
return new { Site, Region, Realm }.GetHashCode();
}
public byte Region;
public byte Site;
public uint Realm; // primary key in `realmlist` table
}
+58
View File
@@ -0,0 +1,58 @@
// 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;
namespace Framework.Realm
{
public struct RealmId : IEquatable<RealmId>
{
public uint Index { get; set; }
public byte Region { get; set; }
public byte Site { get; set; }
public RealmId(byte region, byte battlegroup, uint index)
{
Region = region;
Site = battlegroup;
Index = index;
}
public RealmId(uint realmAddress)
{
Region = (byte)((realmAddress >> 24) & 0xFF);
Site = (byte)((realmAddress >> 16) & 0xFF);
Index = realmAddress & 0xFFFF;
}
public uint GetAddress()
{
return (uint)((Region << 24) | (Site << 16) | (ushort)Index);
}
public string GetAddressString()
{
return $"{Region}-{Site}-{Index}";
}
public string GetSubRegionAddress()
{
return $"{Region}-{Site}-0";
}
public override bool Equals(object obj)
{
return obj != null && obj is RealmId && Equals((RealmId)obj);
}
public bool Equals(RealmId other)
{
return other.Index == Index;
}
public override int GetHashCode()
{
return new { Site, Region, Index }.GetHashCode();
}
}
}
+12 -11
View File
@@ -17,7 +17,7 @@
using Framework.Constants;
using Framework.Database;
using Framework.Rest;
using Framework.Web;
using Framework.Serialization;
using System;
using System.Collections.Generic;
@@ -25,6 +25,7 @@ using System.Linq;
using System.Net;
using System.Timers;
using System.Collections.Concurrent;
using Framework.Realm;
public class RealmManager : Singleton<RealmManager>
{
@@ -91,7 +92,7 @@ public class RealmManager : Singleton<RealmManager>
{
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_REALMLIST);
SQLResult result = DB.Login.Query(stmt);
Dictionary<RealmHandle, string> existingRealms = new Dictionary<RealmHandle, string>();
Dictionary<RealmId, string> existingRealms = new Dictionary<RealmId, string>();
foreach (var p in _realms)
existingRealms[p.Key] = p.Value.Name;
@@ -125,11 +126,11 @@ public class RealmManager : Singleton<RealmManager>
byte region = result.Read<byte>(12);
byte battlegroup = result.Read<byte>(13);
realm.Id = new RealmHandle(region, battlegroup, realmId);
realm.Id = new RealmId(region, battlegroup, realmId);
UpdateRealm(realm);
var subRegion = new RealmHandle(region, battlegroup, 0).GetAddressString();
var subRegion = new RealmId(region, battlegroup, 0).GetAddressString();
if (!_subRegions.Contains(subRegion))
_subRegions.Add(subRegion);
@@ -147,7 +148,7 @@ public class RealmManager : Singleton<RealmManager>
Log.outInfo(LogFilter.Realmlist, "Removed realm \"{0}\".", pair.Value);
}
public Realm GetRealm(RealmHandle id)
public Realm GetRealm(RealmId id)
{
return _realms.LookupByKey(id);
}
@@ -177,7 +178,7 @@ public class RealmManager : Singleton<RealmManager>
}
}
public byte[] GetRealmEntryJSON(RealmHandle id, uint build)
public byte[] GetRealmEntryJSON(RealmId id, uint build)
{
byte[] compressed = new byte[0];
Realm realm = GetRealm(id);
@@ -209,7 +210,7 @@ public class RealmManager : Singleton<RealmManager>
}
realmEntry.Version = version;
realmEntry.CfgRealmsID = (int)realm.Id.Realm;
realmEntry.CfgRealmsID = (int)realm.Id.Index;
realmEntry.Flags = (int)realm.Flags;
realmEntry.Name = realm.Name;
realmEntry.CfgConfigsID = (int)realm.GetConfigId();
@@ -256,7 +257,7 @@ public class RealmManager : Singleton<RealmManager>
realmListUpdate.Update.Version.Build = (int)realm.Value.Build;
}
realmListUpdate.Update.CfgRealmsID = (int)realm.Value.Id.Realm;
realmListUpdate.Update.CfgRealmsID = (int)realm.Value.Id.Index;
realmListUpdate.Update.Flags = (int)flag;
realmListUpdate.Update.Name = realm.Value.Name;
realmListUpdate.Update.CfgConfigsID = (int)realm.Value.GetConfigId();
@@ -270,9 +271,9 @@ public class RealmManager : Singleton<RealmManager>
return Json.Deflate("JSONRealmListUpdates", realmList);
}
public BattlenetRpcErrorCode JoinRealm(uint realmAddress, uint build, IPAddress clientAddress, Array<byte> clientSecret, LocaleConstant locale, string os, string accountName, Bgs.Protocol.GameUtilities.V1.ClientResponse response)
public BattlenetRpcErrorCode JoinRealm(uint realmAddress, uint build, IPAddress clientAddress, byte[] clientSecret, Locale locale, string os, string accountName, Bgs.Protocol.GameUtilities.V1.ClientResponse response)
{
Realm realm = GetRealm(new RealmHandle(realmAddress));
Realm realm = GetRealm(new RealmId(realmAddress));
if (realm != null)
{
if (realm.Flags.HasAnyFlag(RealmFlags.Offline) || realm.Build != build)
@@ -328,7 +329,7 @@ public class RealmManager : Singleton<RealmManager>
List<string> GetSubRegions() { return _subRegions; }
List<RealmBuildInfo> _builds = new List<RealmBuildInfo>();
ConcurrentDictionary<RealmHandle, Realm> _realms = new ConcurrentDictionary<RealmHandle, Realm>();
ConcurrentDictionary<RealmId, Realm> _realms = new ConcurrentDictionary<RealmId, Realm>();
List<string> _subRegions = new List<string>();
Timer _updateTimer;
}
@@ -1,41 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
namespace Framework.Rest
{
[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>();
}
}
-37
View File
@@ -1,37 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class FormInput
{
[DataMember(Name = "input_id")]
public string Id { get; set; }
[DataMember(Name = "type")]
public string Type { get; set; }
[DataMember(Name = "label")]
public string Label { get; set; }
[DataMember(Name = "max_length")]
public int MaxLength { get; set; }
}
}
@@ -1,31 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class FormInputValue
{
[DataMember(Name = "input_id")]
public string Id { get; set; }
[DataMember(Name = "value")]
public string Value { get; set; }
}
}
-35
View File
@@ -1,35 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class FormInputs
{
[DataMember(Name = "type")]
public string Type { get; set; }
[DataMember(Name = "prompt")]
public string Prompt { get; set; }
[DataMember(Name = "inputs")]
public List<FormInput> Inputs { get; set; } = new List<FormInput>();
}
}
-31
View File
@@ -1,31 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class Address
{
[DataMember(Name = "ip")]
public string Ip { get; set; }
[DataMember(Name = "port")]
public int Port { get; set; }
}
}
@@ -1,32 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class AddressFamily
{
[DataMember(Name = "family")]
public int Id { get; set; }
[DataMember(Name = "addresses")]
public IList<Address> Addresses { get; set; } = new List<Address>();
}
}
@@ -1,37 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class ClientVersion
{
[DataMember(Name = "versionMajor")]
public int Major { get; set; }
[DataMember(Name = "versionBuild")]
public int Build { get; set; }
[DataMember(Name = "versionMinor")]
public int Minor { get; set; }
[DataMember(Name = "versionRevision")]
public int Revision { get; set; }
}
}
@@ -1,31 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class RealmCharacterCountEntry
{
[DataMember(Name = "wowRealmAddress")]
public int WowRealmAddress { get; set; }
[DataMember(Name = "count")]
public int Count { get; set; }
}
}
@@ -1,29 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class RealmCharacterCountList
{
[DataMember(Name = "counts")]
public IList<RealmCharacterCountEntry> Counts { get; set; } = new List<RealmCharacterCountEntry>();
}
}
@@ -1,29 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class RealmListServerIPAddresses
{
[DataMember(Name = "families")]
public IList<AddressFamily> Families { get; set; } = new List<AddressFamily>();
}
}
@@ -1,28 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class RealmListTicketClientInformation
{
[DataMember(Name = "info")]
public RealmListTicketInformation Info { get; set; } = new RealmListTicketInformation();
}
}
@@ -1,31 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class RealmListTicketIdentity
{
[DataMember(Name = "gameAccountID")]
public int GameAccountId { get; set; }
[DataMember(Name = "gameAccountRegion")]
public int GameAccountRegion { get; set; }
}
}
@@ -1,31 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class RealmListUpdate
{
[DataMember(Name = "update")]
public RealmEntry Update { get; set; } = new RealmEntry();
[DataMember(Name = "deleting")]
public bool Deleting { get; set; }
}
}
@@ -1,29 +0,0 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Framework.Rest
{
[DataContract]
public class RealmListUpdates
{
[DataMember(Name = "updates")]
public IList<RealmListUpdate> Updates { get; set; } = new List<RealmListUpdate>();
}
}
+12
View File
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Framework.Web.API
{
public class ApiRequest<T>
{
public uint? SearchId { get; set; }
public Func<T, bool> SearchFunc { get; set; }
}
}
@@ -0,0 +1,27 @@
// 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,9 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// 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;
namespace Framework.Rest
namespace Framework.Web
{
[DataContract]
public class LogonResult
@@ -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.Runtime.Serialization;
namespace Framework.Web
{
[DataContract]
public class FormInput
{
[DataMember(Name = "input_id")]
public string Id { get; set; }
[DataMember(Name = "type")]
public string Type { get; set; }
[DataMember(Name = "label")]
public string Label { get; set; }
[DataMember(Name = "max_length")]
public int MaxLength { get; set; }
}
}
@@ -0,0 +1,17 @@
// 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;
namespace Framework.Web
{
[DataContract]
public class FormInputValue
{
[DataMember(Name = "input_id")]
public string Id { get; set; }
[DataMember(Name = "value")]
public string Value { get; set; }
}
}
@@ -0,0 +1,21 @@
// 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.Runtime.Serialization;
namespace Framework.Web
{
[DataContract]
public class FormInputs
{
[DataMember(Name = "type")]
public string Type { get; set; }
[DataMember(Name = "prompt")]
public string Prompt { get; set; }
[DataMember(Name = "inputs")]
public List<FormInput> Inputs { get; set; } = new List<FormInput>();
}
}
+17
View File
@@ -0,0 +1,17 @@
// 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;
namespace Framework.Web
{
[DataContract]
public class Address
{
[DataMember(Name = "ip")]
public string Ip { get; set; }
[DataMember(Name = "port")]
public int Port { get; set; }
}
}
@@ -0,0 +1,18 @@
// 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.Runtime.Serialization;
namespace Framework.Web
{
[DataContract]
public class AddressFamily
{
[DataMember(Name = "family")]
public int Id { get; set; }
[DataMember(Name = "addresses")]
public IList<Address> Addresses { get; set; } = new List<Address>();
}
}
@@ -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.Runtime.Serialization;
namespace Framework.Web
{
[DataContract]
public class ClientVersion
{
[DataMember(Name = "versionMajor")]
public int Major { get; set; }
[DataMember(Name = "versionBuild")]
public int Build { get; set; }
[DataMember(Name = "versionMinor")]
public int Minor { get; set; }
[DataMember(Name = "versionRevision")]
public int Revision { get; set; }
}
}
@@ -0,0 +1,17 @@
// 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;
namespace Framework.Web
{
[DataContract]
public class RealmCharacterCountEntry
{
[DataMember(Name = "wowRealmAddress")]
public int WowRealmAddress { get; set; }
[DataMember(Name = "count")]
public int Count { get; set; }
}
}
@@ -0,0 +1,15 @@
// 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.Runtime.Serialization;
namespace Framework.Web
{
[DataContract]
public class RealmCharacterCountList
{
[DataMember(Name = "counts")]
public IList<RealmCharacterCountEntry> Counts { get; set; } = new List<RealmCharacterCountEntry>();
}
}
@@ -1,23 +1,9 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// 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;
namespace Framework.Rest
namespace Framework.Web
{
[DataContract]
public class RealmEntry
@@ -0,0 +1,15 @@
// 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.Runtime.Serialization;
namespace Framework.Web
{
[DataContract]
public class RealmListServerIPAddresses
{
[DataMember(Name = "families")]
public IList<AddressFamily> Families { get; set; } = new List<AddressFamily>();
}
}
@@ -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.Runtime.Serialization;
namespace Framework.Web
{
[DataContract]
public class RealmListTicketClientInformation
{
[DataMember(Name = "info")]
public RealmListTicketInformation Info { get; set; } = new RealmListTicketInformation();
}
}
@@ -0,0 +1,17 @@
// 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;
namespace Framework.Web
{
[DataContract]
public class RealmListTicketIdentity
{
[DataMember(Name = "gameAccountID")]
public int GameAccountId { get; set; }
[DataMember(Name = "gameAccountRegion")]
public int GameAccountRegion { get; set; }
}
}
@@ -1,24 +1,10 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// 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.Runtime.Serialization;
namespace Framework.Rest
namespace Framework.Web
{
[DataContract]
public class RealmListTicketInformation
@@ -0,0 +1,17 @@
// 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;
namespace Framework.Web
{
[DataContract]
public class RealmListUpdate
{
[DataMember(Name = "update")]
public RealmEntry Update { get; set; } = new RealmEntry();
[DataMember(Name = "deleting")]
public bool Deleting { get; set; }
}
}
@@ -0,0 +1,15 @@
// 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.Runtime.Serialization;
namespace Framework.Web
{
[DataContract]
public class RealmListUpdates
{
[DataMember(Name = "updates")]
public IList<RealmListUpdate> Updates { get; set; } = new List<RealmListUpdate>();
}
}
@@ -25,8 +25,8 @@ using Game.Groups;
using Game.Guilds;
using Game.Mails;
using Game.Maps;
using Game.Network;
using Game.Network.Packets;
using Game.Networking;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Text;
@@ -554,8 +554,8 @@ namespace Game.Achievements
string subject = reward.Subject;
string text = reward.Body;
LocaleConstant localeConstant = _owner.GetSession().GetSessionDbLocaleIndex();
if (localeConstant != LocaleConstant.enUS)
Locale localeConstant = _owner.GetSession().GetSessionDbLocaleIndex();
if (localeConstant != Locale.enUS)
{
AchievementRewardLocale loc = Global.AchievementMgr.GetAchievementRewardLocale(achievement);
if (loc != null)
@@ -1327,8 +1327,8 @@ namespace Game.Achievements
}
AchievementRewardLocale data = new AchievementRewardLocale();
LocaleConstant locale = localeName.ToEnum<LocaleConstant>();
if (locale == LocaleConstant.enUS)
Locale locale = localeName.ToEnum<Locale>();
if (locale == Locale.enUS)
continue;
ObjectManager.AddLocaleString(result.Read<string>(2), locale, data.Subject);
@@ -1363,8 +1363,8 @@ namespace Game.Achievements
public class AchievementRewardLocale
{
public StringArray Subject = new StringArray((int)LocaleConstant.Total);
public StringArray Body = new StringArray((int)LocaleConstant.Total);
public StringArray Subject = new StringArray((int)Locale.Total);
public StringArray Body = new StringArray((int)Locale.Total);
}
public class CompletedAchievementData
+2 -2
View File
@@ -24,8 +24,8 @@ using Game.DataStorage;
using Game.Entities;
using Game.Garrisons;
using Game.Maps;
using Game.Network;
using Game.Network.Packets;
using Game.Networking;
using Game.Networking.Packets;
using Game.Scenarios;
using Game.Spells;
using System;
+1 -1
View File
@@ -19,7 +19,7 @@ using Framework.Constants;
using Game.BattleGrounds;
using Game.Entities;
using Game.Guilds;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
+1 -1
View File
@@ -18,7 +18,7 @@
using Framework.Constants;
using Game.BattleGrounds;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
namespace Game.Arenas
{
+1 -1
View File
@@ -19,7 +19,7 @@ using Framework.Constants;
using Framework.Database;
using Game.Entities;
using Game.Groups;
using Game.Network;
using Game.Networking;
using System;
using System.Collections.Generic;
using System.Linq;
+1 -1
View File
@@ -17,7 +17,7 @@
using Framework.Constants;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using Game.BattleGrounds;
namespace Game.Arenas
+1 -1
View File
@@ -18,7 +18,7 @@
using Framework.Constants;
using Framework.Dynamic;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using Game.BattleGrounds;
namespace Game.Arenas
+1 -1
View File
@@ -17,7 +17,7 @@
using Framework.Constants;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using Game.BattleGrounds;
namespace Game.Arenas
+1 -1
View File
@@ -18,7 +18,7 @@
using Framework.Constants;
using Framework.Dynamic;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using Game.BattleGrounds;
namespace Game.Arenas
+1 -1
View File
@@ -17,7 +17,7 @@
using Framework.Constants;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using Game.BattleGrounds;
namespace Game.Arenas
+10 -10
View File
@@ -21,7 +21,7 @@ using Framework.Dynamic;
using Game.DataStorage;
using Game.Entities;
using Game.Mails;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
@@ -588,9 +588,9 @@ namespace Game
break;
}
for (LocaleConstant locale = LocaleConstant.enUS; locale < LocaleConstant.Total; ++locale)
for (Locale locale = Locale.enUS; locale < Locale.Total; ++locale)
{
if (locale == LocaleConstant.None)
if (locale == Locale.None)
continue;
bucket.FullName[(int)locale] = auction.Items[0].GetName(locale);
@@ -677,7 +677,7 @@ namespace Game
_itemsByAuctionId[auction.Id] = auction;
AuctionPosting.Sorter insertSorter = new AuctionPosting.Sorter(LocaleConstant.enUS, new AuctionSortDef[] { new AuctionSortDef(AuctionHouseSortOrder.Price, false) }, 1);
AuctionPosting.Sorter insertSorter = new AuctionPosting.Sorter(Locale.enUS, new AuctionSortDef[] { new AuctionSortDef(AuctionHouseSortOrder.Price, false) }, 1);
var auctionIndex = bucket.Auctions.BinarySearch(auction, insertSorter);
if (auctionIndex < 0)
auctionIndex = ~auctionIndex;
@@ -1407,7 +1407,7 @@ namespace Game
else
{
bidderAccId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(auction.Bidder);
logGmTrade = Global.AccountMgr.HasPermission(bidderAccId, RBACPermissions.LogGmTrade, Global.WorldMgr.GetRealmId().Realm);
logGmTrade = Global.AccountMgr.HasPermission(bidderAccId, RBACPermissions.LogGmTrade, Global.WorldMgr.GetRealmId().Index);
if (logGmTrade && !Global.CharacterCacheStorage.GetCharacterNameByGuid(auction.Bidder, out bidderName))
bidderName = Global.ObjectMgr.GetCypherString(CypherStrings.Unknown);
@@ -1724,7 +1724,7 @@ namespace Game
public class Sorter : IComparer<AuctionPosting>
{
public Sorter(LocaleConstant locale, AuctionSortDef[] sorts, int sortCount)
public Sorter(Locale locale, AuctionSortDef[] sorts, int sortCount)
{
_locale = locale;
_sorts = sorts;
@@ -1776,7 +1776,7 @@ namespace Game
return 0;
}
LocaleConstant _locale;
Locale _locale;
AuctionSortDef[] _sorts;
int _sortCount;
}
@@ -1800,7 +1800,7 @@ namespace Game
public byte SortLevel = 0;
public byte MinBattlePetLevel = 0;
public byte MaxBattlePetLevel = 0;
public string[] FullName = new string[(int)LocaleConstant.Total];
public string[] FullName = new string[(int)Locale.Total];
public List<AuctionPosting> Auctions = new List<AuctionPosting>();
@@ -1846,7 +1846,7 @@ namespace Game
public class Sorter : IComparer<AuctionsBucketData>
{
public Sorter(LocaleConstant locale, AuctionSortDef[] sorts, int sortCount)
public Sorter(Locale locale, AuctionSortDef[] sorts, int sortCount)
{
_locale = locale;
_sorts = sorts;
@@ -1884,7 +1884,7 @@ namespace Game
return 0;
}
LocaleConstant _locale;
Locale _locale;
AuctionSortDef[] _sorts;
int _sortCount;
}
+2 -2
View File
@@ -21,8 +21,8 @@ using Game.DataStorage;
using Game.Entities;
using Game.Groups;
using Game.Maps;
using Game.Network;
using Game.Network.Packets;
using Game.Networking;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
@@ -18,7 +18,7 @@
using Framework.Constants;
using Game.DataStorage;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using Game.Spells;
using System.Collections.Generic;
+2 -2
View File
@@ -24,8 +24,8 @@ using Game.Entities;
using Game.Groups;
using Game.Guilds;
using Game.Maps;
using Game.Network;
using Game.Network.Packets;
using Game.Networking;
using Game.Networking.Packets;
using Game.Spells;
using System;
using System.Collections.Generic;
@@ -20,7 +20,7 @@ using Framework.Database;
using Game.Arenas;
using Game.DataStorage;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -21,7 +21,7 @@ using Game.Arenas;
using Game.DataStorage;
using Game.Entities;
using Game.Groups;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -17,7 +17,7 @@
using Framework.Constants;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
namespace Game.BattleGrounds
{
@@ -18,7 +18,7 @@
using Framework.Constants;
using Game.DataStorage;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
@@ -18,7 +18,7 @@
using Game.Entities;
using Framework.Constants;
using System.Collections.Generic;
using Game.Network.Packets;
using Game.Networking.Packets;
using Game.DataStorage;
using Game.BattleGrounds;
@@ -18,7 +18,7 @@
using Framework.Constants;
using Game.DataStorage;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using System.Collections.Generic;
using Framework.GameMath;
@@ -18,7 +18,7 @@
using Framework.Constants;
using Game.DataStorage;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using System.Collections.Generic;
namespace Game.BattleGrounds.Zones
+1 -1
View File
@@ -19,7 +19,7 @@ using Framework.Constants;
using Framework.Database;
using Game.DataStorage;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Linq;
+1 -1
View File
@@ -19,7 +19,7 @@ using Framework.Collections;
using Framework.Constants;
using Framework.Database;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using System.Collections.Generic;
namespace Game.BlackMarket
@@ -19,7 +19,7 @@ using Framework.Constants;
using Framework.Database;
using Game.Entities;
using Game.Mails;
using Game.Network.Packets;
using Game.Networking.Packets;
using System.Collections.Generic;
namespace Game.BlackMarket
@@ -232,7 +232,7 @@ namespace Game.BlackMarket
if (bidderAccId == 0) // Account exists
return;
logGmTrade = Global.AccountMgr.HasPermission(bidderAccId, RBACPermissions.LogGmTrade, Global.WorldMgr.GetRealmId().Realm);
logGmTrade = Global.AccountMgr.HasPermission(bidderAccId, RBACPermissions.LogGmTrade, Global.WorldMgr.GetRealmId().Index);
if (logGmTrade && !Global.CharacterCacheStorage.GetCharacterNameByGuid(bidderGuid, out bidderName))
bidderName = Global.ObjectMgr.GetCypherString(CypherStrings.Unknown);
+1 -1
View File
@@ -4,7 +4,7 @@ using Game.Entities;
using Framework.Database;
using Framework.Constants;
using Game.Arenas;
using Game.Network.Packets;
using Game.Networking.Packets;
namespace Game.Cache
{
+2 -2
View File
@@ -20,8 +20,8 @@ using Framework.Database;
using Game.Entities;
using Game.Guilds;
using Game.Mails;
using Game.Network;
using Game.Network.Packets;
using Game.Networking;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Linq;
+3 -3
View File
@@ -21,7 +21,7 @@ using Framework.Database;
using Game.DataStorage;
using Game.Entities;
using Game.Maps;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -106,7 +106,7 @@ namespace Game.Chat
}
}
public static void GetChannelName(ref string channelName, uint channelId, LocaleConstant locale, AreaTableRecord zoneEntry)
public static void GetChannelName(ref string channelName, uint channelId, Locale locale, AreaTableRecord zoneEntry)
{
if (channelId != 0)
{
@@ -123,7 +123,7 @@ namespace Game.Chat
}
}
public string GetName(LocaleConstant locale = LocaleConstant.enUS)
public string GetName(Locale locale = Locale.enUS)
{
string result = _channelName;
GetChannelName(ref result, _channelId, locale, _zoneEntry);
+20 -20
View File
@@ -17,8 +17,8 @@
using Framework.Constants;
using Game.Entities;
using Game.Network;
using Game.Network.Packets;
using Game.Networking;
using Game.Networking.Packets;
using Game.Cache;
namespace Game.Chat
@@ -38,10 +38,10 @@ namespace Game.Chat
_modifier = modifier;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
// LocalizedPacketDo sends client DBC locale, we need to get available to server locale
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
ChannelNotify data = new ChannelNotify();
data.Type = _modifier.GetNotificationType();
@@ -61,9 +61,9 @@ namespace Game.Chat
_source = source;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
ChannelNotifyJoined notify = new ChannelNotifyJoined();
//notify.ChannelWelcomeMsg = "";
@@ -86,9 +86,9 @@ namespace Game.Chat
_suspended = suspend;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
ChannelNotifyLeft notify = new ChannelNotifyLeft();
notify.Channel = _source.GetName(localeIdx);
@@ -111,9 +111,9 @@ namespace Game.Chat
_guid = guid;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
ChatPkt packet = new ChatPkt();
Player player = Global.ObjAccessor.FindConnectedPlayer(_guid);
@@ -146,17 +146,17 @@ namespace Game.Chat
_guid = guid;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
ChatPkt packet = new ChatPkt();
Player player = Global.ObjAccessor.FindConnectedPlayer(_guid);
if (player)
packet.Initialize(ChatMsg.Channel, _lang, player, player, _what, 0, _source.GetName(localeIdx), LocaleConstant.enUS, _prefix);
packet.Initialize(ChatMsg.Channel, _lang, player, player, _what, 0, _source.GetName(localeIdx), Locale.enUS, _prefix);
else
{
packet.Initialize(ChatMsg.Channel, _lang, null, null, _what, 0, _source.GetName(localeIdx), LocaleConstant.enUS, _prefix);
packet.Initialize(ChatMsg.Channel, _lang, null, null, _what, 0, _source.GetName(localeIdx), Locale.enUS, _prefix);
packet.SenderGUID = _guid;
packet.TargetGUID = _guid;
}
@@ -179,9 +179,9 @@ namespace Game.Chat
_guid = guid;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
UserlistAdd userlistAdd = new UserlistAdd();
userlistAdd.AddedUserGUID = _guid;
@@ -204,9 +204,9 @@ namespace Game.Chat
_guid = guid;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
UserlistUpdate userlistUpdate = new UserlistUpdate();
userlistUpdate.UpdatedUserGUID = _guid;
@@ -229,9 +229,9 @@ namespace Game.Chat
_guid = guid;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
UserlistRemove userlistRemove = new UserlistRemove();
userlistRemove.RemovedUserGUID = _guid;
+3 -3
View File
@@ -18,7 +18,7 @@
using Framework.Constants;
using Game.DataStorage;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
@@ -145,7 +145,7 @@ namespace Game.Chat
{
ulong high = 0;
high |= (ulong)HighGuid.ChatChannel << 58;
high |= (ulong)Global.WorldMgr.GetRealmId().Realm << 42;
high |= (ulong)Global.WorldMgr.GetRealmId().Index << 42;
high |= (ulong)(_team == Team.Alliance ? 3 : 5) << 4;
ObjectGuid channelGuid = new ObjectGuid();
@@ -163,7 +163,7 @@ namespace Game.Chat
ulong high = 0;
high |= (ulong)HighGuid.ChatChannel << 58;
high |= (ulong)Global.WorldMgr.GetRealmId().Realm << 42;
high |= (ulong)Global.WorldMgr.GetRealmId().Index << 42;
high |= 1ul << 25; // built-in
if (channelEntry.Flags.HasAnyFlag(ChannelDBCFlags.CityOnly2))
high |= 1ul << 24; // trade
+3 -3
View File
@@ -22,7 +22,7 @@ using Game.DataStorage;
using Game.Entities;
using Game.Groups;
using Game.Maps;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -735,7 +735,7 @@ namespace Game.Chat
return Global.ObjectMgr.GetCypherString(str);
}
public virtual LocaleConstant GetSessionDbcLocale()
public virtual Locale GetSessionDbcLocale()
{
return _session.GetSessionDbcLocale();
}
@@ -864,7 +864,7 @@ namespace Game.Chat
return true;
}
public override LocaleConstant GetSessionDbcLocale()
public override Locale GetSessionDbcLocale()
{
return Global.WorldMgr.GetDefaultDbcLocale();
}
+2 -2
View File
@@ -317,7 +317,7 @@ namespace Game.Chat.Commands
[Command("account", RBACPermissions.CommandBanlistAccount, true)]
static bool HandleBanListAccountCommand(StringArguments args, CommandHandler handler)
{
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.DEL_EXPIRED_IP_BANS);
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.DelExpiredIpBans);
DB.Login.Execute(stmt);
string filterStr = args.NextString();
@@ -433,7 +433,7 @@ namespace Game.Chat.Commands
[Command("ip", RBACPermissions.CommandBanlistIp, true)]
static bool HandleBanListIPCommand(StringArguments args, CommandHandler handler)
{
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.DEL_EXPIRED_IP_BANS);
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.DelExpiredIpBans);
DB.Login.Execute(stmt);
string filterStr = args.NextString();
@@ -40,7 +40,7 @@ namespace Game.Chat
if (!handler.ExtractPlayerTarget(args, out target))
return false;
LocaleConstant loc = handler.GetSessionDbcLocale();
Locale loc = handler.GetSessionDbcLocale();
string targetName = target.GetName();
string knownStr = handler.GetCypherString(CypherStrings.Known);
@@ -405,7 +405,7 @@ namespace Game.Chat
if (!handler.ExtractPlayerTarget(args, out target))
return false;
LocaleConstant loc = handler.GetSessionDbcLocale();
Locale loc = handler.GetSessionDbcLocale();
var targetFSL = target.GetReputationMgr().GetStateList();
foreach (var pair in targetFSL)
+1 -1
View File
@@ -23,7 +23,7 @@ using Game.Combat;
using Game.DataStorage;
using Game.Entities;
using Game.Maps;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Text;
+1 -1
View File
@@ -170,7 +170,7 @@ namespace Game.Chat
// Get the accounts with GM Level >0
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_GM_ACCOUNTS);
stmt.AddValue(0, AccountTypes.Moderator);
stmt.AddValue(1, Global.WorldMgr.GetRealm().Id.Realm);
stmt.AddValue(1, Global.WorldMgr.GetRealm().Id.Index);
SQLResult result = DB.Login.Query(stmt);
if (!result.IsEmpty())

Some files were not shown because too many files have changed in this diff Show More