1
This commit is contained in:
parent
4e702143ef
commit
fd49464d7c
@ -1,5 +1,7 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
|
#include <openssl/bn.h>
|
||||||
|
|
||||||
#include <google/protobuf/message.h>
|
#include <google/protobuf/message.h>
|
||||||
#include <a8/mixedsession.h>
|
#include <a8/mixedsession.h>
|
||||||
#include <a8/tcplistener.h>
|
#include <a8/tcplistener.h>
|
||||||
@ -132,6 +134,19 @@ public:
|
|||||||
.SetParam1(1));
|
.SetParam1(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetKey(unsigned char* data, int len)
|
||||||
|
{
|
||||||
|
send_i_ = 0;
|
||||||
|
send_j_ = 0;
|
||||||
|
recv_i_ = 0;
|
||||||
|
recv_j_ = 0;
|
||||||
|
initialized_ = true;
|
||||||
|
key_.clear();
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
key_.push_back(data[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void SendBuff(const char* buff, unsigned int bufflen) override
|
virtual void SendBuff(const char* buff, unsigned int bufflen) override
|
||||||
@ -197,6 +212,25 @@ void GCListener::MarkClient(int sockhandle, bool is_active)
|
|||||||
tcp_listener_->MarkClient(sockhandle, is_active);
|
tcp_listener_->MarkClient(sockhandle, is_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GCListener::SetKey(int sockhandle, const std::string& key)
|
||||||
|
{
|
||||||
|
tcp_listener_->LockClients();
|
||||||
|
GCClientSession* session = (GCClientSession*)tcp_listener_->GetClientSession(sockhandle);
|
||||||
|
if (session) {
|
||||||
|
bignum_st* bn = BN_new();
|
||||||
|
BN_hex2bn(&bn, key.c_str());
|
||||||
|
{
|
||||||
|
int length = BN_num_bytes(bn);
|
||||||
|
unsigned char* _array = new unsigned char[length];
|
||||||
|
BN_bn2bin(bn, (unsigned char*)_array);
|
||||||
|
std::reverse(_array, _array + length);
|
||||||
|
session->SetKey(_array, 40);
|
||||||
|
}
|
||||||
|
BN_free(bn);
|
||||||
|
}
|
||||||
|
tcp_listener_->UnLockClients();
|
||||||
|
}
|
||||||
|
|
||||||
void GCListener::InternalSendMsg(int socket_handle, int msgid, google::protobuf::Message& msg)
|
void GCListener::InternalSendMsg(int socket_handle, int msgid, google::protobuf::Message& msg)
|
||||||
{
|
{
|
||||||
unsigned short packlen = 2 + CustomPbSerializeSize(&msg);
|
unsigned short packlen = 2 + CustomPbSerializeSize(&msg);
|
||||||
|
@ -44,6 +44,7 @@ class GCListener : public a8::Singleton<GCListener>
|
|||||||
|
|
||||||
void ForceCloseClient(int sockhandle);
|
void ForceCloseClient(int sockhandle);
|
||||||
void MarkClient(int sockhandle, bool is_active);
|
void MarkClient(int sockhandle, bool is_active);
|
||||||
|
void SetKey(int sockhandle, const std::string& key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InternalSendMsg(int socket_handle, int msgid, google::protobuf::Message& msg);
|
void InternalSendMsg(int socket_handle, int msgid, google::protobuf::Message& msg);
|
||||||
|
@ -24,6 +24,8 @@ void PlayerMgr::_CMAuthSession(f8::MsgHdr& hdr, const cs::CMAuthSession& msg)
|
|||||||
msg.account()
|
msg.account()
|
||||||
});
|
});
|
||||||
assert(ret > 0);
|
assert(ret > 0);
|
||||||
|
GCListener::Instance()->SetKey(hdr.socket_handle,
|
||||||
|
DBEngine::Instance()->GetValue(2).GetString());
|
||||||
cs::SMAuthResponse respmsg;
|
cs::SMAuthResponse respmsg;
|
||||||
respmsg.set_errcode(AUTH_OK);
|
respmsg.set_errcode(AUTH_OK);
|
||||||
GCListener::Instance()->SendMsg(hdr.socket_handle, respmsg);
|
GCListener::Instance()->SendMsg(hdr.socket_handle, respmsg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user