aboutsummaryrefslogtreecommitdiff
path: root/src/server/bnetserver/Services
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2016-03-28 17:12:57 +0200
committerShauren <shauren.trinity@gmail.com>2016-03-28 17:12:57 +0200
commitdde620c402daf4ea8d132fb72a77eabc22f7a6d0 (patch)
tree7c12161d7a22915736b0c9a106de896eeb283399 /src/server/bnetserver/Services
parent619669c6209441fc2fb5b483d553badee8c30ad5 (diff)
Core: Updated to 6.2.4
* Rewrite bnetserver for new authentication protocol
Diffstat (limited to 'src/server/bnetserver/Services')
-rw-r--r--src/server/bnetserver/Services/AccountService.cpp33
-rw-r--r--src/server/bnetserver/Services/AccountService.h44
-rw-r--r--src/server/bnetserver/Services/AuthenticationService.cpp33
-rw-r--r--src/server/bnetserver/Services/AuthenticationService.h44
-rw-r--r--src/server/bnetserver/Services/ConnectionService.cpp57
-rw-r--r--src/server/bnetserver/Services/ConnectionService.h46
-rw-r--r--src/server/bnetserver/Services/GameUtilitiesService.cpp33
-rw-r--r--src/server/bnetserver/Services/GameUtilitiesService.h44
-rw-r--r--src/server/bnetserver/Services/Service.h45
-rw-r--r--src/server/bnetserver/Services/ServiceDispatcher.cpp48
-rw-r--r--src/server/bnetserver/Services/ServiceDispatcher.h68
11 files changed, 495 insertions, 0 deletions
diff --git a/src/server/bnetserver/Services/AccountService.cpp b/src/server/bnetserver/Services/AccountService.cpp
new file mode 100644
index 00000000000..c4b6da289b8
--- /dev/null
+++ b/src/server/bnetserver/Services/AccountService.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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 2 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/>.
+ */
+
+#include "AccountService.h"
+#include "Session.h"
+
+Battlenet::Services::Account::Account(Session* session) : AccountService(session)
+{
+}
+
+uint32 Battlenet::Services::Account::HandleGetAccountState(account::v1::GetAccountStateRequest const* request, account::v1::GetAccountStateResponse* response)
+{
+ return _session->HandleGetAccountState(request, response);
+}
+
+uint32 Battlenet::Services::Account::HandleGetGameAccountState(account::v1::GetGameAccountStateRequest const* request, account::v1::GetGameAccountStateResponse* response)
+{
+ return _session->HandleGetGameAccountState(request, response);
+}
diff --git a/src/server/bnetserver/Services/AccountService.h b/src/server/bnetserver/Services/AccountService.h
new file mode 100644
index 00000000000..8f950961a90
--- /dev/null
+++ b/src/server/bnetserver/Services/AccountService.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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 2 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/>.
+ */
+
+#ifndef AccountService_h__
+#define AccountService_h__
+
+#include "Common.h"
+#include "Service.h"
+#include "account_service.pb.h"
+
+namespace Battlenet
+{
+ class Session;
+
+ namespace Services
+ {
+ class Account : public Service<account::v1::AccountService>
+ {
+ typedef Service<account::v1::AccountService> AccountService;
+
+ public:
+ Account(Session* session);
+
+ uint32 HandleGetAccountState(account::v1::GetAccountStateRequest const* request, account::v1::GetAccountStateResponse* response) override;
+ uint32 HandleGetGameAccountState(account::v1::GetGameAccountStateRequest const* request, account::v1::GetGameAccountStateResponse* response) override;
+ };
+ }
+}
+
+#endif // AccountService_h__
diff --git a/src/server/bnetserver/Services/AuthenticationService.cpp b/src/server/bnetserver/Services/AuthenticationService.cpp
new file mode 100644
index 00000000000..fd703ad22ac
--- /dev/null
+++ b/src/server/bnetserver/Services/AuthenticationService.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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 2 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/>.
+ */
+
+#include "AuthenticationService.h"
+#include "Session.h"
+
+Battlenet::Services::Authentication::Authentication(Session* session) : AuthenticationService(session)
+{
+}
+
+uint32 Battlenet::Services::Authentication::HandleLogon(authentication::v1::LogonRequest const* request, NoData* /*respons*/)
+{
+ return _session->HandleLogon(request);
+}
+
+uint32 Battlenet::Services::Authentication::HandleVerifyWebCredentials(authentication::v1::VerifyWebCredentialsRequest const* request, NoData* /*respons*/)
+{
+ return _session->HandleVerifyWebCredentials(request);
+}
diff --git a/src/server/bnetserver/Services/AuthenticationService.h b/src/server/bnetserver/Services/AuthenticationService.h
new file mode 100644
index 00000000000..e5a2726b110
--- /dev/null
+++ b/src/server/bnetserver/Services/AuthenticationService.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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 2 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/>.
+ */
+
+#ifndef AuthenticationService_h__
+#define AuthenticationService_h__
+
+#include "Common.h"
+#include "Service.h"
+#include "authentication_service.pb.h"
+
+namespace Battlenet
+{
+ class Session;
+
+ namespace Services
+ {
+ class Authentication : public Service<authentication::v1::AuthenticationService>
+ {
+ typedef Service<authentication::v1::AuthenticationService> AuthenticationService;
+
+ public:
+ Authentication(Session* session);
+
+ uint32 HandleLogon(authentication::v1::LogonRequest const* request, NoData* respons) override;
+ uint32 HandleVerifyWebCredentials(authentication::v1::VerifyWebCredentialsRequest const* request, NoData* respons) override;
+ };
+ }
+}
+
+#endif // AuthenticationService_h__
diff --git a/src/server/bnetserver/Services/ConnectionService.cpp b/src/server/bnetserver/Services/ConnectionService.cpp
new file mode 100644
index 00000000000..78ead03b7e6
--- /dev/null
+++ b/src/server/bnetserver/Services/ConnectionService.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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 2 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/>.
+ */
+
+#include "ConnectionService.h"
+#include "Duration.h"
+#include "Log.h"
+#include "Session.h"
+#include "Util.h"
+#include "BattlenetRpcErrorCodes.h"
+
+Battlenet::Services::Connection::Connection(Session* session) : ConnectionService(session)
+{
+}
+
+uint32 Battlenet::Services::Connection::HandleConnect(connection::v1::ConnectRequest const* request, connection::v1::ConnectResponse* response)
+{
+ if (request->has_client_id())
+ response->mutable_client_id()->CopyFrom(request->client_id());
+
+ std::chrono::system_clock::duration now = std::chrono::system_clock::now().time_since_epoch();
+
+ response->mutable_server_id()->set_label(GetPID());
+ response->mutable_server_id()->set_epoch(std::chrono::duration_cast<Seconds>(now).count());
+ response->set_server_time(std::chrono::duration_cast<Milliseconds>(now).count());
+
+ response->set_use_bindless_rpc(request->use_bindless_rpc());
+ return ERROR_OK;
+}
+
+uint32 Battlenet::Services::Connection::HandleKeepAlive(NoData const* /*request*/)
+{
+ return ERROR_OK;
+}
+
+uint32 Battlenet::Services::Connection::HandleRequestDisconnect(connection::v1::DisconnectRequest const* request)
+{
+ connection::v1::DisconnectNotification disconnectNotification;
+ disconnectNotification.set_error_code(request->error_code());
+ ForceDisconnect(&disconnectNotification);
+
+ _session->DelayedCloseSocket();
+ return ERROR_OK;
+}
diff --git a/src/server/bnetserver/Services/ConnectionService.h b/src/server/bnetserver/Services/ConnectionService.h
new file mode 100644
index 00000000000..48b726eb2ba
--- /dev/null
+++ b/src/server/bnetserver/Services/ConnectionService.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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 2 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/>.
+ */
+
+#ifndef ConnectionService_h__
+#define ConnectionService_h__
+
+#include "Common.h"
+#include "Service.h"
+#include "connection_service.pb.h"
+
+namespace Battlenet
+{
+ class Session;
+
+ namespace Services
+ {
+ class Connection : public Service<connection::v1::ConnectionService>
+ {
+ typedef Service<connection::v1::ConnectionService> ConnectionService;
+
+ public:
+ Connection(Session* session);
+
+ uint32 HandleConnect(connection::v1::ConnectRequest const* request, connection::v1::ConnectResponse* respons) override;
+ uint32 HandleKeepAlive(NoData const* request) override;
+ uint32 HandleRequestDisconnect(connection::v1::DisconnectRequest const* request) override;
+
+ };
+ }
+}
+
+#endif // ConnectionService_h__
diff --git a/src/server/bnetserver/Services/GameUtilitiesService.cpp b/src/server/bnetserver/Services/GameUtilitiesService.cpp
new file mode 100644
index 00000000000..e9e7b36724d
--- /dev/null
+++ b/src/server/bnetserver/Services/GameUtilitiesService.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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 2 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/>.
+ */
+
+#include "GameUtilitiesService.h"
+#include "Session.h"
+
+Battlenet::Services::GameUtilities::GameUtilities(Session* session) : GameUtilitiesService(session)
+{
+}
+
+uint32 Battlenet::Services::GameUtilities::HandleProcessClientRequest(game_utilities::v1::ClientRequest const* request, game_utilities::v1::ClientResponse* response)
+{
+ return _session->HandleProcessClientRequest(request, response);
+}
+
+uint32 Battlenet::Services::GameUtilities::HandleGetAllValuesForAttribute(game_utilities::v1::GetAllValuesForAttributeRequest const* request, game_utilities::v1::GetAllValuesForAttributeResponse* response)
+{
+ return _session->HandleGetAllValuesForAttribute(request, response);
+}
diff --git a/src/server/bnetserver/Services/GameUtilitiesService.h b/src/server/bnetserver/Services/GameUtilitiesService.h
new file mode 100644
index 00000000000..37f56e03566
--- /dev/null
+++ b/src/server/bnetserver/Services/GameUtilitiesService.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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 2 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/>.
+ */
+
+#ifndef GameUtilitiesServiceService_h__
+#define GameUtilitiesServiceService_h__
+
+#include "Common.h"
+#include "Service.h"
+#include "game_utilities_service.pb.h"
+
+namespace Battlenet
+{
+ class Session;
+
+ namespace Services
+ {
+ class GameUtilities : public Service<game_utilities::v1::GameUtilitiesService>
+ {
+ typedef Service<game_utilities::v1::GameUtilitiesService> GameUtilitiesService;
+
+ public:
+ GameUtilities(Session* session);
+
+ uint32 HandleProcessClientRequest(game_utilities::v1::ClientRequest const* request, game_utilities::v1::ClientResponse* response) override;
+ uint32 HandleGetAllValuesForAttribute(game_utilities::v1::GetAllValuesForAttributeRequest const* request, game_utilities::v1::GetAllValuesForAttributeResponse* response) override;
+ };
+ }
+}
+
+#endif // GameUtilitiesServiceService_h__
diff --git a/src/server/bnetserver/Services/Service.h b/src/server/bnetserver/Services/Service.h
new file mode 100644
index 00000000000..f2f4ee76c3f
--- /dev/null
+++ b/src/server/bnetserver/Services/Service.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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 2 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/>.
+ */
+
+#ifndef Service_h__
+#define Service_h__
+
+#include "Session.h"
+
+namespace bgs { namespace protocol { } }
+using namespace bgs::protocol;
+
+namespace Battlenet
+{
+ template<class T>
+ class Service : public T
+ {
+ public:
+ Service(Session* session) : T(true), _session(session) { }
+
+ protected:
+ void SendRequest(uint32 serviceHash, uint32 methodId, google::protobuf::Message const* request, std::function<void(MessageBuffer)> callback) override { _session->SendRequest(serviceHash, methodId, request, std::move(callback)); }
+ void SendRequest(uint32 serviceHash, uint32 methodId, google::protobuf::Message const* request) override { _session->SendRequest(serviceHash, methodId, request); }
+ void SendResponse(uint32 /*serviceHash*/, uint32 /*methodId*/, uint32 token, uint32 status) override { _session->SendResponse(token, status); }
+ void SendResponse(uint32 /*serviceHash*/, uint32 /*methodId*/, uint32 token, google::protobuf::Message const* response) override { _session->SendResponse(token, response); }
+ std::string GetCallerInfo() const override { return _session->GetClientInfo(); }
+
+ Session* _session;
+ };
+}
+
+#endif // Service_h__
diff --git a/src/server/bnetserver/Services/ServiceDispatcher.cpp b/src/server/bnetserver/Services/ServiceDispatcher.cpp
new file mode 100644
index 00000000000..ded1c2d3765
--- /dev/null
+++ b/src/server/bnetserver/Services/ServiceDispatcher.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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 2 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/>.
+ */
+
+#include "ServiceDispatcher.h"
+
+Battlenet::ServiceDispatcher::ServiceDispatcher()
+{
+ AddService<Services::Account>();
+ AddService<Services::Authentication>();
+ AddService<Service<challenge::v1::ChallengeService>>();
+ AddService<Service<channel::v1::ChannelService>>();
+ AddService<Services::Connection>();
+ AddService<Service<friends::v1::FriendsService>>();
+ AddService<Services::GameUtilities>();
+ AddService<Service<presence::v1::PresenceService>>();
+ AddService<Service<report::v1::ReportService>>();
+ AddService<Service<resources::v1::ResourcesService>>();
+ AddService<Service<user_manager::v1::UserManagerService>>();
+}
+
+void Battlenet::ServiceDispatcher::Dispatch(Session* session, uint32 serviceHash, uint32 token, uint32 methodId, MessageBuffer buffer)
+{
+ auto itr = _dispatchers.find(serviceHash);
+ if (itr != _dispatchers.end())
+ itr->second(session, token, methodId, std::forward<MessageBuffer>(buffer));
+ else
+ TC_LOG_DEBUG("session.rpc", "%s tried to call invalid service 0x%X", session->GetClientInfo().c_str(), serviceHash);
+}
+
+Battlenet::ServiceDispatcher& Battlenet::ServiceDispatcher::Instance()
+{
+ static ServiceDispatcher instance;
+ return instance;
+}
diff --git a/src/server/bnetserver/Services/ServiceDispatcher.h b/src/server/bnetserver/Services/ServiceDispatcher.h
new file mode 100644
index 00000000000..03f67070ef5
--- /dev/null
+++ b/src/server/bnetserver/Services/ServiceDispatcher.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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 2 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/>.
+ */
+
+#ifndef ServiceRegistry_h__
+#define ServiceRegistry_h__
+
+#include "MessageBuffer.h"
+#include "Log.h"
+#include "Common.h"
+#include "AccountService.h"
+#include "AuthenticationService.h"
+#include "challenge_service.pb.h"
+#include "channel_service.pb.h"
+#include "ConnectionService.h"
+#include "friends_service.pb.h"
+#include "GameUtilitiesService.h"
+#include "presence_service.pb.h"
+#include "report_service.pb.h"
+#include "resource_service.pb.h"
+#include "user_manager_service.pb.h"
+
+namespace Battlenet
+{
+ class Session;
+
+ class ServiceDispatcher
+ {
+ public:
+ void Dispatch(Session* session, uint32 serviceHash, uint32 token, uint32 methodId, MessageBuffer buffer);
+
+ static ServiceDispatcher& Instance();
+
+ private:
+ ServiceDispatcher();
+
+ template<class Service>
+ void AddService()
+ {
+ _dispatchers[Service::OriginalHash::value] = &ServiceDispatcher::Dispatch<Service>;
+ }
+
+ template<class Service>
+ static void Dispatch(Session* session, uint32 token, uint32 methodId, MessageBuffer buffer)
+ {
+ Service(session).CallServerMethod(token, methodId, std::forward<MessageBuffer>(buffer));
+ }
+
+ std::unordered_map<uint32, std::function<void(Session*, uint32, uint32, MessageBuffer)>> _dispatchers;
+ };
+}
+
+#define sServiceDispatcher ServiceDispatcher::Instance()
+
+#endif // ServiceRegistry_h__