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>
+10 -25
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 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 RealmManager RealmMgr { get { return RealmManager.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
}
}
+30 -49
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)
{
var httpRequest = HttpHelper.ParseRequest(GetReceiveBuffer(), transferredBytes);
public async override void ReadHandler(byte[] data, int receivedLength)
{
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);
}
@@ -171,7 +152,7 @@ namespace BNetServer.Networking
SendResponse(HttpCode.Ok, loginResult);
}
else
{
{
loginResult.AuthenticationState = "LOGIN";
loginResult.ErrorCode = "UNABLE_TO_DECODE";
loginResult.ErrorMessage = "There was an internal error while connecting to Battle.net. Please try again later.";
@@ -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;
}
}
}
+129 -567
View File
@@ -1,87 +1,80 @@
/*
* 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)
{
if (!result.IsEmpty())
queryProcessor.AddCallback(DB.Login.AsyncQuery(stmt).WithCallback(async result =>
{
bool banned = false;
do
if (!result.IsEmpty())
{
if (result.Read<ulong>(0) != 0)
banned = true;
bool banned = false;
do
{
if (result.Read<ulong>(0) != 0)
banned = true;
if (!string.IsNullOrEmpty(result.Read<string>(1)))
_ipCountry = result.Read<string>(1);
if (!string.IsNullOrEmpty(result.Read<string>(1)))
ipCountry = result.Read<string>(1);
} while (result.NextRow());
} while (result.NextRow());
if (banned)
{
Log.outDebug(LogFilter.Session, "{0} tries to log in using banned IP!", GetClientInfo());
CloseSocket();
return;
if (banned)
{
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;
+22 -39
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,17 +88,18 @@ 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;
}
}
}