mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add ssl support for peer connections.
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#include "Application.h"
|
||||
#include "utils.h"
|
||||
|
||||
// XXX On Windows make sure OpenSSL PRNG is seeded: EGADS
|
||||
|
||||
ConnectionPool::ConnectionPool() :
|
||||
iConnecting(0),
|
||||
mCtx(boost::asio::ssl::context::sslv23)
|
||||
@@ -17,16 +19,16 @@ ConnectionPool::ConnectionPool() :
|
||||
| boost::asio::ssl::context::no_sslv2
|
||||
| boost::asio::ssl::context::single_dh_use);
|
||||
|
||||
SSL_CTX_set_cipher_list(mCtx.native_handle(), "ALL:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
if (1 != SSL_CTX_set_cipher_list(mCtx.native_handle(), theConfig.PEER_SSL_CIPHER_LIST.c_str()))
|
||||
std::runtime_error("Error setting cipher list (no valid ciphers).");
|
||||
}
|
||||
|
||||
|
||||
void ConnectionPool::start()
|
||||
{
|
||||
// XXX Start running policy.
|
||||
}
|
||||
|
||||
// XXX Broken don't send a message to a peer if we got it from the peer.
|
||||
// XXX Broken: also don't send a message to a peer if we got it from the peer.
|
||||
void ConnectionPool::relayMessage(Peer* fromPeer, PackedMessage::pointer msg)
|
||||
{
|
||||
BOOST_FOREACH(naPeer pair, mConnectedMap)
|
||||
@@ -138,18 +140,17 @@ bool ConnectionPool::peerConnected(Peer::pointer peer, const NewcoinAddress& na)
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
void ConnectionPool::peerDisconnected(Peer::pointer peer)
|
||||
void ConnectionPool::peerDisconnected(Peer::pointer peer, const ipPort& ipPeer, const NewcoinAddress& naPeer)
|
||||
{
|
||||
std::cerr << "ConnectionPool::peerDisconnected: " << peer->mIpPort.first << " " << peer->mIpPort.second << std::endl;
|
||||
|
||||
boost::mutex::scoped_lock sl(mPeerLock);
|
||||
|
||||
// XXX Don't access member variable directly.
|
||||
if (peer->mPublicKey.isValid())
|
||||
if (naPeer.isValid())
|
||||
{
|
||||
boost::unordered_map<NewcoinAddress, Peer::pointer>::iterator itCm;
|
||||
|
||||
itCm = mConnectedMap.find(peer->mPublicKey);
|
||||
itCm = mConnectedMap.find(naPeer);
|
||||
|
||||
if (itCm == mConnectedMap.end())
|
||||
{
|
||||
@@ -164,16 +165,15 @@ void ConnectionPool::peerDisconnected(Peer::pointer peer)
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Don't access member variable directly.
|
||||
boost::unordered_map<ipPort, Peer::pointer>::iterator itIp;
|
||||
|
||||
itIp = mIpMap.find(peer->mIpPort);
|
||||
itIp = mIpMap.find(ipPeer);
|
||||
|
||||
if (itIp == mIpMap.end())
|
||||
{
|
||||
// Did not find it. Not already connecting or connected.
|
||||
std::cerr << "Internal Error: peer wasn't connected: "
|
||||
<< peer->mIpPort.first << " " << peer->mIpPort.second << std::endl;
|
||||
<< ipPeer.first << " " << ipPeer.second << std::endl;
|
||||
// XXX Bad error.
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user