Adding ASN.1 protocol to chat cleaner server.

This commit is contained in:
lotodore
2009-08-14 21:18:28 +00:00
parent 1595da68d9
commit 459d7ed574
7 changed files with 136 additions and 14 deletions
-3
View File
@@ -25,9 +25,6 @@
#include <boost/enable_shared_from_this.hpp>
#include <string>
#define CLEANER_PROTOCOL_VERSION 1
#define MAX_CLEANER_PACKET_SIZE 384
class InternalChatCleanerPacket;
class EncodedPacket;
+9 -5
View File
@@ -193,6 +193,11 @@ ChatCleanerManager::HandleRead(const boost::system::error_code &ec, size_t bytes
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
else
{
m_socket->close();
m_connected = false;
}
}
else if (ec != boost::asio::error::operation_aborted)
{
@@ -205,7 +210,7 @@ ChatCleanerManager::HandleRead(const boost::system::error_code &ec, size_t bytes
bool
ChatCleanerManager::HandleMessage(InternalChatCleanerPacket &msg)
{
bool error = false;
bool error = true;
if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerInitAckMessage)
{
CleanerInitAckMessage_t *netAck = &msg.GetMsg()->choice.cleanerInitAckMessage;
@@ -213,14 +218,13 @@ ChatCleanerManager::HandleMessage(InternalChatCleanerPacket &msg)
{
string tmpSecret((const char *)netAck->serverSecret.buf, netAck->serverSecret.size);
if (m_serverSecret == tmpSecret)
{
m_connected = true;
error = false;
}
}
if (!m_connected)
{
LOG_ERROR("Chat cleaner handshake failed.");
m_socket->close();
error = true;
}
}
return error;
}
@@ -18,6 +18,7 @@
***************************************************************************/
#include <net/internalchatcleanerpacket.h>
#include <third_party/asn1/ChatCleanerMessage.h>
#include <cstring>
using namespace std;
+4 -1
View File
@@ -21,7 +21,10 @@
#ifndef _INTERNALCHATCLEANERPACKET_H_
#define _INTERNALCHATCLEANERPACKET_H_
#include <third_party/asn1/ChatCleanerMessage.h>
#define CLEANER_PROTOCOL_VERSION 1
#define MAX_CLEANER_PACKET_SIZE 384
typedef struct ChatCleanerMessage ChatCleanerMessage_t;
class InternalChatCleanerPacket
{