More code dedupe.

This commit is contained in:
Ian Gulliver
2015-02-07 15:25:22 -08:00
parent d82cb789e3
commit 4274c7ca1d
2 changed files with 66 additions and 82 deletions

View File

@@ -33,11 +33,18 @@ class CryptoConnBase : public CryptoBase {
std::unique_ptr<TLVNode> BuildSecureHandshake();
bool HandleSecureHandshake(const TLVNode& node);
static void OnReadable_(struct bufferevent* bev, void* this__);
void OnReadable();
virtual void OnHandshake(const TLVNode& decoded) = 0;
virtual bool OnMessage(const TLVNode& node) = 0;
enum {
AWAITING_HANDSHAKE,
READY,
} state_;
struct bufferevent* bev_;
const std::string secret_key_;
std::string peer_public_key_;
std::string ephemeral_secret_key_;
@@ -68,16 +75,14 @@ class CryptoPubServerConnection : public CryptoConnBase {
~CryptoPubServerConnection();
private:
static void OnReadable_(struct bufferevent* bev, void* this__);
void OnReadable();
void OnHandshake(const TLVNode& decoded);
bool OnMessage(const TLVNode& node);
static void OnError_(struct bufferevent* bev, const short what, void* this__);
void OnError(const short what);
void SendHandshake();
struct bufferevent* bev_;
friend CryptoPubServer;
};
@@ -91,9 +96,9 @@ class CryptoPubClient : public CryptoConnBase {
void Loop();
private:
static void OnReadable_(struct bufferevent* bev, void* this__);
void OnReadable();
void OnHandshake(const TLVNode& decoded);
bool OnMessage(const TLVNode& node);
static void OnConnectOrError_(struct bufferevent* bev, const short what, void* this__);
void OnConnect();
void OnError();
@@ -102,7 +107,6 @@ class CryptoPubClient : public CryptoConnBase {
void SendTunnelRequest();
struct event_base* event_base_;
struct bufferevent* bev_;
const std::list<uint64_t> channel_bitrates_;
};